Repository: ember-cli/eslint-plugin-ember
Pull request #554 (2019-10-25 06:54:37)

Add rule documentation template
Makes it easier to write better documentation for new rules.

Based on: https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/_TEMPLATE_.md


Patch:
diff --git a/README.md b/README.md
index dea63870..c16eda0a 100644
--- a/README.md
+++ b/README.md
@@ -142,7 +142,6 @@ The `--fix` option on the command line automatically fixes problems reported by
 
 |    | Rule ID | Description |
 |:---|:--------|:------------|
-|  | [no-classic-components](./docs/rules/no-classic-components.md) | Enforces Glimmer components |
 |  | [no-computed-properties-in-native-classes](./docs/rules/no-computed-properties-in-native-classes.md) | Disallows using computed properties in native classes |
 
 
diff --git a/docs/rules/_TEMPLATE_.md b/docs/rules/_TEMPLATE_.md
new file mode 100644
index 00000000..f583d70f
--- /dev/null
+++ b/docs/rules/_TEMPLATE_.md
@@ -0,0 +1,55 @@
+# (rule name goes here)
+
+(context about the problem goes here)
+
+## Rule Details
+
+(what the rule does goes here)
+
+## Examples
+
+This rule **forbids** the following:
+
+```js
+// Example 1
+```
+
+```js
+// Example 2
+```
+
+This rule **allows** the following:
+
+```js
+// Example 1
+```
+
+```js
+// Example 2
+```
+
+## Migration
+
+(suggest any fast/automated techniques for fixing violations in a large codebase)
+
+* suggestion on how to fix violations using find-and-replace / regexp
+* suggestion on how to fix violations using a codemod
+
+## Configuration
+
+(exclude this section if the rule has no extra configuration)
+
+* object -- containing the following properties:
+  * string -- `parameterName1` -- description of parameter including the possible values and default value
+  * boolean -- `parameterName2` -- description of parameter including the possible values and default value
+
+## Related Rules
+
+* [related-rule-name1](related-rule-name1.md)
+* [related-rule-name2](related-rule-name2.md)
+
+## References
+
+* (link to relevant documentation goes here)
+* (link to relevant function spec goes here)
+* (link to relevant guide goes here)
diff --git a/docs/rules/no-classic-components.md b/docs/rules/no-classic-components.md
deleted file mode 100644
index 43a07831..00000000
--- a/docs/rules/no-classic-components.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# No classic components (no-classic-components)
-
-This rule aims to enforce Glimmer components instead of classic ones. We should migrate to Glimmer components because
-they have few adventages:
-- Simpler API
-- No wrapper element
-- Namespaced Arguments
-- Less lifecycle hooks
-- Stateless Template-Only Components
-- Unidirectional Dataflow
-
-With that simpler API we could improve the DX and also lower the entry level for Ember.
-
-## Rule Details
-
-If you want to migrate to Glimmer components this rule can help find the classic components that you need to migrate.
-
-Examples of **incorrect** code for this rule:
-
-```js
-
-import Component from '@ember/component';
-
-```
-
-Examples of **correct** code for this rule:
-
-```js
-
-import Component from '@glimmer/component';
-
-```
-
-## References
-
-* [Ember 3.13 Release Notes](https://blog.emberjs.com/2019/09/25/ember-3-13-released.html)
-* [Ember Glimmer Components RFC](https://github.com/emberjs/rfcs/blob/master/text/0416-glimmer-components.md)
-* [Ember Octane Release Plan](https://blog.emberjs.com/2019/08/15/octane-release-plan.html)
-* [Glimmer Components Explained](https://www.pzuraq.com/coming-soon-in-ember-octane-part-5-glimmer-components/)
diff --git a/lib/index.js b/lib/index.js
index c2047aca..1f90b5ea 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -16,7 +16,6 @@ module.exports = {
     'no-attrs-in-components': require('./rules/no-attrs-in-components'),
     'no-attrs-snapshot': require('./rules/no-attrs-snapshot'),
     'no-capital-letters-in-routes': require('./rules/no-capital-letters-in-routes'),
-    'no-classic-components': require('./rules/no-classic-components'),
     'no-computed-properties-in-native-classes': require('./rules/no-computed-properties-in-native-classes'),
     'no-deeply-nested-dependent-keys-with-each': require('./rules/no-deeply-nested-dependent-keys-with-each'),
     'no-duplicate-dependent-keys': require('./rules/no-duplicate-dependent-keys'),
diff --git a/lib/recommended-rules.js b/lib/recommended-rules.js
index 05868ea6..f261a08d 100644
--- a/lib/recommended-rules.js
+++ b/lib/recommended-rules.js
@@ -19,7 +19,6 @@ module.exports = {
   "ember/no-attrs-in-components": "error",
   "ember/no-attrs-snapshot": "error",
   "ember/no-capital-letters-in-routes": "error",
-  "ember/no-classic-components": "off",
   "ember/no-computed-properties-in-native-classes": "off",
   "ember/no-deeply-nested-dependent-keys-with-each": "error",
   "ember/no-duplicate-dependent-keys": "error",
diff --git a/lib/rules/no-classic-components.js b/lib/rules/no-classic-components.js
deleted file mode 100644
index f3db6fc5..00000000
--- a/lib/rules/no-classic-components.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-
-const ERROR_MESSAGE =
-  'Use Glimmer components(@glimmer/component) instead of classic components(@ember/component)';
-
-module.exports = {
-  meta: {
-    docs: {
-      description: 'Enforces Glimmer components',
-      category: 'Ember Octane',
-      recommended: false,
-      url:
-        'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-classic-components.md',
-    },
-    fixable: null,
-  },
-
-  ERROR_MESSAGE,
-
-  create(context) {
-    const report = function(node) {
-      context.report(node, ERROR_MESSAGE);
-    };
-
-    return {
-      ImportDeclaration(node) {
-        const importSource = node.source.value;
-
-        if (importSource === '@ember/component') {
-          report(node);
-        }
-      },
-    };
-  },
-};


Test patch:
diff --git a/tests/lib/rules/no-classic-components.js b/tests/lib/rules/no-classic-components.js
deleted file mode 100644
index 63179dd0..00000000
--- a/tests/lib/rules/no-classic-components.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-
-//------------------------------------------------------------------------------
-// Requirements
-//------------------------------------------------------------------------------
-
-const rule = require('../../../lib/rules/no-classic-components');
-const RuleTester = require('eslint').RuleTester;
-
-//------------------------------------------------------------------------------
-// Tests
-//------------------------------------------------------------------------------
-
-const { ERROR_MESSAGE } = rule;
-const parserOptions = {
-  ecmaVersion: 6,
-  sourceType: 'module',
-};
-const ruleTester = new RuleTester({ parserOptions });
-
-ruleTester.run('no-classic-components', rule, {
-  valid: ["import Component from '@glimmer/component';"],
-
-  invalid: [
-    {
-      code: "import Component from '@ember/component';",
-      errors: [
-        {
-          message: ERROR_MESSAGE,
-          type: 'ImportDeclaration',
-        },
-      ],
-    },
-  ],
-});
diff --git a/tests/rule-setup.js b/tests/rule-setup.js
index 345a98aa..677eed5e 100644
--- a/tests/rule-setup.js
+++ b/tests/rule-setup.js
@@ -45,7 +45,9 @@ describe('rules setup is correct', function() {
     // eslint-disable-next-line node/no-deprecated-api
     assert.deepEqual(
       RULE_NAMES,
-      files.filter(file => !file.startsWith('.')).map(file => file.replace('.md', ''))
+      files
+        .filter(file => !file.startsWith('.') && file !== '_TEMPLATE_.md')
+        .map(file => file.replace('.md', ''))
     );
   });