Skip to content

Commit 1791b5e

Browse files
committed
Use the shareable ESLint config
1 parent 5ad19da commit 1791b5e

File tree

11 files changed

+188
-784
lines changed

11 files changed

+188
-784
lines changed

.eslintrc.js

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

.gitignore

Lines changed: 2 additions & 1 deletion
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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
23+
files: ['**/*.?(c|m)[jt]s?(x)'],
24+
25+
languageOptions: {
26+
parserOptions: {
27+
projectService: true,
28+
tsconfigRootDir: import.meta.dirname,
29+
},
30+
},
31+
rules: {
32+
// TODO: Enable this later.
33+
'@typescript-eslint/consistent-type-definitions': [0, 'type'],
34+
'@typescript-eslint/prefer-nullish-coalescing': [0],
35+
'@typescript-eslint/no-namespace': [0],
36+
'@typescript-eslint/require-await': [0],
37+
'@typescript-eslint/unified-signatures': [0],
38+
'@typescript-eslint/no-unnecessary-type-parameters': [0],
39+
'@typescript-eslint/no-invalid-void-type': [0],
40+
'@typescript-eslint/no-unnecessary-type-arguments': [0],
41+
'@typescript-eslint/no-confusing-void-expression': [0],
42+
'@typescript-eslint/no-duplicate-type-constituents': [0],
43+
'@typescript-eslint/no-redundant-type-constituents': [0],
44+
'@typescript-eslint/no-unnecessary-type-assertion': [0],
45+
'object-shorthand': [0],
46+
'@typescript-eslint/no-explicit-any': [
47+
0,
48+
{
49+
fixToUnknown: false,
50+
ignoreRestArgs: false,
51+
},
52+
],
53+
},
54+
},
55+
56+
{
57+
name: `${basename}/vitest-custom-matchers-declaration-file`,
58+
files: ['packages/toolkit/src/tests/utils/CustomMatchers.d.ts'],
59+
rules: {
60+
'@typescript-eslint/no-empty-object-type': [
61+
2,
62+
{
63+
allowInterfaces: 'with-single-extends',
64+
allowObjectTypes: 'never',
65+
},
66+
],
67+
},
68+
},
69+
70+
{
71+
name: `${basename}/no-require-imports`,
72+
files: ['examples/query/react/graphql-codegen/src/mocks/schema.js'],
73+
languageOptions: {
74+
sourceType: 'commonjs',
75+
},
76+
rules: {
77+
'@typescript-eslint/no-require-imports': [
78+
2,
79+
{
80+
allow: ['ts-node', '\\./db(.c?[tj]s)?$'],
81+
allowAsImport: false,
82+
},
83+
],
84+
},
85+
},
86+
87+
{
88+
name: `${basename}/examples/type-portability/nodenext-cjs`,
89+
files: ['examples/type-portability/nodenext-cjs/**/*.?(c)ts?(x)'],
90+
languageOptions: {
91+
sourceType: 'commonjs',
92+
},
93+
rules: {
94+
'@typescript-eslint/no-namespace': [
95+
0,
96+
{
97+
allowDeclarations: false,
98+
allowDefinitionFiles: true,
99+
},
100+
],
101+
},
102+
},
103+
])
104+
105+
export default eslintConfig

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

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

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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 8 additions & 12 deletions
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.31.1"
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

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

packages/rtk-codemods/package.json

Lines changed: 5 additions & 6 deletions
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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@babel/helper-module-imports": "^7.24.7",
5555
"@microsoft/api-extractor": "^7.13.2",
5656
"@phryneas/ts-version": "^1.0.2",
57+
"@reduxjs/eslint-config": "workspace:^",
5758
"@reduxjs/prettier-config": "workspace:^",
5859
"@size-limit/file": "^11.0.1",
5960
"@size-limit/webpack": "^11.0.1",
@@ -70,22 +71,13 @@
7071
"@types/react": "^19.0.1",
7172
"@types/react-dom": "^19.0.1",
7273
"@types/yargs": "^16.0.1",
73-
"@typescript-eslint/eslint-plugin": "^6",
74-
"@typescript-eslint/parser": "^6",
7574
"axios": "^0.19.2",
7675
"esbuild": "^0.25.1",
7776
"esbuild-extra": "^0.4.0",
78-
"eslint": "^7.25.0",
79-
"eslint-config-prettier": "^9.1.0",
80-
"eslint-config-react-app": "^7.0.1",
81-
"eslint-plugin-flowtype": "^5.7.2",
82-
"eslint-plugin-import": "^2.22.1",
83-
"eslint-plugin-jsx-a11y": "^6.4.1",
84-
"eslint-plugin-prettier": "^5.1.3",
85-
"eslint-plugin-react": "^7.23.2",
86-
"eslint-plugin-react-hooks": "^4.2.0",
77+
"eslint": "^9.26.0",
8778
"fs-extra": "^9.1.0",
8879
"invariant": "^2.2.4",
80+
"jiti": "^2.4.2",
8981
"jsdom": "^25.0.1",
9082
"json-stringify-safe": "^5.0.1",
9183
"msw": "^2.1.4",
@@ -112,7 +104,8 @@
112104
"build-only": "yarn clean && yarn run-build",
113105
"format-check": "yarn run -T format-check",
114106
"format": "yarn run -T format",
115-
"lint": "eslint src examples",
107+
"lint-fix": "yarn run -T lint-fix",
108+
"lint": "yarn run -T lint",
116109
"test": "vitest --typecheck --run ",
117110
"test:watch": "vitest --watch",
118111
"type-tests": "yarn tsc -p tsconfig.test.json --noEmit",

tsconfig.json

Lines changed: 17 additions & 0 deletions
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)