Skip to content

Commit 83fa414

Browse files
committed
breaking: add recommended rules prefer-message-ids, prefer-output-null, no-missing-message-ids, no-unused-message-ids, remove consistent-output
1 parent 951d208 commit 83fa414

11 files changed

+18
-12
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ Here's an example ESLint configuration that:
6161
<!-- __BEGIN AUTOGENERATED TABLE__ -->
6262
Name | ✔️ | 🛠 | 💡 | Description
6363
----- | ----- | ----- | ----- | -----
64-
[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
64+
[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
6565
[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
6666
[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
6767
[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
6868
[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
6969
[no-identical-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-identical-tests.md) | ✔️ | 🛠 | | disallow identical tests
70-
[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`
70+
[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`
7171
[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
7272
[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`
73-
[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`
73+
[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`
7474
[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
7575
[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()`
76-
[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
76+
[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
7777
[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
78-
[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`
78+
[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`
7979
[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
8080
[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()`
8181
[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

docs/rules/consistent-output.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Enforce consistent use of `output` assertions in rule tests (consistent-output)
22

3-
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
4-
53
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`.
64

75
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.

docs/rules/no-missing-message-ids.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow `messageId`s that are missing from `meta.messages` (no-missing-message-ids)
22

3+
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
4+
35
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`.
46

57
## Rule Details

docs/rules/no-unused-message-ids.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow unused `messageId`s in `meta.messages` (no-unused-message-ids)
22

3+
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
4+
35
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.
46

57
## Rule Details

docs/rules/prefer-message-ids.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Require using `messageId` instead of `message` to report rule violations (prefer-message-ids)
22

3+
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
4+
35
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:
46

57
* Rule violation messages can be stored in a central `meta.messages` object for convenient management

docs/rules/prefer-output-null.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Disallow invalid RuleTester test cases where the `output` matches the `code` (prefer-output-null)
22

3+
✔️ The `"extends": "plugin:eslint-plugin/recommended"` property in a configuration file enables this rule.
4+
35
⚒️ 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.
46

57
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.

lib/rules/consistent-output.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
description:
2020
'enforce consistent use of `output` assertions in rule tests',
2121
category: 'Tests',
22-
recommended: true,
22+
recommended: false,
2323
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/consistent-output.md',
2424
},
2525
fixable: null, // or "code" or "whitespace"

lib/rules/no-missing-message-ids.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
description:
1515
'disallow `messageId`s that are missing from `meta.messages`',
1616
category: 'Rules',
17-
recommended: false,
17+
recommended: true,
1818
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-missing-message-ids.md',
1919
},
2020
fixable: null,

lib/rules/no-unused-message-ids.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
docs: {
1414
description: 'disallow unused `messageId`s in `meta.messages`',
1515
category: 'Rules',
16-
recommended: false,
16+
recommended: true,
1717
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/no-unused-message-ids.md',
1818
},
1919
fixable: null,

lib/rules/prefer-message-ids.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
description:
1616
'require using `messageId` instead of `message` to report rule violations',
1717
category: 'Rules',
18-
recommended: false,
18+
recommended: true,
1919
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/prefer-message-ids.md',
2020
},
2121
fixable: null,

lib/rules/prefer-output-null.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
description:
2020
'disallow invalid RuleTester test cases where the `output` matches the `code`',
2121
category: 'Tests',
22-
recommended: false,
22+
recommended: true,
2323
url: 'https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/prefer-output-null.md',
2424
},
2525
fixable: 'code',

0 commit comments

Comments
 (0)