Repository: ember-cli/eslint-plugin-ember
Pull request #175 (2017-11-15 08:11:03)

Add deprecations to README
Partly extracted from #146 

/cc @michalsnik @rwjblue 


Patch:
diff --git a/README.md b/README.md
index 1e5ee1c0..9952eb77 100644
--- a/README.md
+++ b/README.md
@@ -91,6 +91,13 @@ The `--fix` option on the command line automatically fixes problems reported by
 | :white_check_mark: | [no-on-calls-in-components](./docs/rules/no-on-calls-in-components.md) | Prevents usage of `on` calls in components |
 
 
+### Ember Object
+
+|    | Rule ID | Description |
+|:---|:--------|:------------|
+|  | [avoid-leaking-state-in-ember-objects](./docs/rules/avoid-leaking-state-in-ember-objects.md) | Avoids state leakage |
+
+
 ### General
 
 |    | Rule ID | Description |
@@ -142,6 +149,15 @@ The `--fix` option on the command line automatically fixes problems reported by
 | :white_check_mark: | [order-in-models](./docs/rules/order-in-models.md) | Enforces proper order of properties in models |
 | :white_check_mark: | [order-in-routes](./docs/rules/order-in-routes.md) | Enforces proper order of properties in routes |
 
+### Deprecated
+
+> :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
+
+| Rule ID | Replaced by |
+|:--------|:------------|
+| [avoid-leaking-state-in-components](./docs/rules/avoid-leaking-state-in-components.md) | [avoid-leaking-state-in-ember-objects](./docs/rules/avoid-leaking-state-in-ember-objects.md) |
+| [local-modules](./docs/rules/local-modules.md) | [new-module-imports](./docs/rules/new-module-imports.md) |
+
 <!--RULES_TABLE_END-->
 
 For the simplified list of rules, [go here](./lib/recommended-rules.js).
diff --git a/lib/recommended-rules.js b/lib/recommended-rules.js
index 7ea5084c..1c203297 100644
--- a/lib/recommended-rules.js
+++ b/lib/recommended-rules.js
@@ -7,6 +7,7 @@
 module.exports = {
   "ember/alias-model-in-controller": "error",
   "ember/avoid-leaking-state-in-components": "error",
+  "ember/avoid-leaking-state-in-ember-objects": "off",
   "ember/closure-actions": "error",
   "ember/jquery-ember-run": "error",
   "ember/local-modules": "off",
diff --git a/lib/rules/avoid-leaking-state-in-components.js b/lib/rules/avoid-leaking-state-in-components.js
index 662b92cb..e49ea7f3 100644
--- a/lib/rules/avoid-leaking-state-in-components.js
+++ b/lib/rules/avoid-leaking-state-in-components.js
@@ -12,9 +12,11 @@ module.exports = {
     docs: {
       description: 'Avoids state leakage',
       category: 'Components',
-      recommended: true
+      recommended: true,
+      replacedBy: ['avoid-leaking-state-in-ember-objects'],
     },
     fixable: null, // or "code" or "whitespace"
+    deprecated: true,
     schema: [{
       type: 'array',
       items: { type: 'string' },
diff --git a/lib/rules/avoid-leaking-state-in-ember-objects.js b/lib/rules/avoid-leaking-state-in-ember-objects.js
index 13c0be38..1ab5f3d9 100644
--- a/lib/rules/avoid-leaking-state-in-ember-objects.js
+++ b/lib/rules/avoid-leaking-state-in-ember-objects.js
@@ -37,7 +37,7 @@ module.exports = {
     docs: {
       description: 'Avoids state leakage',
       category: 'Ember Object',
-      recommended: true
+      recommended: false
     },
     fixable: null, // or "code" or "whitespace"
     schema: [{
diff --git a/lib/rules/local-modules.js b/lib/rules/local-modules.js
index 0f2680dc..8cf8c5eb 100644
--- a/lib/rules/local-modules.js
+++ b/lib/rules/local-modules.js
@@ -11,7 +11,8 @@ module.exports = {
     docs: {
       description: 'Enforces usage of local modules',
       category: 'General',
-      recommended: false
+      recommended: false,
+      replacedBy: ['new-module-imports'],
     },
     deprecated: true,
     fixable: null, // or "code" or "whitespace"
diff --git a/scripts/update-rules.js b/scripts/update-rules.js
index dfaa32cd..ae39f3c1 100644
--- a/scripts/update-rules.js
+++ b/scripts/update-rules.js
@@ -45,7 +45,7 @@ const categories = rules
     return arr;
   }, []);
 
-const rulesTableContent = categories.map(category => `
+let rulesTableContent = categories.map(category => `
 ### ${category}
 
 |    | Rule ID | Description |
@@ -65,6 +65,27 @@ ${
 }
 `).join('\n');
 
+rulesTableContent += `
+### Deprecated
+
+> :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
+
+| Rule ID | Replaced by |
+|:--------|:------------|
+${
+  rules
+    .filter(entry => entry[1].meta.deprecated)
+    .map((entry) => {
+      const name = entry[0];
+      const meta = entry[1].meta;
+      const link = `[${name}](./docs/rules/${name}.md)`;
+      const replacedBy = (meta.docs.replacedBy || []).map(id => `[${id}](./docs/rules/${id}.md)`).join(', ') || '(no replacement)';
+      return `| ${link} | ${replacedBy} |`;
+    })
+    .join('\n')
+}
+`;
+
 const recommendedRules = rules.reduce((obj, entry) => {
   const name = `ember/${entry[0]}`;
   const recommended = entry[1].meta.docs.recommended;


Test patch:
diff --git a/tests/__snapshots__/recommended.js.snap b/tests/__snapshots__/recommended.js.snap
index 287e4fe1..051cf650 100644
--- a/tests/__snapshots__/recommended.js.snap
+++ b/tests/__snapshots__/recommended.js.snap
@@ -4,7 +4,6 @@ exports[`recommended rules 1`] = `
 Array [
   "alias-model-in-controller",
   "avoid-leaking-state-in-components",
-  "avoid-leaking-state-in-ember-objects",
   "closure-actions",
   "jquery-ember-run",
   "named-functions-in-promises",