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

Lines changed: 0 additions & 19 deletions
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

Lines changed: 12 additions & 6 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 27 additions & 0 deletions
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

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"type": "module",
23
"devDependencies": {
34
"eslint-plugin-markdown": "latest"
45
}

0 commit comments

Comments
 (0)