Skip to content

Commit 4e154e4

Browse files
Update to ESLint v9
1 parent 635813d commit 4e154e4

File tree

5 files changed

+1556
-551
lines changed

5 files changed

+1556
-551
lines changed

.eslintignore

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

.eslintrc.js

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

eslint.config.mjs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
parserOptions: {
28+
ecmaVersion: 'latest',
29+
projectService: true,
30+
tsconfigRootDir: rootPath,
31+
},
32+
},
33+
settings: {
34+
'import/resolver': {
35+
node: true,
36+
typescript: true,
37+
},
38+
},
39+
},
40+
{
41+
files: ['**/*.{ts,tsx}'],
42+
extends: [
43+
pluginJsxA11y.flatConfigs.recommended,
44+
pluginReact.configs.flat.recommended,
45+
pluginReact.configs.flat['jsx-runtime'],
46+
'react-hooks/recommended-latest',
47+
],
48+
languageOptions: {
49+
globals: globals.browser,
50+
parserOptions: {
51+
ecmaFeatures: { jsx: true },
52+
sourceType: 'module',
53+
},
54+
},
55+
plugins: {
56+
'react-hooks': pluginReactHooks,
57+
},
58+
rules: {
59+
'react/prop-types': 0,
60+
'jsx-a11y/anchor-has-content': 0,
61+
'jsx-a11y/alt-text': 0,
62+
'jsx-a11y/heading-has-content': 0,
63+
'react-hooks/exhaustive-deps': 0,
64+
},
65+
settings: {
66+
react: {
67+
version: 'detect',
68+
},
69+
},
70+
},
71+
{
72+
files: ['**/*.{js,mjs}'],
73+
languageOptions: {
74+
globals: globals.node,
75+
},
76+
},
77+
{
78+
files: ['**/*.js'],
79+
rules: {
80+
'@typescript-eslint/no-require-imports': 'off',
81+
'@typescript-eslint/no-var-requires': 'off',
82+
},
83+
},
84+
{
85+
files: ['**/*.test.{ts,tsx}'],
86+
languageOptions: {
87+
globals: globals.jest,
88+
},
89+
},
90+
{
91+
files: ['**/*.stories.tsx'],
92+
rules: { '@typescript-eslint/no-unused-vars': 'off' },
93+
},
94+
globalIgnores(['**/coverage/', '**/dist/']),
95+
includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'),
96+
]);

package.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"lint:fix": "yarn lint:js:fix && yarn lint:prettier:fix",
5959
"lint:prettier": "prettier --check .",
6060
"lint:prettier:fix": "prettier --write .",
61-
"lint:js": "eslint 'src/**/*.{js,ts,tsx}' 'stories/**/*.{js,ts,tsx}'",
61+
"lint:js": "eslint .",
6262
"lint:js:fix": "yarn lint:js --fix",
6363
"lint:types": "tsc --build tsconfig.json --pretty",
6464
"build-storybook": "storybook build",
@@ -70,6 +70,8 @@
7070
"@babel/preset-env": "^7.28.3",
7171
"@babel/preset-react": "^7.27.1",
7272
"@babel/preset-typescript": "^7.27.1",
73+
"@eslint/compat": "^1.4.0",
74+
"@eslint/js": "^9.37.0",
7375
"@rollup/plugin-babel": "^6.0.4",
7476
"@rollup/plugin-commonjs": "^28.0.6",
7577
"@rollup/plugin-node-resolve": "^16.0.1",
@@ -83,25 +85,24 @@
8385
"@storybook/theming": "^8.0.5",
8486
"@testing-library/jest-dom": "^6.9.1",
8587
"@testing-library/react": "^14.2.1",
88+
"@types/eslint": "^9.6.1",
8689
"@types/jest": "^30.0.0",
8790
"@types/jest-axe": "^3.5.9",
8891
"@types/node": "^24.6.2",
8992
"@types/react": "^18.2.60",
9093
"@types/react-dom": "^18.2.19",
91-
"@typescript-eslint/eslint-plugin": "^7.1.0",
92-
"@typescript-eslint/parser": "^7.1.0",
9394
"babel-jest": "^30.2.0",
9495
"babel-plugin-module-resolver": "^5.0.2",
9596
"chromatic": "^6.17.3",
9697
"classnames": "^2.5.1",
97-
"eslint": "^8.57.0",
98-
"eslint-config-prettier": "^9.1.0",
99-
"eslint-import-resolver-typescript": "^3.6.1",
100-
"eslint-plugin-import": "^2.29.1",
101-
"eslint-plugin-jsx-a11y": "^6.8.0",
102-
"eslint-plugin-prettier": "^5.1.3",
103-
"eslint-plugin-react": "^7.33.2",
104-
"eslint-plugin-react-hooks": "^4.6.0",
98+
"eslint": "^9.37.0",
99+
"eslint-config-prettier": "^10.1.8",
100+
"eslint-import-resolver-typescript": "^4.4.4",
101+
"eslint-plugin-import": "^2.32.0",
102+
"eslint-plugin-jsx-a11y": "^6.10.2",
103+
"eslint-plugin-react": "^7.37.5",
104+
"eslint-plugin-react-hooks": "^6.1.0",
105+
"globals": "^16.4.0",
105106
"jest": "^30.2.0",
106107
"jest-axe": "^10.0.0",
107108
"jest-environment-jsdom": "^30.2.0",
@@ -115,6 +116,7 @@
115116
"storybook": "^8.0.5",
116117
"tslib": "^2.8.1",
117118
"typescript": "5.3.3",
119+
"typescript-eslint": "^8.45.0",
118120
"vite": "^4.5.3",
119121
"vite-tsconfig-paths": "^4.3.2"
120122
},

0 commit comments

Comments
 (0)