From f235772994a6306c2a97dcc8800878a707cecef3 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Sat, 26 Jun 2021 12:03:50 -0400 Subject: [PATCH] Breaking: Enable additional `recommended` rules for v4 --- README.md | 12 ++++++------ docs/rules/consistent-output.md | 2 ++ docs/rules/no-deprecated-context-methods.md | 2 ++ docs/rules/no-only-tests.md | 2 ++ docs/rules/prefer-object-rule.md | 2 ++ docs/rules/require-meta-has-suggestions.md | 2 ++ docs/rules/require-meta-schema.md | 2 ++ docs/rules/require-meta-type.md | 2 ++ lib/rules/consistent-output.js | 2 +- lib/rules/no-deprecated-context-methods.js | 2 +- lib/rules/no-only-tests.js | 2 +- lib/rules/prefer-object-rule.js | 2 +- lib/rules/require-meta-docs-description.js | 2 +- lib/rules/require-meta-has-suggestions.js | 2 +- lib/rules/require-meta-schema.js | 2 +- lib/rules/require-meta-type.js | 2 +- 16 files changed, 28 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a78fc8c2..ca8befc4 100644 --- a/README.md +++ b/README.md @@ -47,17 +47,17 @@ Then configure the rules you want to use under the rules section. Name | ✔️ | 🛠 | 💡 | Description ----- | ----- | ----- | ----- | ----- -[consistent-output](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/consistent-output.md) | | | | enforce consistent use of `output` assertions in rule tests +[consistent-output](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/consistent-output.md) | ✔️ | | | enforce consistent use of `output` assertions in rule tests [fixer-return](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/fixer-return.md) | ✔️ | | | require fixer functions to return a fix [meta-property-ordering](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/meta-property-ordering.md) | | 🛠 | | enforce the order of meta properties -[no-deprecated-context-methods](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-deprecated-context-methods.md) | | 🛠 | | disallow usage of deprecated methods on rule context objects +[no-deprecated-context-methods](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-deprecated-context-methods.md) | ✔️ | 🛠 | | disallow usage of deprecated methods on rule context objects [no-deprecated-report-api](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-deprecated-report-api.md) | ✔️ | 🛠 | | disallow the version of `context.report()` with multiple arguments [no-identical-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-identical-tests.md) | ✔️ | 🛠 | | disallow identical tests [no-missing-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-placeholders.md) | ✔️ | | | disallow missing placeholders in rule report messages -[no-only-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-only-tests.md) | | | 💡 | disallow the test case property `only` +[no-only-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-only-tests.md) | ✔️ | | 💡 | disallow the test case property `only` [no-unused-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-unused-placeholders.md) | ✔️ | | | disallow unused placeholders in rule report messages [no-useless-token-range](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-useless-token-range.md) | ✔️ | 🛠 | | disallow unnecessary calls to `sourceCode.getFirstToken()` and `sourceCode.getLastToken()` -[prefer-object-rule](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-object-rule.md) | | 🛠 | | disallow rule exports where the export is a function +[prefer-object-rule](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-object-rule.md) | ✔️ | 🛠 | | disallow rule exports where the export is a function [prefer-output-null](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-output-null.md) | | 🛠 | | disallow invalid RuleTester test cases where the `output` matches the `code` [prefer-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-placeholders.md) | | | | require using placeholders for dynamic report messages [prefer-replace-text](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-replace-text.md) | | | | require using `replaceText()` instead of `replaceTextRange()` @@ -65,9 +65,9 @@ Name | ✔️ | 🛠 | 💡 | Description [require-meta-docs-description](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-docs-description.md) | | | | require rules to implement a `meta.docs.description` property with the correct format [require-meta-docs-url](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-docs-url.md) | | 🛠 | | require rules to implement a `meta.docs.url` property [require-meta-fixable](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-fixable.md) | ✔️ | | | require rules to implement a `meta.fixable` property -[require-meta-has-suggestions](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-has-suggestions.md) | | 🛠 | | require suggestable rules to implement a `meta.hasSuggestions` property +[require-meta-has-suggestions](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-has-suggestions.md) | ✔️ | 🛠 | | require suggestable rules to implement a `meta.hasSuggestions` property [require-meta-schema](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-schema.md) | | 🛠 | | require rules to implement a `meta.schema` property -[require-meta-type](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-type.md) | | | | require rules to implement a `meta.type` property +[require-meta-type](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-type.md) | ✔️ | | | require rules to implement a `meta.type` property [test-case-property-ordering](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/test-case-property-ordering.md) | | 🛠 | | require the properties of a test case to be placed in a consistent order [test-case-shorthand-strings](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/test-case-shorthand-strings.md) | | 🛠 | | enforce consistent usage of shorthand strings for test cases with no options diff --git a/docs/rules/consistent-output.md b/docs/rules/consistent-output.md index 72db0bcc..9e110a06 100644 --- a/docs/rules/consistent-output.md +++ b/docs/rules/consistent-output.md @@ -1,5 +1,7 @@ # Enforce consistent use of `output` assertions in rule tests (consistent-output) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + When writing tests for a fixable rule with `RuleTester`, you can assert the autofix output of your test cases. However, it can be easy to forget to assert the output of a particular test case. [As of ESLint 7](https://eslint.org/docs/user-guide/migrating-to-7.0.0#additional-validation-added-to-the-ruletester-class), test cases that trigger an autofix are required to provide the `output` property. diff --git a/docs/rules/no-deprecated-context-methods.md b/docs/rules/no-deprecated-context-methods.md index 75bdfcba..4ac017f7 100644 --- a/docs/rules/no-deprecated-context-methods.md +++ b/docs/rules/no-deprecated-context-methods.md @@ -1,5 +1,7 @@ # Disallow usage of deprecated methods on rule context objects (no-deprecated-context-methods) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + ⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule. This rule disallows the use of deprecated methods on rule `context` objects. diff --git a/docs/rules/no-only-tests.md b/docs/rules/no-only-tests.md index 0da555e6..8f950f78 100644 --- a/docs/rules/no-only-tests.md +++ b/docs/rules/no-only-tests.md @@ -1,5 +1,7 @@ # Disallow the test case property `only` (no-only-tests) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + 💡 Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). The [`only` property](https://eslint.org/docs/developer-guide/unit-tests#running-individual-tests) can be used as of [ESLint 7.29](https://eslint.org/blog/2021/06/eslint-v7.29.0-released#highlights) for running individual rule test cases with less-noisy debugging. This feature should be only used in development, as it prevents all the tests from running. Mistakenly checking-in a test case with this property can cause CI tests to incorrectly pass. diff --git a/docs/rules/prefer-object-rule.md b/docs/rules/prefer-object-rule.md index 095835ac..11b3460d 100644 --- a/docs/rules/prefer-object-rule.md +++ b/docs/rules/prefer-object-rule.md @@ -1,5 +1,7 @@ # Disallow rule exports where the export is a function (prefer-object-rule) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + ⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule. ## Rule Details diff --git a/docs/rules/require-meta-has-suggestions.md b/docs/rules/require-meta-has-suggestions.md index 6d08487d..e5e2822f 100644 --- a/docs/rules/require-meta-has-suggestions.md +++ b/docs/rules/require-meta-has-suggestions.md @@ -1,5 +1,7 @@ # Require suggestable rules to implement a `meta.hasSuggestions` property (require-meta-has-suggestions) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + ⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule. A suggestable ESLint rule should specify the `meta.hasSuggestions` property with a value of `true`. This makes it easier for both humans and tooling to tell whether a rule provides suggestions. [As of ESLint 8](https://eslint.org/blog/2021/06/whats-coming-in-eslint-8.0.0#rules-with-suggestions-now-require-the-metahassuggestions-property), an exception will be thrown if a suggestable rule is missing this property. diff --git a/docs/rules/require-meta-schema.md b/docs/rules/require-meta-schema.md index af5f773c..8cadbe15 100644 --- a/docs/rules/require-meta-schema.md +++ b/docs/rules/require-meta-schema.md @@ -1,5 +1,7 @@ # Require rules to implement a `meta.schema` property (require-meta-schema) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + ⚒️ The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#--fix) can automatically fix some of the problems reported by this rule. Defining a schema for each rule allows eslint to validate that configuration options are passed correctly. Even when there are no options for a rule, a schema should still be defined (as an empty array) so that eslint can validate that no data is mistakenly passed to the rule. diff --git a/docs/rules/require-meta-type.md b/docs/rules/require-meta-type.md index b3a33484..6bc6164f 100644 --- a/docs/rules/require-meta-type.md +++ b/docs/rules/require-meta-type.md @@ -1,5 +1,7 @@ # Require rules to implement a `meta.type` property (require-meta-type) +✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule. + ESLint v5.9.0 introduces a new `--fix-type` option for the command line interface. This option allows users to filter the type of fixes applied when using `--fix`. Fixes in custom rules will not be applied when using `--fix-type` unless they include a `meta.type` field. diff --git a/lib/rules/consistent-output.js b/lib/rules/consistent-output.js index aee28ad8..f9f36d8c 100644 --- a/lib/rules/consistent-output.js +++ b/lib/rules/consistent-output.js @@ -17,7 +17,7 @@ module.exports = { docs: { description: 'enforce consistent use of `output` assertions in rule tests', category: 'Tests', - recommended: false, + recommended: true, }, fixable: null, // or "code" or "whitespace" schema: [ diff --git a/lib/rules/no-deprecated-context-methods.js b/lib/rules/no-deprecated-context-methods.js index 1ceeca61..e71844f8 100644 --- a/lib/rules/no-deprecated-context-methods.js +++ b/lib/rules/no-deprecated-context-methods.js @@ -40,7 +40,7 @@ module.exports = { docs: { description: 'disallow usage of deprecated methods on rule context objects', category: 'Rules', - recommended: false, + recommended: true, }, fixable: 'code', schema: [], diff --git a/lib/rules/no-only-tests.js b/lib/rules/no-only-tests.js index 78f0c6d6..71fd71b0 100644 --- a/lib/rules/no-only-tests.js +++ b/lib/rules/no-only-tests.js @@ -9,7 +9,7 @@ module.exports = { docs: { description: 'disallow the test case property `only`', category: 'Tests', - recommended: false, + recommended: true, }, schema: [], messages: { diff --git a/lib/rules/prefer-object-rule.js b/lib/rules/prefer-object-rule.js index 72b9920e..9a6c9f25 100644 --- a/lib/rules/prefer-object-rule.js +++ b/lib/rules/prefer-object-rule.js @@ -16,7 +16,7 @@ module.exports = { docs: { description: 'disallow rule exports where the export is a function', category: 'Rules', - recommended: false, + recommended: true, }, fixable: 'code', schema: [], diff --git a/lib/rules/require-meta-docs-description.js b/lib/rules/require-meta-docs-description.js index 31a148f8..808b3627 100644 --- a/lib/rules/require-meta-docs-description.js +++ b/lib/rules/require-meta-docs-description.js @@ -15,7 +15,7 @@ module.exports = { docs: { description: 'require rules to implement a `meta.docs.description` property with the correct format', category: 'Rules', - recommended: false, // TODO: enable it in a major release. + recommended: false, }, fixable: null, schema: [ diff --git a/lib/rules/require-meta-has-suggestions.js b/lib/rules/require-meta-has-suggestions.js index 563d658e..33462991 100644 --- a/lib/rules/require-meta-has-suggestions.js +++ b/lib/rules/require-meta-has-suggestions.js @@ -13,7 +13,7 @@ module.exports = { docs: { description: 'require suggestable rules to implement a `meta.hasSuggestions` property', category: 'Rules', - recommended: false, + recommended: true, }, fixable: 'code', schema: [], diff --git a/lib/rules/require-meta-schema.js b/lib/rules/require-meta-schema.js index f5174a1a..ddcb65df 100644 --- a/lib/rules/require-meta-schema.js +++ b/lib/rules/require-meta-schema.js @@ -13,7 +13,7 @@ module.exports = { docs: { description: 'require rules to implement a `meta.schema` property', category: 'Rules', - recommended: false, // TODO: enable it in a major release. + recommended: true, }, fixable: 'code', schema: [ diff --git a/lib/rules/require-meta-type.js b/lib/rules/require-meta-type.js index 330d3e94..fb7f33e9 100644 --- a/lib/rules/require-meta-type.js +++ b/lib/rules/require-meta-type.js @@ -19,7 +19,7 @@ module.exports = { docs: { description: 'require rules to implement a `meta.type` property', category: 'Rules', - recommended: false, // TODO: enable it in a major release. + recommended: true, }, fixable: null, schema: [],