Skip to content

Commit

Permalink
breaking: update recommended rules for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Jul 7, 2022
1 parent 951d208 commit 5675515
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ Here's an example ESLint configuration that:
<!-- __BEGIN AUTOGENERATED TABLE__ -->
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-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-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-message-ids.md) | | | | disallow `messageId`s that are missing from `meta.messages`
[no-missing-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-message-ids.md) | ✔️ | | | disallow `messageId`s that are missing from `meta.messages`
[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-unused-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-unused-message-ids.md) | | | | disallow unused `messageId`s in `meta.messages`
[no-unused-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-unused-message-ids.md) | ✔️ | | | disallow unused `messageId`s in `meta.messages`
[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-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-message-ids.md) | | | | require using `messageId` instead of `message` to report rule violations
[prefer-message-ids](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/prefer-message-ids.md) | ✔️ | | | require using `messageId` instead of `message` to report rule violations
[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-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()`
[report-message-format](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/report-message-format.md) | | | | enforce a consistent format for rule report messages
Expand Down
2 changes: 0 additions & 2 deletions docs/rules/consistent-output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# 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 fixable rules, it's a best practice to use the `output` property on each test case to assert what autofixed code is produced, or to assert that no autofix is produced using `output: null`.

Prior to ESLint 7, it was easy to forget to assert the autofix output of a particular test case, resulting in incomplete test coverage and a greater chance of unexpected behavior / bugs.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-missing-message-ids.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow `messageId`s that are missing from `meta.messages` (no-missing-message-ids)

✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.

When using `meta.messages` and `messageId` to report rule violations, it's possible to mistakenly use a `messageId` that doesn't exist in `meta.messages`.

## Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-unused-message-ids.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow unused `messageId`s in `meta.messages` (no-unused-message-ids)

✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.

When using `meta.messages` and `messageId` to report rule violations, it's possible to mistakenly leave a message in `meta.messages` that is never used.

## Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-message-ids.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Require using `messageId` instead of `message` to report rule violations (prefer-message-ids)

✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.

When reporting a rule violation, it's preferred to provide the violation message with the `messageId` property instead of the `message` property. Message IDs provide the following benefits:

* Rule violation messages can be stored in a central `meta.messages` object for convenient management
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/prefer-output-null.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Disallow invalid RuleTester test cases where the `output` matches the `code` (prefer-output-null)

✔️ 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.

Instead of repeating the test case `code`, using `output: null` is more concise and makes it easier to distinguish whether a test case provides an autofix.
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/consistent-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
description:
'enforce consistent use of `output` assertions in rule tests',
category: 'Tests',
recommended: true,
recommended: false,
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/consistent-output.md',
},
fixable: null, // or "code" or "whitespace"
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-missing-message-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
description:
'disallow `messageId`s that are missing from `meta.messages`',
category: 'Rules',
recommended: false,
recommended: true,
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-missing-message-ids.md',
},
fixable: null,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unused-message-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
docs: {
description: 'disallow unused `messageId`s in `meta.messages`',
category: 'Rules',
recommended: false,
recommended: true,
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-unused-message-ids.md',
},
fixable: null,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-message-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
description:
'require using `messageId` instead of `message` to report rule violations',
category: 'Rules',
recommended: false,
recommended: true,
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/prefer-message-ids.md',
},
fixable: null,
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-output-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
description:
'disallow invalid RuleTester test cases where the `output` matches the `code`',
category: 'Tests',
recommended: false,
recommended: true,
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/prefer-output-null.md',
},
fixable: 'code',
Expand Down

0 comments on commit 5675515

Please sign in to comment.