Skip to content

Commit cecec03

Browse files
chore: update eslint to v9 and replace eslint config files
1 parent b512a85 commit cecec03

File tree

38 files changed

+632
-952
lines changed

38 files changed

+632
-952
lines changed

.eslintignore

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

.eslintrc.base.js

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

.eslintrc.js

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

eslint.config.js

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
const globals = require("globals");
2+
const react = require("eslint-plugin-react");
3+
const jest = require("eslint-plugin-jest");
4+
const tsParser = require("@typescript-eslint/parser");
5+
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
6+
const js = require("@eslint/js");
7+
const importPlugin = require("eslint-plugin-import");
8+
const jsxA11y = require("eslint-plugin-jsx-a11y");
9+
const prettier = require("eslint-plugin-prettier");
10+
11+
module.exports = [
12+
js.configs.recommended,
13+
{
14+
files: ["**/*.{js,jsx}"],
15+
languageOptions: {
16+
globals: {
17+
...globals.browser,
18+
...globals.jest,
19+
},
20+
ecmaVersion: 13,
21+
sourceType: "module",
22+
parserOptions: {
23+
ecmaFeatures: {
24+
jsx: true,
25+
},
26+
},
27+
},
28+
plugins: {
29+
react,
30+
jest,
31+
import: importPlugin,
32+
"jsx-a11y": jsxA11y,
33+
prettier,
34+
},
35+
settings: {
36+
react: {
37+
version: "detect",
38+
},
39+
"import/resolver": {
40+
node: {
41+
extensions: [".js", ".jsx", ".ts", ".tsx"],
42+
},
43+
},
44+
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
45+
},
46+
rules: {
47+
// React rules
48+
"react/function-component-definition": "off",
49+
"react/jsx-filename-extension": "off",
50+
"react/jsx-no-constructed-context-values": "off",
51+
"react/jsx-no-useless-fragment": "off",
52+
"react/require-default-props": "off",
53+
"react/jsx-props-no-spreading": "off",
54+
55+
// Import rules
56+
"import/no-relative-packages": "off",
57+
"import/prefer-default-export": "off",
58+
"import/no-extraneous-dependencies": ["error", {
59+
devDependencies: true,
60+
}],
61+
"import/no-relative-path-imports": "off",
62+
"import/no-absolute-path": "off",
63+
64+
// JSX A11y rules
65+
"jsx-a11y/control-has-associated-label": "off",
66+
"jsx-a11y/label-has-associated-control": "off", // Disabled due to too many false positives
67+
68+
// General rules
69+
"no-restricted-exports": "off",
70+
"no-unsafe-optional-chaining": "off",
71+
"no-promise-executor-return": "off",
72+
"default-param-last": "off",
73+
"dot-notation": "off",
74+
"no-console": 1,
75+
"no-unused-vars": ["warn", {
76+
argsIgnorePattern: "^_",
77+
varsIgnorePattern: "^(React|_)",
78+
}],
79+
"no-undef": "off", // Disable for config files and test files
80+
81+
// Import rules - disable problematic ones
82+
"import/no-extraneous-dependencies": "off",
83+
84+
// Prettier
85+
"prettier/prettier": ["error", {}, {
86+
usePrettierrc: true,
87+
}],
88+
},
89+
},
90+
{
91+
files: ["**/*.{ts,tsx}"],
92+
languageOptions: {
93+
parser: tsParser,
94+
globals: {
95+
...globals.browser,
96+
...globals.jest,
97+
},
98+
ecmaVersion: 13,
99+
sourceType: "module",
100+
parserOptions: {
101+
ecmaFeatures: {
102+
jsx: true,
103+
},
104+
},
105+
},
106+
plugins: {
107+
react,
108+
jest,
109+
"@typescript-eslint": typescriptEslint,
110+
import: importPlugin,
111+
"jsx-a11y": jsxA11y,
112+
prettier,
113+
},
114+
settings: {
115+
react: {
116+
version: "detect",
117+
},
118+
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
119+
"import/parsers": {
120+
"@typescript-eslint/parser": [".ts", ".tsx"],
121+
},
122+
"import/resolver": {
123+
node: {
124+
extensions: [".js", ".jsx", ".ts", ".tsx"],
125+
},
126+
},
127+
},
128+
rules: {
129+
// Inherit JS rules
130+
...js.configs.recommended.rules,
131+
132+
// TypeScript specific rules
133+
"import/extensions": ["error", "ignorePackages", {
134+
js: "never",
135+
jsx: "never",
136+
ts: "never",
137+
tsx: "never",
138+
}],
139+
"import/prefer-default-export": "off",
140+
"react/jsx-filename-extension": ["error", {
141+
extensions: [".js", ".jsx", ".ts", ".tsx"],
142+
}],
143+
"@typescript-eslint/ban-ts-comment": ["warn"],
144+
"no-unused-vars": "off",
145+
"react/require-default-props": "off",
146+
"@typescript-eslint/no-unused-vars": ["error", {
147+
argsIgnorePattern: "^_",
148+
varsIgnorePattern: "^(React|_)",
149+
}],
150+
"@typescript-eslint/no-empty-function": "off",
151+
152+
// Re-apply common rules for TypeScript files
153+
"react/function-component-definition": "off",
154+
"import/no-relative-packages": "off",
155+
"jsx-a11y/control-has-associated-label": "off",
156+
"react/jsx-no-constructed-context-values": "off",
157+
"no-restricted-exports": "off",
158+
"react/jsx-no-useless-fragment": "off",
159+
"no-unsafe-optional-chaining": "off",
160+
"no-promise-executor-return": "off",
161+
"default-param-last": "off",
162+
"react/jsx-props-no-spreading": "off",
163+
"prettier/prettier": ["error", {}, {
164+
usePrettierrc: true,
165+
}],
166+
"dot-notation": "off",
167+
"no-console": 1,
168+
"import/no-extraneous-dependencies": ["error", {
169+
devDependencies: true,
170+
}],
171+
"import/no-relative-path-imports": "off",
172+
"jsx-a11y/label-has-associated-control": "off", // Disabled due to too many false positives
173+
"import/no-absolute-path": "off",
174+
},
175+
},
176+
{
177+
ignores: [
178+
"**/node_modules",
179+
"**/build",
180+
"**/dist",
181+
"**/lib",
182+
"**/esm",
183+
"**/*.spec.ts",
184+
"**/*spec.ts",
185+
"**/*.d.ts",
186+
"**/graphql-schema.ts",
187+
"vite.config.*"
188+
],
189+
},
190+
];

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
"@commitlint/cli": "^19.7.1",
4949
"@commitlint/config-conventional": "^19.7.1",
5050
"@commitlint/config-lerna-scopes": "^19.7.0",
51+
"@eslint/compat": "^1.3.1",
52+
"@eslint/eslintrc": "^3.3.1",
53+
"@eslint/js": "^9.29.0",
5154
"@semantic-release/changelog": "^6.0.3",
5255
"@semantic-release/git": "^10.0.1",
5356
"@storybook/addons": "^7.6.14",
@@ -67,17 +70,19 @@
6770
"css-minimizer-webpack-plugin": "^2.0.0",
6871
"cz-conventional-changelog": "^3.3.0",
6972
"dompurify": "^3.2.4",
70-
"eslint": "^8",
73+
"eslint": "^9",
7174
"eslint-config-airbnb": "^19.0.4",
7275
"eslint-config-prettier": "^8.2.0",
7376
"eslint-plugin-import": "^2.22.1",
7477
"eslint-plugin-import-helpers": "^1.1.0",
7578
"eslint-plugin-jest": "^28",
7679
"eslint-plugin-jsx-a11y": "^6.10.2",
77-
"eslint-plugin-prettier": "^3.4.0",
80+
"eslint-plugin-prettier": "^5.5.1",
7881
"eslint-plugin-react": "^7.37.4",
7982
"eslint-plugin-react-hooks": "^4",
83+
"eslint-plugin-storybook": "^9.0.13",
8084
"gh-pages": "^6.0.0",
85+
"globals": "^16.2.0",
8186
"husky": "^6.0.0",
8287
"inquirer": "^8.0.0",
8388
"inquirer-autocomplete-prompt": "^2.0.0",

0 commit comments

Comments
 (0)