Repository: yannickcr/eslint-plugin-react
Pull request #683 (2016-07-15 20:29:09)

Add in an "all" config
Much like eslint:all

http://eslint.org/docs/user-guide/configuring#using-eslintall

ljharb: These should probably be a superset of the "recommended" config - what about these options https://github.com/yannickcr/eslint-plugin-react/blob/master/index.js#L68-L69 ?
pfhayes: That's a good point. I would say that "all" should be every rule in it's default configuration, and I would also say it's okay for "recommended" to deviate from default configurations (to ones that might be preferred). But I'm happy to update this to be a superset of recommended if you disagree
pfhayes: Also, what do you think is the best for `react/jsx-sort-prop-types` ? It's deprecated and replaced by `react/sort-prop-types` so maybe it should be excluded from `all`?
yannickcr: Nice. Can you also update the Readme?
pfhayes: Sure thing, I've updated the README now
yannickcr: Thanks, can you rebase your branch? Then I think we'll be good to go :)
pfhayes: Done, should be good to go now

Patch:
diff --git a/README.md b/README.md
index e6dc4d09..44bb84ab 100644
--- a/README.md
+++ b/README.md
@@ -149,6 +149,18 @@ To enable this configuration use the `extends` property in your `.eslintrc` conf
 }
 ```
 
+This plugin also exports an `all` configuration that includes every available rule.
+This pairs well with the `eslint:all` rule.
+
+```js
+{
+  "plugins": [
+    "react"
+  ],
+  "extends": ["eslint:all", "plugin:react/all"]
+}
+```
+
 See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information about extending configuration files.
 
 The rules enabled in this configuration are:
diff --git a/index.js b/index.js
index 5abe6595..7f0ae1bb 100644
--- a/index.js
+++ b/index.js
@@ -1,55 +1,63 @@
 'use strict';
 
+var rules = {
+  'jsx-uses-react': require('./lib/rules/jsx-uses-react'),
+  'no-multi-comp': require('./lib/rules/no-multi-comp'),
+  'prop-types': require('./lib/rules/prop-types'),
+  'display-name': require('./lib/rules/display-name'),
+  'wrap-multilines': require('./lib/rules/wrap-multilines'),
+  'self-closing-comp': require('./lib/rules/self-closing-comp'),
+  'no-comment-textnodes': require('./lib/rules/no-comment-textnodes'),
+  'no-danger': require('./lib/rules/no-danger'),
+  'no-set-state': require('./lib/rules/no-set-state'),
+  'no-is-mounted': require('./lib/rules/no-is-mounted'),
+  'no-deprecated': require('./lib/rules/no-deprecated'),
+  'no-did-mount-set-state': require('./lib/rules/no-did-mount-set-state'),
+  'no-did-update-set-state': require('./lib/rules/no-did-update-set-state'),
+  'no-render-return-value': require('./lib/rules/no-render-return-value'),
+  'react-in-jsx-scope': require('./lib/rules/react-in-jsx-scope'),
+  'jsx-uses-vars': require('./lib/rules/jsx-uses-vars'),
+  'jsx-handler-names': require('./lib/rules/jsx-handler-names'),
+  'jsx-pascal-case': require('./lib/rules/jsx-pascal-case'),
+  'jsx-no-bind': require('./lib/rules/jsx-no-bind'),
+  'jsx-no-undef': require('./lib/rules/jsx-no-undef'),
+  'no-unknown-property': require('./lib/rules/no-unknown-property'),
+  'jsx-curly-spacing': require('./lib/rules/jsx-curly-spacing'),
+  'jsx-equals-spacing': require('./lib/rules/jsx-equals-spacing'),
+  'jsx-sort-props': require('./lib/rules/jsx-sort-props'),
+  'sort-prop-types': require('./lib/rules/sort-prop-types'),
+  'jsx-boolean-value': require('./lib/rules/jsx-boolean-value'),
+  'sort-comp': require('./lib/rules/sort-comp'),
+  'require-extension': require('./lib/rules/require-extension'),
+  'jsx-no-duplicate-props': require('./lib/rules/jsx-no-duplicate-props'),
+  'jsx-max-props-per-line': require('./lib/rules/jsx-max-props-per-line'),
+  'jsx-no-literals': require('./lib/rules/jsx-no-literals'),
+  'jsx-indent-props': require('./lib/rules/jsx-indent-props'),
+  'jsx-indent': require('./lib/rules/jsx-indent'),
+  'jsx-closing-bracket-location': require('./lib/rules/jsx-closing-bracket-location'),
+  'jsx-space-before-closing': require('./lib/rules/jsx-space-before-closing'),
+  'no-direct-mutation-state': require('./lib/rules/no-direct-mutation-state'),
+  'forbid-prop-types': require('./lib/rules/forbid-prop-types'),
+  'prefer-es6-class': require('./lib/rules/prefer-es6-class'),
+  'jsx-key': require('./lib/rules/jsx-key'),
+  'no-string-refs': require('./lib/rules/no-string-refs'),
+  'prefer-stateless-function': require('./lib/rules/prefer-stateless-function'),
+  'require-render-return': require('./lib/rules/require-render-return'),
+  'jsx-first-prop-new-line': require('./lib/rules/jsx-first-prop-new-line'),
+  'jsx-no-target-blank': require('./lib/rules/jsx-no-target-blank'),
+  'jsx-filename-extension': require('./lib/rules/jsx-filename-extension'),
+  'require-optimization': require('./lib/rules/require-optimization'),
+  'no-find-dom-node': require('./lib/rules/no-find-dom-node')
+};
+
+var ruleNames = Object.keys(rules);
+var allRules = {};
+for (var i = 0; i < ruleNames.length; i++) {
+  allRules['react/' + ruleNames[i]] = 2;
+}
+
 module.exports = {
-  rules: {
-    'jsx-uses-react': require('./lib/rules/jsx-uses-react'),
-    'no-multi-comp': require('./lib/rules/no-multi-comp'),
-    'prop-types': require('./lib/rules/prop-types'),
-    'display-name': require('./lib/rules/display-name'),
-    'wrap-multilines': require('./lib/rules/wrap-multilines'),
-    'self-closing-comp': require('./lib/rules/self-closing-comp'),
-    'no-comment-textnodes': require('./lib/rules/no-comment-textnodes'),
-    'no-danger': require('./lib/rules/no-danger'),
-    'no-set-state': require('./lib/rules/no-set-state'),
-    'no-is-mounted': require('./lib/rules/no-is-mounted'),
-    'no-deprecated': require('./lib/rules/no-deprecated'),
-    'no-did-mount-set-state': require('./lib/rules/no-did-mount-set-state'),
-    'no-did-update-set-state': require('./lib/rules/no-did-update-set-state'),
-    'no-render-return-value': require('./lib/rules/no-render-return-value'),
-    'react-in-jsx-scope': require('./lib/rules/react-in-jsx-scope'),
-    'jsx-uses-vars': require('./lib/rules/jsx-uses-vars'),
-    'jsx-handler-names': require('./lib/rules/jsx-handler-names'),
-    'jsx-pascal-case': require('./lib/rules/jsx-pascal-case'),
-    'jsx-no-bind': require('./lib/rules/jsx-no-bind'),
-    'jsx-no-undef': require('./lib/rules/jsx-no-undef'),
-    'no-unknown-property': require('./lib/rules/no-unknown-property'),
-    'jsx-curly-spacing': require('./lib/rules/jsx-curly-spacing'),
-    'jsx-equals-spacing': require('./lib/rules/jsx-equals-spacing'),
-    'jsx-sort-props': require('./lib/rules/jsx-sort-props'),
-    'sort-prop-types': require('./lib/rules/sort-prop-types'),
-    'jsx-boolean-value': require('./lib/rules/jsx-boolean-value'),
-    'sort-comp': require('./lib/rules/sort-comp'),
-    'require-extension': require('./lib/rules/require-extension'),
-    'jsx-no-duplicate-props': require('./lib/rules/jsx-no-duplicate-props'),
-    'jsx-max-props-per-line': require('./lib/rules/jsx-max-props-per-line'),
-    'jsx-no-literals': require('./lib/rules/jsx-no-literals'),
-    'jsx-indent-props': require('./lib/rules/jsx-indent-props'),
-    'jsx-indent': require('./lib/rules/jsx-indent'),
-    'jsx-closing-bracket-location': require('./lib/rules/jsx-closing-bracket-location'),
-    'jsx-space-before-closing': require('./lib/rules/jsx-space-before-closing'),
-    'no-direct-mutation-state': require('./lib/rules/no-direct-mutation-state'),
-    'forbid-prop-types': require('./lib/rules/forbid-prop-types'),
-    'prefer-es6-class': require('./lib/rules/prefer-es6-class'),
-    'jsx-key': require('./lib/rules/jsx-key'),
-    'no-string-refs': require('./lib/rules/no-string-refs'),
-    'prefer-stateless-function': require('./lib/rules/prefer-stateless-function'),
-    'require-render-return': require('./lib/rules/require-render-return'),
-    'jsx-first-prop-new-line': require('./lib/rules/jsx-first-prop-new-line'),
-    'jsx-no-target-blank': require('./lib/rules/jsx-no-target-blank'),
-    'jsx-filename-extension': require('./lib/rules/jsx-filename-extension'),
-    'require-optimization': require('./lib/rules/require-optimization'),
-    'no-find-dom-node': require('./lib/rules/no-find-dom-node')
-  },
+  rules: rules,
   configs: {
     recommended: {
       parserOptions: {
@@ -75,6 +83,14 @@ module.exports = {
         'react/prop-types': 2,
         'react/react-in-jsx-scope': 2
       }
+    },
+    all: {
+      parserOptions: {
+        ecmaFeatures: {
+          jsx: true
+        }
+      },
+      rules: allRules
     }
   }
 };


Test patch:
diff --git a/tests/index.js b/tests/index.js
index 100c0ee6..13c2e6b5 100644
--- a/tests/index.js
+++ b/tests/index.js
@@ -26,5 +26,20 @@ describe('all rule files should be exported by the plugin', function() {
 describe('configurations', function() {
   it('should export a \'recommended\' configuration', function() {
     assert(plugin.configs.recommended);
+    Object.keys(plugin.configs.recommended.rules).forEach(function (configName) {
+      assert.equal(configName.indexOf('react/'), 0);
+      var ruleName = configName.substring('react/'.length);
+      assert(plugin.rules[ruleName]);
+    });
+  });
+  it('should export a \'all\' configuration', function() {
+    assert(plugin.configs.all);
+    Object.keys(plugin.configs.all.rules).forEach(function(configName) {
+      assert.equal(configName.indexOf('react/'), 0);
+      assert.equal(plugin.configs.all.rules[configName], 2);
+    });
+    rules.forEach(function(ruleName) {
+      assert(plugin.configs.all.rules['react/' + ruleName]);
+    });
   });
 });