Skip to content

Commit 03cf3d7

Browse files
michaelfaithbmish
andauthored
feat!: remove eslint v8 / eslintrc support and remove flat/ prefix from configs (#528)
* feat!: remove eslint v8 support This change removes support for legacy rc-based configs, and moves minimum supported version to 9.0. I've also removed the deprecated `/configs` entry point. * use test setup file * docs: update examples * build: disable n/no-missing-import for md files * build: disable n/no-missing-import for md files --------- Co-authored-by: Bryan Mishkin <[email protected]>
1 parent 0b708d7 commit 03cf3d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+107
-244
lines changed

.eslint-doc-generatorrc.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ const config = {
99
'rules-recommended',
1010
'tests',
1111
'tests-recommended',
12-
'flat/recommended',
13-
'flat/all',
14-
'flat/all-type-checked',
15-
'flat/rules',
16-
'flat/rules-recommended',
17-
'flat/tests',
18-
'flat/tests-recommended',
1912
],
2013
postprocess: async (content, path) =>
2114
prettier.format(content, {

.github/workflows/main.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,17 @@ jobs:
3434
- uses: actions/checkout@v4
3535
- uses: actions/setup-node@v4
3636
with:
37-
node-version: "lts/*"
37+
node-version: 'lts/*'
3838
- run: npm install
3939
- run: npm run lint
4040

41-
eslint8:
42-
runs-on: ubuntu-latest
43-
steps:
44-
- uses: actions/checkout@v4
45-
- uses: actions/setup-node@v4
46-
with:
47-
node-version: "lts/*"
48-
- run: npm install
49-
- run: npm install --save-dev eslint@8
50-
- run: npm test
51-
5241
test-remote:
5342
name: eslint-remote-tester
5443
runs-on: ubuntu-latest
5544
steps:
5645
- uses: actions/checkout@v4
5746
- uses: actions/setup-node@v4
5847
with:
59-
node-version: "lts/*"
48+
node-version: 'lts/*'
6049
- run: npm install
6150
- run: npm run test:remote

README.md

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ An ESLint plugin for linting ESLint plugins. Rules written in CJS, ESM, and Type
66

77
- [Installation](#installation)
88
- [Usage](#usage)
9-
- [**.eslintrc.json**](#eslintrcjson)
10-
- [`eslint.config.js` (requires eslint\>=v8.23.0)](#eslintconfigjs-requires-eslintv8230)
119
- [Rules](#rules)
1210
- [Rules](#rules-1)
1311
- [Tests](#tests)
@@ -42,25 +40,14 @@ Here's an example ESLint configuration that:
4240
- Enables the `recommended` configuration
4341
- Enables an optional/non-recommended rule
4442

45-
Note: you might need to set `sourceType` to `script` (most users) (use `module` for ESM/TypeScript).
46-
47-
### <a name='eslintrc'></a>**[.eslintrc.json](https://eslint.org/docs/latest/use/configure/configuration-files)**
48-
49-
```json
50-
{
51-
"extends": ["plugin:eslint-plugin/recommended"],
52-
"rules": {
53-
"eslint-plugin/require-meta-docs-description": "error"
54-
}
55-
}
56-
```
57-
58-
### <a name='flat'></a>[`eslint.config.js`](https://eslint.org/docs/latest/use/configure/configuration-files-new) (requires eslint>=v8.23.0)
43+
Note: you might need to set `sourceType` to `module` or `script` depending on your codebase.
5944

6045
```js
61-
const eslintPlugin = require('eslint-plugin-eslint-plugin');
62-
module.exports = [
63-
eslintPlugin.configs['flat/recommended'],
46+
// eslint.config.js
47+
import eslintPlugin from 'eslint-plugin-eslint-plugin';
48+
49+
export default [
50+
eslintPlugin.configs.recommended,
6451
{
6552
rules: {
6653
'eslint-plugin/require-meta-docs-description': 'error',
@@ -141,54 +128,29 @@ The list of recommended rules will only change in a major release of this plugin
141128

142129
### <a name='Presetusage'></a>Preset usage
143130

144-
Both flat and eslintrc configs are supported. For example, to enable the `recommended` preset, use:
145-
146-
eslint.config.js
131+
Example of applying the `recommended` config to all files.
147132

148133
```js
149-
const eslintPlugin = require('eslint-plugin-eslint-plugin');
150-
module.exports = [eslintPlugin.configs['flat/recommended']];
151-
```
134+
// eslint.config.js
135+
import eslintPlugin from 'eslint-plugin-eslint-plugin';
152136

153-
.eslintrc.json
154-
155-
```json
156-
{
157-
"extends": ["plugin:eslint-plugin/recommended"]
158-
}
137+
export default [eslintPlugin.configs.recommended];
159138
```
160139

161140
Or to apply linting only to the appropriate rule or test files:
162141

163-
eslint.config.js
164-
165142
```js
166-
const eslintPlugin = require('eslint-plugin-eslint-plugin');
167-
module.exports = [
143+
// eslint.config.js
144+
import eslintPlugin from 'eslint-plugin-eslint-plugin';
145+
146+
export default [
168147
{
169148
files: ['lib/rules/*.{js,ts}'],
170-
...eslintPlugin.configs['flat/rules-recommended'],
149+
...eslintPlugin.configs['rules-recommended'],
171150
},
172151
{
173152
files: ['tests/lib/rules/*.{js,ts}'],
174-
...eslintPlugin.configs['flat/tests-recommended'],
153+
...eslintPlugin.configs['tests-recommended'],
175154
},
176155
];
177156
```
178-
179-
.eslintrc.js
180-
181-
```json
182-
{
183-
"overrides": [
184-
{
185-
"files": ["lib/rules/*.{js,ts}"],
186-
"extends": ["plugin:eslint-plugin/rules-recommended"]
187-
},
188-
{
189-
"files": ["tests/lib/rules/*.{js,ts}"],
190-
"extends": ["plugin:eslint-plugin/tests-recommended"]
191-
}
192-
]
193-
}
194-
```

configs/all-type-checked.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

configs/all.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

configs/recommended.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

configs/rules-recommended.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

configs/rules.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

configs/tests-recommended.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

configs/tests.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,54 @@ module.exports = {
9696
}
9797
```
9898

99+
```js
100+
// eslint.config.js
101+
import eslintPlugin from 'eslint-plugin-eslint-plugin';
102+
103+
export default [
104+
{
105+
plugins: { 'eslint-plugin': eslintPlugin },
106+
rules: {
107+
'eslint-plugin/require-meta-docs-url': [
108+
'error',
109+
{
110+
pattern:
111+
'https://github.com/eslint-community/eslint-plugin-eslint-plugin/blob/master/docs/rules/{{name}}.md',
112+
},
113+
],
114+
},
115+
},
116+
];
117+
```
118+
99119
If you set the `pattern` option, this rule adds `meta.docs.url` property automatically when you execute `eslint --fix` command.
100120

101121
## Version specific URL
102122

103-
If you want to enforce version-specific URLs, it's feasible easily with `.eslintrc.js` and `npm version <type>` script.
123+
If you want to enforce version-specific URLs, it's feasible easily with `eslint.config.js` and `npm version <type>` script.
104124
For example:
105125

106-
**.eslintrc.js**:
126+
**eslint.config.js**:
107127

108128
```js
109-
// const version = require("./package.json").version;
110-
111-
module.exports = {
112-
plugins: ['eslint-plugin'],
113-
rules: {
114-
'eslint-plugin/require-meta-docs-url': [
115-
'error',
116-
{
117-
pattern: `path/to/v${version}/docs/rules/{{name}}.md`,
118-
},
119-
],
129+
import eslintPlugin from 'eslint-plugin-eslint-plugin';
130+
import packageMetadata from './package.json' with { type: 'json' };
131+
132+
const { version } = packageMetadata;
133+
134+
export default [
135+
{
136+
plugins: { 'eslint-plugin': eslintPlugin },
137+
rules: {
138+
'eslint-plugin/require-meta-docs-url': [
139+
'error',
140+
{
141+
pattern: `path/to/v${version}/docs/rules/{{name}}.md`,
142+
},
143+
],
144+
},
120145
},
121-
};
146+
];
122147
```
123148

124149
**package.json**:

eslint.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import js from '@eslint/js';
44
import { FlatCompat } from '@eslint/eslintrc';
55
import markdown from 'eslint-plugin-markdown';
66
import pluginN from 'eslint-plugin-n';
7-
import eslintPluginConfig from 'eslint-plugin-eslint-plugin/configs/all';
7+
import eslintPlugin from './lib/index.js';
88

99
const dirname = path.dirname(fileURLToPath(import.meta.url));
1010
const compat = new FlatCompat({
@@ -46,9 +46,9 @@ export default [
4646
{
4747
// Apply eslint-plugin rules to our own rules/tests (but not docs).
4848
files: ['lib/**/*.js', 'tests/**/*.js'],
49-
plugins: eslintPluginConfig.plugins,
49+
plugins: { 'eslint-plugin': eslintPlugin },
5050
rules: {
51-
...eslintPluginConfig.rules,
51+
...eslintPlugin.configs.all.rules,
5252
'eslint-plugin/no-meta-schema-default': 'off', // TODO: enable once https://github.com/bmish/eslint-doc-generator/issues/513 is fixed and released
5353
'eslint-plugin/report-message-format': ['error', '^[^a-z].*.$'],
5454
'eslint-plugin/require-meta-docs-url': [
@@ -77,6 +77,8 @@ export default [
7777

7878
'@eslint-community/eslint-comments/require-description': 'off',
7979

80+
'n/no-missing-import': 'off',
81+
8082
'unicorn/filename-case': 'off',
8183
},
8284
},

lib/index.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,14 @@ const plugin = {
105105
configs: {}, // assigned later
106106
};
107107

108-
// eslintrc configs
108+
// configs
109109
Object.assign(
110110
plugin.configs,
111111
Object.keys(configFilters).reduce((configs, configName) => {
112112
return Object.assign(configs, {
113113
[configName]: {
114-
plugins: ['eslint-plugin'],
115-
rules: Object.fromEntries(
116-
Object.keys(allRules)
117-
.filter((ruleName) => configFilters[configName](allRules[ruleName]))
118-
.map((ruleName) => [`${PLUGIN_NAME}/${ruleName}`, 'error']),
119-
),
120-
},
121-
});
122-
}, {}),
123-
);
124-
125-
// flat configs
126-
Object.assign(
127-
plugin.configs,
128-
Object.keys(configFilters).reduce((configs, configName) => {
129-
return Object.assign(configs, {
130-
[`flat/${configName}`]: {
131-
name: `eslint-plugin/flat/${configName}`,
132-
plugins: { 'eslint-plugin': plugin },
114+
name: `${PLUGIN_NAME}/${configName}`,
115+
plugins: { [PLUGIN_NAME]: plugin },
133116
rules: Object.fromEntries(
134117
Object.keys(allRules)
135118
.filter((ruleName) => configFilters[configName](allRules[ruleName]))

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"type": "module",
88
"exports": {
99
".": "./lib/index.js",
10-
"./configs/*": "./configs/*.js",
1110
"./package.json": "./package.json"
1211
},
1312
"license": "MIT",
@@ -24,8 +23,8 @@
2423
"update:eslint-docs": "eslint-doc-generator"
2524
},
2625
"files": [
27-
"lib/",
28-
"configs/"
26+
"CHANGELOG.md",
27+
"lib/"
2928
],
3029
"keywords": [
3130
"eslint",
@@ -79,7 +78,7 @@
7978
"vitest": "^3.2.4"
8079
},
8180
"peerDependencies": {
82-
"eslint": ">=8.23.0"
81+
"eslint": ">=9.0.0"
8382
},
8483
"engines": {
8584
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"

0 commit comments

Comments
 (0)