Skip to content

Commit b1ec983

Browse files
committed
Merge branch 'main' into no-meta-schema-default
2 parents 137a3e9 + 334aec3 commit b1ec983

29 files changed

+238
-74
lines changed

.github/workflows/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@ jobs:
5656
with:
5757
node-version: "lts/*"
5858
- run: npm install
59-
- run: npm install --save-dev eslint@8 # eslint-remote-tester does not support eslint v9.
6059
- run: npm run test:remote

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module.exports = [
9999
| [prefer-replace-text](docs/rules/prefer-replace-text.md) | require using `replaceText()` instead of `replaceTextRange()` | | | | |
100100
| [report-message-format](docs/rules/report-message-format.md) | enforce a consistent format for rule report messages | | | | |
101101
| [require-meta-docs-description](docs/rules/require-meta-docs-description.md) | require rules to implement a `meta.docs.description` property with the correct format | | | | |
102-
| [require-meta-docs-recommended](docs/rules/require-meta-docs-recommended.md) | require rules to implement a `meta.docs.recommended` property | | | | |
102+
| [require-meta-docs-recommended](docs/rules/require-meta-docs-recommended.md) | require rules to implement a `meta.docs.recommended` property | | | 💡 | |
103103
| [require-meta-docs-url](docs/rules/require-meta-docs-url.md) | require rules to implement a `meta.docs.url` property | | 🔧 | | |
104104
| [require-meta-fixable](docs/rules/require-meta-fixable.md) | require rules to implement a `meta.fixable` property || | | |
105105
| [require-meta-has-suggestions](docs/rules/require-meta-has-suggestions.md) | require suggestable rules to implement a `meta.hasSuggestions` property || 🔧 | | |

docs/rules/consistent-output.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ As mentioned in the introduction, the need for this rule is reduced as of ESLint
7575

7676
## Further Reading
7777

78-
- [`RuleTester` documentation](http://eslint.org/docs/developer-guide/working-with-plugins#testing)
78+
- [ESLint plugin docs: Testing a Plugin](https://eslint.org/docs/latest/extend/plugins#testing-a-plugin)

docs/rules/fixer-return.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- end auto-generated rule header -->
66

7-
In a [fixable](https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes) rule, a fixer function is useless if it never returns anything.
7+
In a [fixable](https://eslint.org/docs/latest/extend/custom-rules#applying-fixes) rule, a fixer function is useless if it never returns anything.
88

99
## Rule Details
1010

docs/rules/no-deprecated-context-methods.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The deprecated methods are:
3131
- `getTokensBefore`
3232
- `getTokensBetween`
3333

34-
Instead of using these methods, you should use the equivalent methods on [`SourceCode`](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode), e.g. `context.getSourceCode().getText()` instead of `context.getSource()`.
34+
Instead of using these methods, you should use the equivalent methods on [`SourceCode`](https://eslint.org/docs/latest/extend/custom-rules#accessing-the-source-code), e.g. `context.sourceCode.getText()` instead of `context.getSource()`.
3535

3636
## Rule Details
3737

@@ -71,4 +71,4 @@ If you need to support very old versions of ESLint where `SourceCode` doesn't ex
7171

7272
## Further Reading
7373

74-
- [`SourceCode` API](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode)
74+
- [ESLint rule docs: Accessing the Source Code](https://eslint.org/docs/latest/extend/custom-rules#accessing-the-source-code)

docs/rules/no-deprecated-report-api.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
ESLint has two APIs that rules can use to report problems.
1010

11-
- The [deprecated API](http://eslint.org/docs/developer-guide/working-with-rules-deprecated) accepts multiple arguments: `context.report(node, [loc], message)`.
12-
- The ["new API"](http://eslint.org/docs/developer-guide/working-with-rules#contextreport) accepts a single argument: an object containing information about the reported problem.
11+
- The [deprecated API](https://eslint.org/docs/latest/extend/custom-rules-deprecated) accepts multiple arguments: `context.report(node, [loc], message)`.
12+
- The ["new API"](https://eslint.org/docs/latest/extend/custom-rules#reporting-problems) accepts a single argument: an object containing information about the reported problem.
1313

1414
It is recommended that all rules use the new API.
1515

@@ -41,5 +41,4 @@ module.exports = {
4141

4242
## Further Reading
4343

44-
- [Deprecated rule API](http://eslint.org/docs/developer-guide/working-with-rules-deprecated)
45-
- [New rule API](http://eslint.org/docs/developer-guide/working-with-rules)
44+
- [ESLint rule docs: Reporting Problems](https://eslint.org/docs/latest/extend/custom-rules#reporting-problems)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ module.exports = {
5858

5959
## Further Reading
6060

61-
- [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
61+
- [ESLint rule docs: `messageId`s](https://eslint.org/docs/latest/extend/custom-rules#messageids)
6262
- [no-unused-message-ids](./no-unused-message-ids.md) rule
6363
- [prefer-message-ids](./prefer-message-ids.md) rule

docs/rules/no-missing-placeholders.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ If you want to use rule messages that actually contain double-curly bracket text
7474

7575
## Further Reading
7676

77-
- [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
77+
- [ESLint rule docs: Using Message Placeholders](https://eslint.org/docs/latest/extend/custom-rules#using-message-placeholders)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ module.exports = {
5959

6060
## Further Reading
6161

62-
- [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
62+
- [ESLint rule docs: `messageId`s](https://eslint.org/docs/latest/extend/custom-rules#messageids)
6363
- [no-missing-message-ids](./no-missing-message-ids.md) rule
6464
- [prefer-message-ids](./prefer-message-ids.md) rule

docs/rules/no-unused-placeholders.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ If you want to allow unused placeholders, you should turn off this rule.
5757

5858
## Further Reading
5959

60-
- [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
60+
- [ESLint rule docs: Using Message Placeholders](https://eslint.org/docs/latest/extend/custom-rules#using-message-placeholders)
6161
- [no-missing-placeholders](https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-placeholders.md)

docs/rules/no-useless-token-range.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ module.exports = {
4848

4949
## Further Reading
5050

51-
- [`SourceCode` API](https://eslint.org/docs/developer-guide/working-with-rules#contextgetsourcecode)
51+
- [ESLint rule docs: Accessing the Source Code](https://eslint.org/docs/latest/extend/custom-rules#accessing-the-source-code)

docs/rules/prefer-message-ids.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ module.exports = {
5959

6060
## Further Reading
6161

62-
- [messageIds API](https://eslint.org/docs/developer-guide/working-with-rules#messageids)
62+
- [ESLint rule docs: `messageId`s](https://eslint.org/docs/latest/extend/custom-rules#messageids)
6363
- [no-invalid-message-ids](./no-invalid-message-ids.md) rule
6464
- [no-missing-message-ids](./no-missing-message-ids.md) rule

docs/rules/prefer-object-rule.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- end auto-generated rule header -->
88

9-
Prior to ESLint v9, ESLint supported both [function-style](https://eslint.org/docs/developer-guide/working-with-rules-deprecated) and [object-style](https://eslint.org/docs/developer-guide/working-with-rules) rules. However, function-style rules have been deprecated since 2016, and do not support newer features like autofixing and suggestions.
9+
Prior to ESLint v9, ESLint supported both [function-style](https://eslint.org/docs/latest/extend/custom-rules-deprecated) and [object-style](https://eslint.org/docs/latest/extend/custom-rules) rules. However, function-style rules have been deprecated since 2016, and do not support newer features like autofixing and suggestions.
1010

1111
As of [ESLint v9](https://github.com/eslint/rfcs/tree/main/designs/2021-schema-object-rules#motivation-for-requiring-object-style-rules), ESLint supports only object-style rules.
1212

docs/rules/prefer-placeholders.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ If you need to use string concatenation in your report messages for some reason,
6363

6464
## Further Reading
6565

66-
- [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
66+
- [ESLint rule docs: Using Message Placeholders](https://eslint.org/docs/latest/extend/custom-rules#using-message-placeholders)

docs/rules/prefer-replace-text.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ module.exports = {
5353

5454
## Further Reading
5555

56-
- [Applying Fixes](https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes)
56+
- [ESLint rule docs: Applying Fixes](https://eslint.org/docs/latest/extend/custom-rules#applying-fixes)

docs/rules/require-meta-docs-description.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ module.exports = {
5959

6060
## Further Reading
6161

62-
- [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)
62+
- [ESLint rule docs: Options Schemas](https://eslint.org/docs/latest/extend/custom-rules#options-schemas)

docs/rules/require-meta-docs-recommended.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Require rules to implement a `meta.docs.recommended` property (`eslint-plugin/require-meta-docs-recommended`)
22

3+
💡 This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
4+
35
<!-- end auto-generated rule header -->
46

57
Utilizing `meta.docs.recommended` makes it clear from each rule implementation whether a rule is part of the `recommended` config. Some plugins also have scripting for conveniently generating their config based on this flag.
@@ -72,4 +74,4 @@ module.exports = {
7274

7375
## Further Reading
7476

75-
- [Rule Structure](https://eslint.org/docs/latest/extend/custom-rules#rule-structure)
77+
- [ESLint rule docs: Rule Structure](https://eslint.org/docs/latest/extend/custom-rules#rule-structure)

docs/rules/require-meta-fixable.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ module.exports = {
102102

103103
## Further Reading
104104

105-
- [ESLint's autofix API](http://eslint.org/docs/developer-guide/working-with-rules#applying-fixes)
106-
- [ESLint's rule basics mentioning `meta.fixable`](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
105+
- [ESLint rule docs: Applying Fixes](https://eslint.org/docs/latest/extend/custom-rules#applying-fixes)
106+
- [ESLint rule docs: Rule Structure (mentioning `meta.fixable`)](https://eslint.org/docs/latest/extend/custom-rules#rule-structure)

docs/rules/require-meta-has-suggestions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ module.exports = {
8888

8989
## Further Reading
9090

91-
- [ESLint's suggestion API](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
92-
- [ESLint rule basics describing the `meta.hasSuggestions` property](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
91+
- [ESLint rule docs: Providing Suggestions](https://eslint.org/docs/latest/extend/custom-rules#providing-suggestions)
92+
- [ESLint rule docs: Rule Structure (mentioning `meta.hasSuggestions`)](https://eslint.org/docs/latest/extend/custom-rules#rule-structure)

docs/rules/require-meta-schema-description.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ If your rule options are very simple and well-named, and your rule isn't used by
8585

8686
## Further Reading
8787

88-
- [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)
88+
- [ESLint rule docs: Options Schemas](https://eslint.org/docs/latest/extend/custom-rules#options-schemas)

docs/rules/require-meta-schema.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ As mentioned in the introduction, the need for this rule is reduced as of ESLint
8989

9090
## Further Reading
9191

92-
- [working-with-rules#options-schemas](https://eslint.org/docs/developer-guide/working-with-rules#options-schemas)
92+
- [ESLint rule docs: Options Schemas](https://eslint.org/docs/latest/extend/custom-rules#options-schemas)

docs/rules/require-meta-type.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ module.exports = {
5151

5252
## Further Reading
5353

54-
- [command-line-interface#--fix-type](https://eslint.org/docs/user-guide/command-line-interface#--fix-type)
55-
- [working-with-rules#rule-basics](https://eslint.org/docs/developer-guide/working-with-rules#rule-basics)
54+
- [ESLint CLI docs: `--fix-type`](https://eslint.org/docs/latest/use/command-line-interface#--fix-type)
55+
- [ESLint rule docs: Rule Structure](https://eslint.org/docs/latest/extend/custom-rules#rule-structure)
5656
- [ESLint v5.9.0 released](https://eslint.org/blog/2018/11/eslint-v5.9.0-released#the-fix-type-option)

docs/rules/test-case-shorthand-strings.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,4 @@ If you don't care about consistent usage of shorthand strings, you should not tu
248248

249249
## Further Reading
250250

251-
- [`RuleTester` documentation](http://eslint.org/docs/developer-guide/working-with-plugins#testing)
251+
- [ESLint plugin docs: Testing a Plugin](https://eslint.org/docs/latest/extend/plugins#testing-a-plugin)

eslint-remote-tester.config.js renamed to eslint-remote-tester.config.mjs

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
'use strict';
1+
import eslintPlugin from 'eslint-plugin-eslint-plugin';
2+
import tsparser from '@typescript-eslint/parser';
23

34
/** @type {import('eslint-remote-tester').Config} */
4-
module.exports = {
5+
export default {
56
/** Repositories to scan */
67
repositories: [
78
// A few dozen top ESLint plugins.
@@ -41,18 +42,18 @@ module.exports = {
4142
/** Optional boolean flag used to enable caching of cloned repositories. For CIs it's ideal to disable caching. Defaults to true. */
4243
cache: false,
4344

44-
pathIgnorePattern: 'fixtures',
45-
4645
/** ESLint configuration */
47-
eslintrc: {
48-
root: true,
49-
extends: ['plugin:eslint-plugin/all'],
50-
// ignorePatterns: ['fixtures/**/*'], // not working somehow - using `pathIgnorePattern` as of now.
51-
overrides: [
52-
{
53-
files: ['*.ts', '*.mts', '*.cts'],
54-
parser: '@typescript-eslint/parser',
46+
eslintConfig: [
47+
{
48+
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
49+
...eslintPlugin.configs['flat/all'],
50+
},
51+
{
52+
files: ['*.ts', '*.mts', '*.cts'],
53+
...eslintPlugin.configs['flat/all-type-checked'],
54+
languageOptions: {
55+
parser: tsparser,
5556
},
56-
],
57-
},
57+
},
58+
],
5859
};

eslint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = [
1919
'plugin:prettier/recommended',
2020
'plugin:unicorn/recommended',
2121
),
22-
pluginN.configs['flat/recommended'],
22+
...pluginN.configs['flat/mixed-esm-and-cjs'],
2323
{
2424
rules: {
2525
'@eslint-community/eslint-comments/no-unused-disable': 'error',

lib/rules/require-meta-docs-recommended.js

+48
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
const { getStaticValue } = require('@eslint-community/eslint-utils');
44
const utils = require('../utils');
55

6+
/**
7+
* @param {import('eslint').Rule.RuleFixer} fixer
8+
* @param {import('estree').ObjectExpression} objectNode
9+
* @param {boolean} recommendedValue
10+
*/
11+
function insertRecommendedProperty(fixer, objectNode, recommendedValue) {
12+
if (objectNode.properties.length === 0) {
13+
return fixer.replaceText(
14+
objectNode,
15+
`{ recommended: ${recommendedValue} }`,
16+
);
17+
}
18+
return fixer.insertTextAfter(
19+
objectNode.properties.at(-1),
20+
`, recommended: ${recommendedValue}`,
21+
);
22+
}
23+
624
/** @type {import('eslint').Rule.RuleModule} */
725
module.exports = {
826
meta: {
@@ -15,6 +33,7 @@ module.exports = {
1533
url: 'https://github.com/eslint-community/eslint-plugin-eslint-plugin/tree/HEAD/docs/rules/require-meta-docs-recommended.md',
1634
},
1735
fixable: null,
36+
hasSuggestions: true,
1837
schema: [
1938
{
2039
type: 'object',
@@ -31,6 +50,8 @@ module.exports = {
3150
messages: {
3251
incorrect: '`meta.docs.recommended` is required to be a boolean.',
3352
missing: '`meta.docs.recommended` is required.',
53+
setRecommendedTrue: 'Set `meta.docs.recommended` to `true`.',
54+
setRecommendedFalse: 'Set `meta.docs.recommended` to `false`.',
3455
},
3556
},
3657

@@ -49,9 +70,26 @@ module.exports = {
4970
} = utils.getMetaDocsProperty('recommended', ruleInfo, scopeManager);
5071

5172
if (!descriptionNode) {
73+
const suggestions =
74+
docsNode?.value?.type === 'ObjectExpression'
75+
? [
76+
{
77+
messageId: 'setRecommendedTrue',
78+
fix: (fixer) =>
79+
insertRecommendedProperty(fixer, docsNode.value, true),
80+
},
81+
{
82+
messageId: 'setRecommendedFalse',
83+
fix: (fixer) =>
84+
insertRecommendedProperty(fixer, docsNode.value, false),
85+
},
86+
]
87+
: [];
88+
5289
context.report({
5390
node: docsNode || metaNode || ruleInfo.create,
5491
messageId: 'missing',
92+
suggest: suggestions,
5593
});
5694
return {};
5795
}
@@ -68,6 +106,16 @@ module.exports = {
68106
context.report({
69107
node: descriptionNode.value,
70108
messageId: 'incorrect',
109+
suggest: [
110+
{
111+
messageId: 'setRecommendedTrue',
112+
fix: (fixer) => fixer.replaceText(descriptionNode.value, 'true'),
113+
},
114+
{
115+
messageId: 'setRecommendedFalse',
116+
fix: (fixer) => fixer.replaceText(descriptionNode.value, 'false'),
117+
},
118+
],
71119
});
72120
return {};
73121
}

lib/rules/test-case-property-ordering.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports = {
6868
// current < lastChecked to catch unordered;
6969
// and lastChecked === -1 to catch extra properties before.
7070
if (
71-
current > -1 &&
71+
current !== -1 &&
7272
(current < lastChecked || lastChecked === -1)
7373
) {
7474
let orderMsg = order.filter((item) =>

0 commit comments

Comments
 (0)