Skip to content

Commit fba5564

Browse files
Update to ESLint v9
1 parent 0ebb03b commit fba5564

File tree

5 files changed

+1558
-552
lines changed

5 files changed

+1558
-552
lines changed

.eslintignore

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

.eslintrc.cjs

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

eslint.config.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { join } from 'node:path';
2+
import configPrettier from 'eslint-config-prettier/flat';
3+
import pluginReact from 'eslint-plugin-react';
4+
import pluginReactHooks from 'eslint-plugin-react-hooks';
5+
import eslint from '@eslint/js';
6+
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
7+
import { includeIgnoreFile } from '@eslint/compat';
8+
import { defineConfig, globalIgnores } from 'eslint/config';
9+
import globals from 'globals';
10+
import pluginImport from 'eslint-plugin-import';
11+
import pluginTypeScript from 'typescript-eslint';
12+
13+
const rootPath = import.meta.dirname;
14+
const gitignorePath = join(rootPath, '.gitignore');
15+
16+
export default defineConfig([
17+
{
18+
files: ['**/*.{js,mjs,ts,tsx}'],
19+
extends: [
20+
configPrettier,
21+
eslint.configs.recommended,
22+
pluginTypeScript.configs.recommended,
23+
pluginImport.flatConfigs.recommended,
24+
pluginImport.flatConfigs.typescript,
25+
],
26+
languageOptions: {
27+
parser: pluginTypeScript.parser,
28+
parserOptions: {
29+
ecmaVersion: 'latest',
30+
projectService: true,
31+
tsconfigRootDir: rootPath,
32+
},
33+
},
34+
settings: {
35+
'import/resolver': {
36+
node: true,
37+
typescript: true,
38+
},
39+
},
40+
},
41+
{
42+
files: ['**/*.{ts,tsx}'],
43+
extends: [
44+
pluginJsxA11y.flatConfigs.recommended,
45+
pluginReact.configs.flat.recommended,
46+
pluginReact.configs.flat['jsx-runtime'],
47+
'react-hooks/recommended-latest',
48+
],
49+
languageOptions: {
50+
globals: globals.browser,
51+
parserOptions: {
52+
ecmaFeatures: { jsx: true },
53+
sourceType: 'module',
54+
},
55+
},
56+
plugins: {
57+
'react-hooks': pluginReactHooks,
58+
},
59+
rules: {
60+
'import/no-unresolved': 'off',
61+
'react/prop-types': 0,
62+
'jsx-a11y/anchor-has-content': 0,
63+
'jsx-a11y/alt-text': 0,
64+
'jsx-a11y/heading-has-content': 0,
65+
'react-hooks/exhaustive-deps': 0,
66+
},
67+
settings: {
68+
react: {
69+
version: 'detect',
70+
},
71+
},
72+
},
73+
{
74+
files: ['**/*.{cjs,js,mjs}'],
75+
languageOptions: {
76+
globals: globals.node,
77+
},
78+
},
79+
{
80+
files: ['**/*.cjs'],
81+
rules: {
82+
'@typescript-eslint/no-require-imports': 'off',
83+
'@typescript-eslint/no-var-requires': 'off',
84+
},
85+
},
86+
{
87+
files: ['**/*.test.{ts,tsx}'],
88+
languageOptions: {
89+
globals: globals.jest,
90+
},
91+
},
92+
{
93+
files: ['**/*.stories.tsx'],
94+
rules: { '@typescript-eslint/no-unused-vars': 'off' },
95+
},
96+
globalIgnores(['**/coverage/', '**/dist/']),
97+
includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'),
98+
]);

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"lint:fix": "yarn lint:js:fix && yarn lint:prettier:fix",
6060
"lint:prettier": "prettier --check .",
6161
"lint:prettier:fix": "prettier --write .",
62-
"lint:js": "eslint 'src/**/*.{js,ts,tsx}' 'stories/**/*.{js,ts,tsx}'",
62+
"lint:js": "eslint .",
6363
"lint:js:fix": "yarn lint:js --fix",
6464
"lint:types": "tsc --build tsconfig.json --pretty",
6565
"build-storybook": "storybook build",
@@ -71,6 +71,8 @@
7171
"@babel/preset-env": "^7.28.3",
7272
"@babel/preset-react": "^7.27.1",
7373
"@babel/preset-typescript": "^7.27.1",
74+
"@eslint/compat": "^1.4.0",
75+
"@eslint/js": "^9.37.0",
7476
"@rollup/plugin-babel": "^6.0.4",
7577
"@rollup/plugin-commonjs": "^28.0.6",
7678
"@rollup/plugin-node-resolve": "^16.0.1",
@@ -84,26 +86,25 @@
8486
"@storybook/theming": "^8.0.5",
8587
"@testing-library/jest-dom": "^6.9.1",
8688
"@testing-library/react": "^15.0.7",
89+
"@types/eslint": "^9.6.1",
8790
"@types/jest": "^30.0.0",
8891
"@types/jest-axe": "^3.5.9",
8992
"@types/node": "^24.6.2",
9093
"@types/react": "^18.3.12",
9194
"@types/react-dom": "^18.3.1",
92-
"@typescript-eslint/eslint-plugin": "^7.1.0",
93-
"@typescript-eslint/parser": "^7.1.0",
9495
"babel-jest": "^30.2.0",
9596
"babel-plugin-module-resolver": "^5.0.2",
9697
"babel-plugin-replace-import-extension": "^1.1.5",
9798
"chromatic": "^6.17.3",
9899
"classnames": "^2.5.1",
99-
"eslint": "^8.57.0",
100-
"eslint-config-prettier": "^9.1.0",
101-
"eslint-import-resolver-typescript": "^3.6.1",
102-
"eslint-plugin-import": "^2.29.1",
103-
"eslint-plugin-jsx-a11y": "^6.8.0",
104-
"eslint-plugin-prettier": "^5.1.3",
105-
"eslint-plugin-react": "^7.33.2",
106-
"eslint-plugin-react-hooks": "^4.6.0",
100+
"eslint": "^9.37.0",
101+
"eslint-config-prettier": "^10.1.8",
102+
"eslint-import-resolver-typescript": "^4.4.4",
103+
"eslint-plugin-import": "^2.32.0",
104+
"eslint-plugin-jsx-a11y": "^6.10.2",
105+
"eslint-plugin-react": "^7.37.5",
106+
"eslint-plugin-react-hooks": "^6.1.0",
107+
"globals": "^16.4.0",
107108
"jest": "^30.2.0",
108109
"jest-axe": "^10.0.0",
109110
"jest-environment-jsdom": "^30.2.0",
@@ -118,6 +119,7 @@
118119
"storybook": "^8.0.5",
119120
"tslib": "^2.8.1",
120121
"typescript": "5.3.3",
122+
"typescript-eslint": "^8.45.0",
121123
"vite": "^4.5.3",
122124
"vite-tsconfig-paths": "^4.3.2"
123125
},

0 commit comments

Comments
 (0)