Skip to content

Commit abe3958

Browse files
committed
Migrate eslintrc.js to eslint.config.mjs
Ran `yarn dlx @eslint/migrate-config .eslintrc.js` and `yarn add @eslint/compat globals @eslint/js @eslint/eslintrc -D`.
1 parent 35aec06 commit abe3958

File tree

3 files changed

+141
-1
lines changed

3 files changed

+141
-1
lines changed

eslint.config.mjs

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import typescriptEslint from '@typescript-eslint/eslint-plugin'
2+
import tsParser from '@typescript-eslint/parser'
3+
import path from 'node:path'
4+
import { fileURLToPath } from 'node:url'
5+
6+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
7+
import { FlatCompat } from '@eslint/eslintrc'
8+
import js from '@eslint/js'
9+
import _import from 'eslint-plugin-import'
10+
import jest from 'eslint-plugin-jest'
11+
import react from 'eslint-plugin-react'
12+
import reactHooks from 'eslint-plugin-react-hooks'
13+
import globals from 'globals'
14+
15+
const __filename = fileURLToPath(import.meta.url)
16+
const __dirname = path.dirname(__filename)
17+
const compat = new FlatCompat({
18+
baseDirectory: __dirname,
19+
recommendedConfig: js.configs.recommended,
20+
allConfig: js.configs.all,
21+
})
22+
23+
export default [
24+
{ ignores: ['apps/*/build/', 'packages/*/dist/'] },
25+
...fixupConfigRules(
26+
compat.extends(
27+
'eslint:recommended',
28+
'plugin:react/recommended',
29+
'plugin:@typescript-eslint/recommended',
30+
'plugin:jest/recommended',
31+
'plugin:jest/style',
32+
'plugin:react/jsx-runtime',
33+
'plugin:react-hooks/recommended',
34+
'prettier',
35+
),
36+
),
37+
{
38+
plugins: {
39+
'@typescript-eslint': fixupPluginRules(typescriptEslint),
40+
import: fixupPluginRules(_import),
41+
jest: fixupPluginRules(jest),
42+
react: fixupPluginRules(react),
43+
'react-hooks': fixupPluginRules(reactHooks),
44+
},
45+
46+
languageOptions: {
47+
globals: { ...globals.browser },
48+
49+
parser: tsParser,
50+
ecmaVersion: 2021,
51+
sourceType: 'module',
52+
53+
parserOptions: { ecmaFeatures: { jsx: true } },
54+
},
55+
56+
settings: { react: { version: 'detect' } },
57+
58+
rules: {
59+
'no-unused-vars': 'off',
60+
'@typescript-eslint/no-empty-function': 'off',
61+
'@typescript-eslint/no-empty-interface': 'warn',
62+
63+
'@typescript-eslint/no-unused-vars': [
64+
'warn',
65+
{ argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_', varsIgnorePattern: '^_' },
66+
],
67+
68+
'arrow-body-style': ['warn', 'as-needed'],
69+
curly: ['warn', 'all'],
70+
eqeqeq: ['warn', 'always'],
71+
72+
'import/order': [
73+
'warn',
74+
{
75+
groups: [
76+
['builtin', 'external'],
77+
['internal'],
78+
['parent'],
79+
['sibling', 'index'],
80+
['object', 'type'],
81+
['unknown'],
82+
],
83+
84+
'newlines-between': 'always',
85+
warnOnUnassignedImports: true,
86+
87+
alphabetize: { order: 'asc' },
88+
89+
pathGroups: [
90+
{
91+
pattern: '?(react|react-dom|react-dom/client)',
92+
group: 'builtin',
93+
position: 'before',
94+
},
95+
{ pattern: './*.css', group: 'unknown', position: 'after' },
96+
],
97+
98+
pathGroupsExcludedImportTypes: ['react', 'react-dom'],
99+
},
100+
],
101+
102+
'jest/no-disabled-tests': 'warn',
103+
'jest/no-focused-tests': 'warn',
104+
'jest/no-identical-title': 'warn',
105+
'jest/prefer-to-have-length': 'warn',
106+
'jest/valid-expect': 'warn',
107+
'react/display-name': 'off',
108+
'react/no-unescaped-entities': 'off',
109+
110+
'sort-imports': ['warn', { ignoreDeclarationSort: true }],
111+
},
112+
},
113+
]

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
]
5555
},
5656
"devDependencies": {
57+
"@eslint/compat": "^1.2.7",
58+
"@eslint/eslintrc": "^3.3.0",
59+
"@eslint/js": "^9.22.0",
5760
"@rollup/plugin-typescript": "^12.1.2",
5861
"@typescript-eslint/eslint-plugin": "^8.26.1",
5962
"@typescript-eslint/parser": "^8.26.1",
@@ -63,6 +66,7 @@
6366
"eslint-plugin-jest": "28.11.0",
6467
"eslint-plugin-react": "^7.37.4",
6568
"eslint-plugin-react-hooks": "^5.2.0",
69+
"globals": "^16.0.0",
6670
"prettier": "^3.5.3",
6771
"tslib": "^2.8.1",
6872
"typescript": "^5.8.2"

yarn.lock

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,18 @@ __metadata:
19831983
languageName: node
19841984
linkType: hard
19851985

1986+
"@eslint/compat@npm:^1.2.7":
1987+
version: 1.2.7
1988+
resolution: "@eslint/compat@npm:1.2.7"
1989+
peerDependencies:
1990+
eslint: ^9.10.0
1991+
peerDependenciesMeta:
1992+
eslint:
1993+
optional: true
1994+
checksum: 10/fad83a195864d6718ce523acc30fd56c6cb0838394fc5ddb8f7a91031b1669bb5d8627d3e90bb2f86568b3c452ddcc22a90f0d15edd76dcccf4c49617cb567cb
1995+
languageName: node
1996+
linkType: hard
1997+
19861998
"@eslint/config-array@npm:^0.19.2":
19871999
version: 0.19.2
19882000
resolution: "@eslint/config-array@npm:0.19.2"
@@ -2044,7 +2056,7 @@ __metadata:
20442056
languageName: node
20452057
linkType: hard
20462058

2047-
"@eslint/js@npm:9.22.0":
2059+
"@eslint/js@npm:9.22.0, @eslint/js@npm:^9.22.0":
20482060
version: 9.22.0
20492061
resolution: "@eslint/js@npm:9.22.0"
20502062
checksum: 10/2d7725f29ee4a7c85f5b5c499945d60f7701877b41b580d3f7badef43901ac98e4f8f76e4cfaef9ba116966c5f7b67132161e31e02f2eeccb0d09b548f6ea1b2
@@ -8539,6 +8551,13 @@ __metadata:
85398551
languageName: node
85408552
linkType: hard
85418553

8554+
"globals@npm:^16.0.0":
8555+
version: 16.0.0
8556+
resolution: "globals@npm:16.0.0"
8557+
checksum: 10/aa05d569af9c763d9982e6885f3ac6d21c84cd54c9a12eeace55b3334d0631128f189902d34ae2a924694311f92d700dbd3e8e62e8a9e1094a882f9f8897149a
8558+
languageName: node
8559+
linkType: hard
8560+
85428561
"globalthis@npm:^1.0.4":
85438562
version: 1.0.4
85448563
resolution: "globalthis@npm:1.0.4"
@@ -13647,6 +13666,9 @@ __metadata:
1364713666
version: 0.0.0-use.local
1364813667
resolution: "react-hook-tracer-root@workspace:."
1364913668
dependencies:
13669+
"@eslint/compat": "npm:^1.2.7"
13670+
"@eslint/eslintrc": "npm:^3.3.0"
13671+
"@eslint/js": "npm:^9.22.0"
1365013672
"@rollup/plugin-typescript": "npm:^12.1.2"
1365113673
"@typescript-eslint/eslint-plugin": "npm:^8.26.1"
1365213674
"@typescript-eslint/parser": "npm:^8.26.1"
@@ -13656,6 +13678,7 @@ __metadata:
1365613678
eslint-plugin-jest: "npm:28.11.0"
1365713679
eslint-plugin-react: "npm:^7.37.4"
1365813680
eslint-plugin-react-hooks: "npm:^5.2.0"
13681+
globals: "npm:^16.0.0"
1365913682
prettier: "npm:^3.5.3"
1366013683
tslib: "npm:^2.8.1"
1366113684
typescript: "npm:^5.8.2"

0 commit comments

Comments
 (0)