Skip to content

Commit

Permalink
breaking: add recommended rules prefer-message-ids, `prefer-outpu…
Browse files Browse the repository at this point in the history
…t-null`, `no-missing-message-ids`, `no-unused-message-ids` (#258)

* breaking: add `recommended` rules `prefer-message-ids`, `prefer-output-null`, `no-missing-message-ids`, `no-unused-message-ids`, remove `consistent-output`

* re-enable consistent-output as recommended
  • Loading branch information
bmish authored Jul 12, 2022
1 parent 8506ddd commit 8634d84
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ Name | ✔️ | 🛠 | 💡 | Description
[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 function-style rules
[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: 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/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 8634d84

Please sign in to comment.