Skip to content

Commit 986221f

Browse files
committed
Use the shareable ESLint config
1 parent 4981076 commit 986221f

File tree

11 files changed

+187
-785
lines changed

11 files changed

+187
-785
lines changed

.eslintrc.js

-61
This file was deleted.

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ typesversions
3131
.pnp.*
3232
*.tgz
3333

34-
tsconfig.vitest-temp.json
34+
tsconfig.vitest-temp.json
35+
.eslintcache

eslint.config.mts

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { createESLintConfig } from '@reduxjs/eslint-config'
2+
import eslintConfigPackageJson from '@reduxjs/eslint-config/package.json' with { type: 'json' }
3+
4+
const basename = `${eslintConfigPackageJson.name}/overrides`
5+
6+
const eslintConfig = createESLintConfig([
7+
{
8+
name: `${basename}/global-ignores`,
9+
ignores: [
10+
'packages/rtk-codemods/transforms/*/__testfixtures__/',
11+
'packages/toolkit/.size-limit.cjs',
12+
'packages/rtk-query-codegen-openapi/test/config.example.js',
13+
'examples/publish-ci/',
14+
15+
// TODO: Remove this later.
16+
'examples/',
17+
],
18+
},
19+
20+
{
21+
name: `${basename}/main`,
22+
files: ['**/*.?(c|m)[jt]s?(x)'],
23+
languageOptions: {
24+
parserOptions: {
25+
projectService: true,
26+
tsconfigRootDir: import.meta.dirname,
27+
},
28+
},
29+
rules: {
30+
// TODO: Enable this later.
31+
'@typescript-eslint/consistent-type-definitions': [0, 'type'],
32+
'@typescript-eslint/prefer-nullish-coalescing': [0],
33+
'@typescript-eslint/no-namespace': [0],
34+
'@typescript-eslint/require-await': [0],
35+
'@typescript-eslint/unified-signatures': [0],
36+
'@typescript-eslint/no-unnecessary-type-parameters': [0],
37+
'@typescript-eslint/no-invalid-void-type': [0],
38+
'@typescript-eslint/no-unnecessary-type-arguments': [0],
39+
'@typescript-eslint/no-confusing-void-expression': [0],
40+
'@typescript-eslint/no-duplicate-type-constituents': [0],
41+
'@typescript-eslint/no-redundant-type-constituents': [0],
42+
'@typescript-eslint/no-unnecessary-type-assertion': [0],
43+
'object-shorthand': [0],
44+
'@typescript-eslint/no-explicit-any': [
45+
0,
46+
{
47+
fixToUnknown: false,
48+
ignoreRestArgs: false,
49+
},
50+
],
51+
},
52+
},
53+
54+
{
55+
name: `${basename}/vitest-custom-matchers-declaration-file`,
56+
files: ['packages/toolkit/src/tests/utils/CustomMatchers.d.ts'],
57+
rules: {
58+
'@typescript-eslint/no-empty-object-type': [
59+
2,
60+
{
61+
allowInterfaces: 'with-single-extends',
62+
allowObjectTypes: 'never',
63+
},
64+
],
65+
},
66+
},
67+
68+
{
69+
name: `${basename}/no-require-imports`,
70+
files: ['examples/query/react/graphql-codegen/src/mocks/schema.js'],
71+
languageOptions: {
72+
sourceType: 'commonjs',
73+
},
74+
rules: {
75+
'@typescript-eslint/no-require-imports': [
76+
2,
77+
{
78+
allow: ['ts-node', '\\./db(.c?[tj]s)?$'],
79+
allowAsImport: false,
80+
},
81+
],
82+
},
83+
},
84+
85+
{
86+
name: `${basename}/examples/type-portability/nodenext-cjs`,
87+
files: ['examples/type-portability/nodenext-cjs/**/*.?(c)ts?(x)'],
88+
languageOptions: {
89+
sourceType: 'commonjs',
90+
},
91+
rules: {
92+
'@typescript-eslint/no-namespace': [
93+
0,
94+
{
95+
allowDeclarations: false,
96+
allowDefinitionFiles: true,
97+
},
98+
],
99+
},
100+
},
101+
])
102+
103+
export default eslintConfig

examples/query/react/infinite-queries/.eslintrc.json

-35
This file was deleted.

examples/query/react/infinite-queries/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"test": "vitest run",
1212
"format-check": "yarn run -T format-check",
1313
"format": "yarn run -T format",
14-
"lint": "eslint .",
15-
"lint:fix": "eslint --fix .",
14+
"lint-fix": "yarn run -T lint-fix",
15+
"lint": "yarn run -T lint",
1616
"type-check": "tsc --noEmit"
1717
},
1818
"dependencies": {
@@ -25,6 +25,7 @@
2525
"react-router": "^7.0.1"
2626
},
2727
"devDependencies": {
28+
"@reduxjs/eslint-config": "workspace:^",
2829
"@reduxjs/prettier-config": "workspace:^",
2930
"@testing-library/dom": "^9.3.4",
3031
"@testing-library/jest-dom": "^6.2.0",
@@ -34,6 +35,8 @@
3435
"@types/react-dom": "18.3.1",
3536
"@types/react-native-web": "^0.19",
3637
"@vitejs/plugin-react": "^4.2.1",
38+
"eslint": "^9.26.0",
39+
"jiti": "^2.4.2",
3740
"jsdom": "^23.2.0",
3841
"msw": "^2.6.6",
3942
"prettier": "^3.5.3",

package.json

+8-12
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,13 @@
3131
"@babel/helper-compilation-targets": "^7.23.6",
3232
"@babel/traverse": "^7.24.1",
3333
"@babel/types": "^7.24.0",
34+
"@reduxjs/eslint-config": "workspace:^",
3435
"@reduxjs/prettier-config": "workspace:^",
36+
"@reduxjs/tsconfig": "workspace:^",
3537
"@types/react": "^19.0.1",
3638
"@types/react-dom": "^19.0.1",
37-
"@typescript-eslint/eslint-plugin": "6.12.0",
38-
"@typescript-eslint/parser": "6.12.0",
39-
"eslint": "^7.25.0",
40-
"eslint-config-prettier": "^9.1.0",
41-
"eslint-config-react-app": "^7.0.1",
42-
"eslint-plugin-flowtype": "^5.7.2",
43-
"eslint-plugin-import": "^2.22.1",
44-
"eslint-plugin-jsx-a11y": "^6.4.1",
45-
"eslint-plugin-prettier": "^5.1.3",
46-
"eslint-plugin-react": "^7.23.2",
47-
"eslint-plugin-react-hooks": "^4.2.0",
39+
"eslint": "^9.26.0",
40+
"jiti": "^2.4.2",
4841
"netlify-plugin-cache": "^1.0.3",
4942
"prettier": "^3.5.3",
5043
"react": "^19.0.0",
@@ -53,13 +46,16 @@
5346
"release-it": "^14.12.5",
5447
"serve": "^14.2.0",
5548
"ts-node": "^10.9.2",
56-
"typescript": "^5.8.2"
49+
"typescript": "^5.8.2",
50+
"typescript-eslint": "^8.32.0"
5751
},
5852
"scripts": {
5953
"build": "yarn build:packages",
6054
"test": "yarn test:packages",
6155
"format-check": "prettier --ignore-path=$PROJECT_CWD/.prettierignore --ignore-path=$PROJECT_CWD/.gitignore --config=$PROJECT_CWD/prettier.config.mjs --check $INIT_CWD",
6256
"format": "prettier --ignore-path=$PROJECT_CWD/.prettierignore --ignore-path=$PROJECT_CWD/.gitignore --config=$PROJECT_CWD/prettier.config.mjs --write $INIT_CWD",
57+
"lint-fix": "eslint --config=$PROJECT_CWD/eslint.config.mts --no-error-on-unmatched-pattern --fix $INIT_CWD",
58+
"lint": "eslint --config=$PROJECT_CWD/eslint.config.mts --no-error-on-unmatched-pattern $INIT_CWD",
6359
"postinstall": "yarn build-configs",
6460
"build-configs": "yarn workspaces foreach -Atip --include='packages/configs/*' run build",
6561
"build:examples": "yarn workspaces foreach -A --include '@reduxjs/*' --include '@examples-query-react/*' --include '@examples-action-listener/*' -vtp run build",

packages/rtk-codemods/.eslintrc.json

-11
This file was deleted.

packages/rtk-codemods/package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"scripts": {
55
"format-check": "yarn run -T format-check",
66
"format": "yarn run -T format",
7-
"lint": "eslint .",
7+
"lint-fix": "yarn run -T lint-fix",
8+
"lint": "yarn run -T lint",
89
"test": "vitest --run",
910
"test:watch": "vitest --watch",
1011
"test:coverage": "vitest --coverage"
@@ -31,13 +32,11 @@
3132
"typescript": "^5.8.2"
3233
},
3334
"devDependencies": {
35+
"@reduxjs/eslint-config": "workspace:^",
3436
"@reduxjs/prettier-config": "workspace:^",
3537
"@types/jscodeshift": "^0.11.11",
36-
"@typescript-eslint/parser": "^6.19.1",
37-
"eslint": "^8.56.0",
38-
"eslint-config-prettier": "^9.1.0",
39-
"eslint-plugin-node": "^11.1.0",
40-
"eslint-plugin-prettier": "^5.1.3",
38+
"eslint": "^9.26.0",
39+
"jiti": "^2.4.2",
4140
"prettier": "^3.5.3",
4241
"vitest": "^1.6.0"
4342
},

packages/toolkit/package.json

+5-12
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"@babel/helper-module-imports": "^7.24.7",
165165
"@microsoft/api-extractor": "^7.13.2",
166166
"@phryneas/ts-version": "^1.0.2",
167+
"@reduxjs/eslint-config": "workspace:^",
167168
"@reduxjs/prettier-config": "workspace:^",
168169
"@size-limit/file": "^11.0.1",
169170
"@size-limit/webpack": "^11.0.1",
@@ -180,22 +181,13 @@
180181
"@types/react": "^19.0.1",
181182
"@types/react-dom": "^19.0.1",
182183
"@types/yargs": "^16.0.1",
183-
"@typescript-eslint/eslint-plugin": "^6",
184-
"@typescript-eslint/parser": "^6",
185184
"axios": "^0.19.2",
186185
"esbuild": "^0.25.1",
187186
"esbuild-extra": "^0.4.0",
188-
"eslint": "^7.25.0",
189-
"eslint-config-prettier": "^9.1.0",
190-
"eslint-config-react-app": "^7.0.1",
191-
"eslint-plugin-flowtype": "^5.7.2",
192-
"eslint-plugin-import": "^2.22.1",
193-
"eslint-plugin-jsx-a11y": "^6.4.1",
194-
"eslint-plugin-prettier": "^5.1.3",
195-
"eslint-plugin-react": "^7.23.2",
196-
"eslint-plugin-react-hooks": "^4.2.0",
187+
"eslint": "^9.26.0",
197188
"fs-extra": "^9.1.0",
198189
"invariant": "^2.2.4",
190+
"jiti": "^2.4.2",
199191
"jsdom": "^25.0.1",
200192
"json-stringify-safe": "^5.0.1",
201193
"msw": "^2.1.4",
@@ -222,7 +214,8 @@
222214
"build-only": "yarn clean && yarn run-build",
223215
"format-check": "yarn run -T format-check",
224216
"format": "yarn run -T format",
225-
"lint": "eslint src examples",
217+
"lint-fix": "yarn run -T lint-fix",
218+
"lint": "yarn run -T lint",
226219
"test": "vitest --typecheck --run ",
227220
"test:watch": "vitest --watch",
228221
"type-tests": "yarn tsc -p tsconfig.test.json --noEmit",

tsconfig.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "@reduxjs/tsconfig/node-next/with-js",
3+
"compilerOptions": {
4+
"jsx": "react-jsx",
5+
"noEmit": true,
6+
"outDir": "./dist",
7+
"rootDir": "./"
8+
},
9+
"exclude": [
10+
"dist",
11+
"examples/publish-ci",
12+
"**/dist",
13+
"**/build",
14+
"**/lib",
15+
"**/__testfixtures__"
16+
]
17+
}

0 commit comments

Comments
 (0)