Skip to content

Commit 86811d7

Browse files
authored
chore: use eslint 9 internally (typescript-eslint#9119)
* eslint 9 * add compat * add fixup * fixup react * add more fixups * add issue comment * lint and empty types * fix types * remove eslint9 ci test * rename * update no-restricted-imports snapshot * update build script * change quote style * revert renaming * begin migrating config files * migrate markdown to v9 * migrate recommended-does-not-require-program * migrate eslint.config.js * migrate vue-sfc, except for TS errors * remove flatconfig boolean * remove config file option * remove deprecated rules * correct issue * revert style change * add clarifying comment * remove unnecessary suppression * remove unnecessary suppression * remove unused suppression
1 parent 0d70d62 commit 86811d7

File tree

27 files changed

+224
-208
lines changed

27 files changed

+224
-208
lines changed

.github/workflows/ci.yml

-19
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,6 @@ jobs:
134134
run: yarn stylelint
135135
working-directory: packages/website
136136

137-
eslint_v9_tests:
138-
name: Run tests on ESLint v9
139-
needs: [build]
140-
runs-on: ubuntu-latest
141-
steps:
142-
- name: Checkout
143-
uses: actions/checkout@v4
144-
- name: Install
145-
uses: ./.github/actions/prepare-install
146-
with:
147-
node-version: ${{ env.PRIMARY_NODE_VERSION }}
148-
- name: Build
149-
uses: ./.github/actions/prepare-build
150-
- run: yarn add eslint@9
151-
- name: Run tests
152-
run: yarn test
153-
env:
154-
CI: true
155-
156137
integration_tests:
157138
name: Run integration tests on primary Node.js version
158139
needs: [build]

eslint.config.mjs

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import url from 'node:url';
44

5+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
56
import { FlatCompat } from '@eslint/eslintrc';
67
import eslint from '@eslint/js';
78
import tseslintInternalPlugin from '@typescript-eslint/eslint-plugin-internal';
@@ -29,15 +30,20 @@ export default tseslint.config(
2930
plugins: {
3031
['@typescript-eslint']: tseslint.plugin,
3132
['@typescript-eslint/internal']: tseslintInternalPlugin,
32-
['deprecation']: deprecationPlugin,
33+
// https://github.com/gund/eslint-plugin-deprecation/issues/78
34+
// https://github.com/typescript-eslint/typescript-eslint/issues/8988
35+
['deprecation']: fixupPluginRules(deprecationPlugin),
3336
['eslint-comments']: eslintCommentsPlugin,
3437
['eslint-plugin']: eslintPluginPlugin,
35-
['import']: importPlugin,
38+
// https://github.com/import-js/eslint-plugin-import/issues/2948
39+
['import']: fixupPluginRules(importPlugin),
3640
['jest']: jestPlugin,
3741
['jsdoc']: jsdocPlugin,
3842
['jsx-a11y']: jsxA11yPlugin,
39-
['react-hooks']: reactHooksPlugin,
40-
['react']: reactPlugin,
43+
// https://github.com/facebook/react/issues/28313
44+
['react-hooks']: fixupPluginRules(reactHooksPlugin),
45+
// https://github.com/jsx-eslint/eslint-plugin-react/issues/3699
46+
['react']: fixupPluginRules(reactPlugin),
4147
['simple-import-sort']: simpleImportSortPlugin,
4248
['unicorn']: unicornPlugin,
4349
},
@@ -512,8 +518,8 @@ export default tseslint.config(
512518
files: ['packages/website/**/*.{ts,tsx,mts,cts,js,jsx}'],
513519
extends: [
514520
...compat.config(jsxA11yPlugin.configs.recommended),
515-
...compat.config(reactPlugin.configs.recommended),
516-
...compat.config(reactHooksPlugin.configs.recommended),
521+
...fixupConfigRules(compat.config(reactPlugin.configs.recommended)),
522+
...fixupConfigRules(compat.config(reactHooksPlugin.configs.recommended)),
517523
],
518524
rules: {
519525
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@babel/eslint-parser": "^7.24.1",
6161
"@babel/parser": "^7.24.4",
6262
"@babel/types": "^7.24.0",
63+
"@eslint/compat": "^1.0.1",
6364
"@eslint/eslintrc": "^2.1.4",
6465
"@eslint/js": "^8.57.0",
6566
"@jest/types": "29.6.3",
@@ -85,7 +86,7 @@
8586
"cross-fetch": "^4.0.0",
8687
"cspell": "^8.6.1",
8788
"downlevel-dts": ">=0.11.0",
88-
"eslint": "8.57.0",
89+
"eslint": "^9.3.0",
8990
"eslint-plugin-deprecation": "^2.0.0",
9091
"eslint-plugin-eslint-comments": "^3.2.0",
9192
"eslint-plugin-eslint-plugin": "^5.5.0",
@@ -129,7 +130,7 @@
129130
"@types/estree": "link:./tools/dummypkg",
130131
"@types/node": "^20.0.0",
131132
"@types/react": "^18.2.14",
132-
"eslint": "8.57.0",
133+
"eslint": "^9",
133134
"eslint-visitor-keys": "^3.4.1",
134135
"jest-config": "^29",
135136
"jest-resolve": "^29",

packages/eslint-plugin/rules.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,4 @@ export type TypeScriptESLintRules = Record<
7474
>;
7575

7676
declare const rules: TypeScriptESLintRules;
77-
// eslint-disable-next-line import/no-default-export
7877
export default rules;

packages/eslint-plugin/src/rules/prefer-regexp-exec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
21
import type { TSESTree } from '@typescript-eslint/utils';
32
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
43
import * as tsutils from 'ts-api-utils';

packages/eslint-plugin/tests/rules/prefer-optional-chain/base-cases.ts

-4
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,6 @@ const RawBaseCases = (operator: '&&' | '||') =>
229229
] as const;
230230

231231
export const identity: MutateFn = c => c;
232-
/*
233-
eslint-disable-next-line eslint-plugin/prefer-message-ids, eslint-plugin/prefer-object-rule, eslint-plugin/require-meta-type, eslint-plugin/require-meta-schema --
234-
TODO - bug in hte rules - https://github.com/eslint-community/eslint-plugin-eslint-plugin/issues/455
235-
*/
236232
export const BaseCases: BaseCaseCreator = ({
237233
operator,
238234
mutateCode = identity,

packages/eslint-plugin/tests/schema-snapshots/no-restricted-imports.shot

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/integration-tests/fixtures/markdown/.eslintrc.js

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import markdown from 'eslint-plugin-markdown';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
tseslint.configs.base,
6+
// this will also ensure that eslint will force lint the markdown files
7+
{ plugins: { markdown }, files: ['**/*.md'], processor: 'markdown/markdown' },
8+
{
9+
files: ['**/*.md/*.{js,ts,jsx,tsx,javascript,node}'],
10+
rules: {
11+
'@typescript-eslint/no-explicit-any': 'error',
12+
'no-console': 'error',
13+
},
14+
},
15+
);

packages/integration-tests/fixtures/markdown/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"type": "module",
23
"devDependencies": {
34
"eslint-plugin-markdown": "latest"
45
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
14
// This integration test exists to make sure that the recommended config does
25
// not require a program to be specified to ensure a fast and simple initial
36
// setup. Users can add on one of our other configs if they want to opt in to
47
// more expensive checks.
5-
module.exports = {
6-
root: true,
7-
parser: '@typescript-eslint/parser',
8-
extends: [
9-
'eslint:recommended',
10-
'plugin:@typescript-eslint/eslint-recommended',
11-
'plugin:@typescript-eslint/recommended',
12-
],
13-
plugins: ['@typescript-eslint'],
14-
};
8+
export default tseslint.config(
9+
eslint.configs.recommended,
10+
...tseslint.configs.recommended,
11+
);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"type": "module",
23
"devDependencies": {}
34
}

packages/integration-tests/fixtures/vue-jsx/.eslintrc.js

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import tseslint from 'typescript-eslint';
2+
import pluginVue from 'eslint-plugin-vue';
3+
4+
export default tseslint.config(
5+
tseslint.configs.base,
6+
...pluginVue.configs['flat/essential'],
7+
{
8+
languageOptions: {
9+
parserOptions: { ecmaFeatures: { jsx: true }, parser: tseslint.parser },
10+
},
11+
rules: { '@typescript-eslint/no-explicit-any': 'error' },
12+
},
13+
);

packages/integration-tests/fixtures/vue-jsx/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"type": "module",
23
"devDependencies": {
34
"vue-eslint-parser": "latest",
45
"eslint-plugin-vue": "latest",

packages/integration-tests/fixtures/vue-sfc/.eslintrc.js

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pluginVue from 'eslint-plugin-vue';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
tseslint.configs.base,
6+
...pluginVue.configs['flat/essential'],
7+
{
8+
languageOptions: {
9+
parserOptions: {
10+
parser: tseslint.parser,
11+
project: '/usr/linked/tsconfig.json',
12+
},
13+
},
14+
rules: {
15+
'@typescript-eslint/no-explicit-any': 'error',
16+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
17+
'semi-spacing': 'error',
18+
},
19+
},
20+
);

packages/integration-tests/fixtures/vue-sfc/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"type": "module",
23
"devDependencies": {
34
"vue-eslint-parser": "latest",
45
"eslint-plugin-vue": "latest",

packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap

+1-10
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@ exports[`recommended-does-not-require-program eslint should work successfully 1`
2424
"output": "const foo: unknown = true;
2525
",
2626
"suppressedMessages": [],
27-
"usedDeprecatedRules": [
28-
{
29-
"replacedBy": [],
30-
"ruleId": "no-extra-semi",
31-
},
32-
{
33-
"replacedBy": [],
34-
"ruleId": "no-mixed-spaces-and-tabs",
35-
},
36-
],
27+
"usedDeprecatedRules": [],
3728
"warningCount": 0,
3829
},
3930
]

packages/integration-tests/tests/flat-config-types.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ for (const additionalFlags of [
2525
},
2626
);
2727
}
28-
eslintIntegrationTest(__filename, 'eslint.config.js', true);
28+
eslintIntegrationTest(__filename, 'eslint.config.js');

packages/integration-tests/tools/integration-test-base.ts

-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ function integrationTest(
128128
export function eslintIntegrationTest(
129129
testFilename: string,
130130
filesGlob: string,
131-
flatConfig = false,
132131
): void {
133132
integrationTest('eslint', testFilename, async testFolder => {
134133
// lint, outputting to a JSON file
@@ -143,8 +142,6 @@ export function eslintIntegrationTest(
143142
'json',
144143
'--output-file',
145144
outFile,
146-
'--config',
147-
flatConfig ? './eslint.config.js' : './.eslintrc.js',
148145
'--fix-dry-run',
149146
filesGlob,
150147
],

0 commit comments

Comments
 (0)