Skip to content

Commit df45777

Browse files
committed
feat: update eslint
1 parent beeadee commit df45777

24 files changed

+324
-132
lines changed

Diff for: .vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"editor.formatOnPaste": true, // optional
55
"editor.formatOnSave": true, // optional
66
"editor.formatOnSaveMode": "file", // required to format on save
7-
"files.autoSave": "afterDelay" // optional but recommended
7+
"files.autoSave": "afterDelay", // optional but recommended,
8+
"eslint.workingDirectories": [{ "pattern": "./apps/*/" }, { "pattern": "./packages/*/" }]
89
}

Diff for: apps/book-server/eslint.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {Linter.Config} */
47
export default [
5-
...baseConfig,
8+
...baseConfig(projectPath),
69
{
710
ignores: ['node_modules', 'books/*', 'dist'],
811
},

Diff for: apps/book-server/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
"@types/inquirer": "^9.0.7",
7777
"@types/jest": "^29.5.12",
7878
"@types/node": "^20.12.5",
79+
"@typescript-eslint/eslint-plugin": "^7.13.1",
80+
"@typescript-eslint/parser": "^7.6.0",
7981
"dotenv-cli": "^7.2.1",
8082
"eslint": "^9.5.0",
8183
"inquirer": "^9.2.23",

Diff for: apps/book-web/eslint.config.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import nextConfig from '@packages/eslint-config/next.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {import("eslint").Linter.Config} */
4-
export default [
5-
...nextConfig,
6-
{
7-
rules: {
8-
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
9-
},
10-
},
11-
]
7+
export default [...nextConfig(projectPath)]

Diff for: apps/cron/eslint.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {Linter.Config} */
47
export default [
5-
...baseConfig,
8+
...baseConfig(projectPath),
69
{
710
ignores: ['node_modules', 'dist'],
811
},

Diff for: apps/cron/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"@types/inquirer": "^9.0.3",
5454
"@types/jest": "^29.5.2",
5555
"@types/node": "^20.12.5",
56+
"@typescript-eslint/eslint-plugin": "^7.11.0",
57+
"@typescript-eslint/parser": "^7.6.0",
5658
"eslint": "^9.5.0",
5759
"nodemon": "^2.0.22",
5860
"ts-paths-esm-loader": "^1.4.3",

Diff for: apps/server/eslint.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {Linter.Config} */
47
export default [
5-
...baseConfig,
8+
...baseConfig(projectPath),
69
{
710
ignores: ['node_modules', 'dist'],
811
},

Diff for: apps/web/eslint.config.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import nextConfig from '@packages/eslint-config/next.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {import("eslint").Linter.Config} */
4-
export default [
5-
...nextConfig,
6-
{
7-
rules: {
8-
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
9-
},
10-
},
11-
]
7+
export default [...nextConfig(projectPath)]

Diff for: apps/web/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
"@types/react-dom": "18.2.6",
9090
"@types/sanitize-html": "^2.9.0",
9191
"@types/throttle-debounce": "^5.0.1",
92+
"@typescript-eslint/eslint-plugin": "^7.5.0",
93+
"@typescript-eslint/parser": "^7.6.0",
9294
"encoding": "^0.1.13",
9395
"eslint": "^9.5.0",
9496
"typescript": "^5.4.5",

Diff for: eslint.config.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const project = resolve(process.cwd())
25

36
/** @type {Linter.Config} */
47
export default [
5-
...baseConfig,
8+
...baseConfig(project),
69
{
710
ignores: [
811
'node_modules',

Diff for: packages/commonjs/eslint.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {Linter.Config} */
47
export default [
5-
...baseConfig,
8+
...baseConfig(projectPath),
69
{
710
ignores: ['node_modules', 'dist'],
811
},

Diff for: packages/commonjs/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
},
2525
"devDependencies": {
2626
"@types/node": "^20.14.0",
27+
"@typescript-eslint/eslint-plugin": "^7.13.1",
28+
"@typescript-eslint/parser": "^7.6.0",
2729
"eslint": "^9.5.0",
2830
"typescript": "^5.4.5"
2931
}

Diff for: packages/database/eslint.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
23

4+
const projectPath = resolve(process.cwd())
35
/** @type {Linter.Config} */
46
export default [
5-
...baseConfig,
7+
...baseConfig(projectPath),
68
{
79
ignores: ['node_modules', 'dist'],
810
},

Diff for: packages/database/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
"@types/inquirer": "^9.0.3",
5555
"@types/jest": "^29.5.3",
5656
"@types/node": "^20.12.5",
57+
"@typescript-eslint/eslint-plugin": "^7.13.1",
58+
"@typescript-eslint/parser": "^7.6.0",
5759
"eslint": "^9.5.0",
5860
"typescript": "^5.4.5"
5961
}

Diff for: packages/eslint-config/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"@typescript-eslint/parser": "^7.6.0",
2424
"eslint": "^9.5.0",
2525
"eslint-config-prettier": "^9.0.0",
26-
"eslint-plugin-react-hooks": "^4.6.2",
2726
"prettier": "^3.2.5",
2827
"typescript": "^5.4.5"
2928
}

Diff for: packages/eslint-config/src/base.mjs

+40-42
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1-
import { Linter } from 'eslint'
2-
import { resolve, dirname } from 'node:path'
3-
import { fileURLToPath } from 'node:url'
1+
import { resolve } from 'node:path'
42
import { FlatCompat } from '@eslint/eslintrc'
53
import js from '@eslint/js'
64

7-
const project = resolve(process.cwd(), 'tsconfig.json')
8-
const __filename = fileURLToPath(import.meta.url)
9-
const __dirname = dirname(__filename)
5+
const baseConfig = (projectPath) => {
6+
const tsconfigPath = resolve(projectPath, 'tsconfig.json')
107

11-
const compat = new FlatCompat({
12-
baseDirectory: __dirname,
13-
resolvePluginsRelativeTo: __dirname,
14-
recommendedConfig: js.configs.recommended,
15-
allConfig: js.configs.all,
16-
})
17-
18-
/** @type {Linter.Config} */
19-
export default [
20-
{
21-
ignores: ['node_modules'],
22-
},
23-
...compat.config({
24-
parser: '@typescript-eslint/parser',
25-
parserOptions: {
26-
project,
27-
sourceType: 'module',
28-
tsconfigRootDir: __dirname,
29-
},
30-
plugins: ['@typescript-eslint'],
31-
extends: ['plugin:@typescript-eslint/recommended'],
32-
root: true,
33-
env: {
34-
node: true,
35-
jest: true,
8+
const compat = new FlatCompat({
9+
baseDirectory: projectPath,
10+
resolvePluginsRelativeTo: projectPath,
11+
recommendedConfig: js.configs.recommended,
12+
allConfig: js.configs.all,
13+
})
14+
return [
15+
{
16+
ignores: ['node_modules'],
3617
},
37-
rules: {
38-
'@typescript-eslint/interface-name-prefix': 'off',
39-
'@typescript-eslint/explicit-function-return-type': 'off',
40-
'@typescript-eslint/explicit-module-boundary-types': 'off',
41-
'@typescript-eslint/no-explicit-any': 'off',
42-
'@typescript-eslint/no-non-null-assertion': 'off',
43-
'@typescript-eslint/no-empty-interface': 'off',
44-
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
45-
},
46-
}),
47-
]
18+
...compat.config({
19+
parser: '@typescript-eslint/parser',
20+
parserOptions: {
21+
project: tsconfigPath,
22+
sourceType: 'module',
23+
tsconfigRootDir: projectPath,
24+
},
25+
plugins: ['@typescript-eslint'],
26+
extends: ['plugin:@typescript-eslint/recommended'],
27+
root: true,
28+
env: {
29+
node: true,
30+
jest: true,
31+
},
32+
rules: {
33+
'@typescript-eslint/interface-name-prefix': 'off',
34+
'@typescript-eslint/explicit-function-return-type': 'off',
35+
'@typescript-eslint/explicit-module-boundary-types': 'off',
36+
'@typescript-eslint/no-explicit-any': 'off',
37+
'@typescript-eslint/no-non-null-assertion': 'off',
38+
'@typescript-eslint/no-empty-interface': 'off',
39+
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
40+
},
41+
}),
42+
]
43+
}
44+
45+
export default baseConfig

Diff for: packages/eslint-config/src/next.mjs

+47-45
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,55 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
22
import { Linter } from 'eslint'
3-
import { resolve, dirname } from 'node:path'
4-
import { fileURLToPath } from 'node:url'
3+
import { resolve } from 'node:path'
54
import { FlatCompat } from '@eslint/eslintrc'
65
import js from '@eslint/js'
76

8-
const project = resolve(process.cwd(), 'tsconfig.json')
9-
const __filename = fileURLToPath(import.meta.url)
10-
const __dirname = dirname(__filename)
7+
/** @type {Linter.Config} */
8+
const nextConfig = (projectPath) => {
9+
const tsconfigPath = resolve(projectPath, 'tsconfig.json')
1110

12-
const compat = new FlatCompat({
13-
baseDirectory: __dirname,
14-
resolvePluginsRelativeTo: __dirname,
15-
recommendedConfig: js.configs.recommended,
16-
allConfig: js.configs.all,
17-
})
11+
const compat = new FlatCompat({
12+
baseDirectory: projectPath,
13+
resolvePluginsRelativeTo: projectPath,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all,
16+
})
1817

19-
/** @type {Linter.Config} */
20-
export default [
21-
{
22-
ignores: ['node_modules', '.next', '.out'],
23-
},
24-
...compat.config({
25-
parser: '@typescript-eslint/parser',
26-
parserOptions: {
27-
project,
28-
sourceType: 'module',
29-
tsconfigRootDir: __dirname,
30-
},
31-
plugins: ['@typescript-eslint', 'react-hooks'],
32-
extends: [
33-
'plugin:@typescript-eslint/eslint-recommended',
34-
'plugin:@typescript-eslint/recommended',
35-
'plugin:react-hooks/recommended',
36-
],
37-
root: true,
38-
globals: {
39-
React: true,
40-
JSX: true,
18+
return [
19+
{
20+
ignores: ['node_modules', '.next', '.out'],
4121
},
42-
env: {
43-
node: true,
44-
browser: true,
45-
},
46-
rules: {
47-
'@typescript-eslint/ban-types': 'off',
48-
'@typescript-eslint/no-explicit-any': 'off',
49-
'@typescript-eslint/no-unused-vars': 'warn',
50-
'@next/next/no-html-link-for-pages': 'off',
51-
},
52-
}),
53-
]
22+
...compat.config({
23+
parser: '@typescript-eslint/parser',
24+
parserOptions: {
25+
project: tsconfigPath,
26+
sourceType: 'module',
27+
tsconfigRootDir: projectPath,
28+
},
29+
plugins: ['@typescript-eslint'],
30+
extends: [
31+
'plugin:@typescript-eslint/eslint-recommended',
32+
'plugin:@typescript-eslint/recommended',
33+
// 'plugin:react-hooks/recommended', // not yey support eslint 9
34+
],
35+
root: true,
36+
globals: {
37+
React: true,
38+
JSX: true,
39+
},
40+
env: {
41+
node: true,
42+
browser: true,
43+
},
44+
rules: {
45+
'@typescript-eslint/ban-types': 'off',
46+
'@typescript-eslint/no-explicit-any': 'off',
47+
'@typescript-eslint/no-unused-vars': 'warn',
48+
'@next/next/no-html-link-for-pages': 'off',
49+
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
50+
},
51+
}),
52+
]
53+
}
54+
55+
export default nextConfig

Diff for: packages/library/eslint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import baseConfig from '@packages/eslint-config/base.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {Linter.Config} */
47
export default [

Diff for: packages/library/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
"@types/jest": "^29.5.12",
6060
"@types/jsonwebtoken": "^9.0.2",
6161
"@types/nanoid-dictionary": "^4.2.3",
62+
"@typescript-eslint/eslint-plugin": "^7.13.1",
63+
"@typescript-eslint/parser": "^7.6.0",
6264
"eslint": "^9.5.0",
6365
"tsx": "^4.7.2",
6466
"typescript": "^5.4.5"

Diff for: packages/nextra-editor/eslint.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import nextConfig from '@packages/eslint-config/next.mjs'
2+
import { resolve } from 'node:path'
3+
4+
const projectPath = resolve(process.cwd())
25

36
/** @type {import("eslint").Linter.Config} */
47
export default [
5-
...nextConfig,
8+
...nextConfig(projectPath),
69
{
710
ignores: ['node_modules', 'dist', 'style.css'],
811
},

Diff for: packages/nextra-editor/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
"@types/react": "^18.2.21",
107107
"@types/react-dom": "^18.2.7",
108108
"@types/title": "^3.4.3",
109+
"@typescript-eslint/eslint-plugin": "^7.5.0",
110+
"@typescript-eslint/parser": "^7.6.0",
109111
"@vitejs/plugin-react": "^4.1.0",
110112
"concurrently": "^8.0.0",
111113
"eslint": "^9.5.0",

0 commit comments

Comments
 (0)