Repository: ember-cli/eslint-plugin-ember
Pull request #746 (2020-03-29 16:33:59)

Remove non-recommended rules from cluttering `recommended-rules.js`
It's not necessary to list non-recommended rules in the `recommended-rules.js` file. It only clutters the file for those trying to use it as a reference for the complete list of recommended rules.


Patch:
diff --git a/lib/recommended-rules.js b/lib/recommended-rules.js
index e704d4be..8cebc5d8 100644
--- a/lib/recommended-rules.js
+++ b/lib/recommended-rules.js
@@ -5,26 +5,15 @@
  * definitions, execute "npm run update"
  */
 module.exports = {
-  "ember/alias-model-in-controller": "off",
   "ember/avoid-leaking-state-in-ember-objects": "error",
   "ember/avoid-using-needs-in-controllers": "error",
-  "ember/classic-decorator-hooks": "off",
-  "ember/classic-decorator-no-classic-methods": "off",
   "ember/closure-actions": "error",
-  "ember/computed-property-getters": "off",
   "ember/jquery-ember-run": "error",
-  "ember/named-functions-in-promises": "off",
   "ember/new-module-imports": "error",
-  "ember/no-actions-hash": "off",
   "ember/no-arrow-function-computed-properties": "error",
   "ember/no-attrs-in-components": "error",
   "ember/no-attrs-snapshot": "error",
   "ember/no-capital-letters-in-routes": "error",
-  "ember/no-classic-classes": "off",
-  "ember/no-classic-components": "off",
-  "ember/no-component-lifecycle-hooks": "off",
-  "ember/no-computed-properties-in-native-classes": "off",
-  "ember/no-controllers": "off",
   "ember/no-deeply-nested-dependent-keys-with-each": "error",
   "ember/no-duplicate-dependent-keys": "error",
   "ember/no-ember-super-in-es-classes": "error",
@@ -38,7 +27,6 @@ module.exports = {
   "ember/no-incorrect-computed-macros": "error",
   "ember/no-invalid-debug-function-arguments": "error",
   "ember/no-invalid-dependent-keys": "error",
-  "ember/no-invalid-test-waiters": "off",
   "ember/no-jquery": "error",
   "ember/no-legacy-test-waiters": "error",
   "ember/no-mixins": "error",
@@ -48,29 +36,18 @@ module.exports = {
   "ember/no-on-calls-in-components": "error",
   "ember/no-pause-test": "error",
   "ember/no-private-routing-service": "error",
-  "ember/no-proxies": "off",
-  "ember/no-replace-test-comments": "off",
   "ember/no-restricted-resolver-tests": "error",
   "ember/no-side-effects": "error",
   "ember/no-test-and-then": "error",
   "ember/no-test-import-export": "error",
   "ember/no-test-module-for": "error",
-  "ember/no-unnecessary-index-route": "off",
   "ember/no-unnecessary-route-path-option": "error",
-  "ember/no-unnecessary-service-injection-argument": "off",
   "ember/no-volatile-computed-properties": "error",
-  "ember/order-in-components": "off",
-  "ember/order-in-controllers": "off",
-  "ember/order-in-models": "off",
-  "ember/order-in-routes": "off",
   "ember/require-computed-macros": "error",
   "ember/require-computed-property-dependencies": "error",
   "ember/require-return-from-computed": "error",
   "ember/require-super-in-init": "error",
-  "ember/require-tagless-components": "off",
-  "ember/route-path-style": "off",
   "ember/routes-segments-snake-case": "error",
   "ember/use-brace-expansion": "error",
-  "ember/use-ember-data-rfc-395-imports": "error",
-  "ember/use-ember-get-and-set": "off"
+  "ember/use-ember-data-rfc-395-imports": "error"
 }
\ No newline at end of file
diff --git a/scripts/update-rules.js b/scripts/update-rules.js
index c92ffff1..b0903f5d 100644
--- a/scripts/update-rules.js
+++ b/scripts/update-rules.js
@@ -96,8 +96,9 @@ ${deprecatedRules
 const recommendedRules = rules.reduce((obj, entry) => {
   const name = `ember/${entry[0]}`;
   const recommended = entry[1].meta.docs.recommended;
-  const status = recommended ? 'error' : 'off';
-  obj[name] = status; // eslint-disable-line no-param-reassign
+  if (recommended) {
+    obj[name] = 'error'; // eslint-disable-line no-param-reassign
+  }
   return obj;
 }, {});
 


Test patch:
diff --git a/tests/rule-setup.js b/tests/rule-setup.js
index c4073df5..501cbcb6 100644
--- a/tests/rule-setup.js
+++ b/tests/rule-setup.js
@@ -7,7 +7,10 @@ const recommendedRules = require('../lib/recommended-rules.js');
 const octaneRules = require('../lib/octane-rules.js');
 
 const RULE_NAMES = Object.keys(rules);
-const OCTANE_RULE_NAMES = Object.keys(octaneRules);
+const RECOMMENDED_RULE_NAMES = Object.keys(recommendedRules).map((name) =>
+  name.replace('ember/', '')
+);
+const OCTANE_RULE_NAMES = Object.keys(octaneRules).map((name) => name.replace('ember/', ''));
 
 describe('rules setup is correct', function () {
   it('should have a list of exported rules and rules directory that match', function () {
@@ -20,17 +23,16 @@ describe('rules setup is correct', function () {
     );
   });
 
-  it('should list all rules in the recommended rules file', function () {
-    expect(RULE_NAMES).toStrictEqual(
-      Object.keys(recommendedRules).map((file) => file.replace('ember/', ''))
+  it('should list all recommended rules in the recommended rules file', function () {
+    const recommendedRuleNamesFromMeta = RULE_NAMES.filter(
+      (key) => rules[key].meta.docs.recommended
     );
+    expect(RECOMMENDED_RULE_NAMES).toStrictEqual(recommendedRuleNamesFromMeta);
   });
 
-  it('should list all rules in the octane rules file', function () {
-    const octaneRuleNames = Object.keys(rules).filter((key) => rules[key].meta.docs.octane);
-    expect(OCTANE_RULE_NAMES.map((file) => file.replace('ember/', ''))).toStrictEqual(
-      octaneRuleNames
-    );
+  it('should list all octane rules in the octane rules file', function () {
+    const octaneRuleNamesFromMeta = RULE_NAMES.filter((key) => rules[key].meta.docs.octane);
+    expect(OCTANE_RULE_NAMES).toStrictEqual(octaneRuleNamesFromMeta);
   });
 
   it('should have tests for all rules', function () {