@zjutjh/eslint-config 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +14 -27
- package/package.json +38 -38
package/README.md
CHANGED
|
@@ -4,8 +4,21 @@ zjutjh 的 ESLint 配置,适用于 JS, TS, Vue3 等项目。
|
|
|
4
4
|
|
|
5
5
|
## 使用方式
|
|
6
6
|
|
|
7
|
+
> [!TIP]
|
|
8
|
+
> **For Agent**:可以通过 Skill 来接入
|
|
9
|
+
>
|
|
10
|
+
> ```sh
|
|
11
|
+
> # 推荐安装到项目本地。
|
|
12
|
+
> npx skills add zjutjh/eslint-config --skill setup-zjutjh-eslint
|
|
13
|
+
> ```
|
|
14
|
+
> 安装完成后,在对话里提及接入 zjutjh eslint config 即可触发
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
**For Human**
|
|
19
|
+
|
|
7
20
|
> [!IMPORTANT]
|
|
8
|
-
> ESLint 版本需要 ^
|
|
21
|
+
> ESLint 版本需要 ^10.0.0 以上,Node 版本需要 ^20.19.0 以上
|
|
9
22
|
|
|
10
23
|
```sh
|
|
11
24
|
# 确保你已经安装了 eslint
|
|
@@ -13,7 +26,7 @@ $ pnpm add -D eslint
|
|
|
13
26
|
|
|
14
27
|
$ pnpm add -D @zjutjh/eslint-config
|
|
15
28
|
|
|
16
|
-
# 如果你想使用 ts 编写配置文件,还需要安装 typescript, jiti 来帮助 eslint
|
|
29
|
+
# 如果你想使用 ts 编写配置文件,还需要安装 typescript, jiti 来帮助 eslint 解析配置。(Node 24 版本后不需要安装 jiti)
|
|
17
30
|
$ pnpm add -D typescript jiti
|
|
18
31
|
```
|
|
19
32
|
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { isPackageExists } from "local-pkg";
|
|
2
|
-
import
|
|
2
|
+
import importXPlugin, { flatConfigs } from "eslint-plugin-import-x";
|
|
3
3
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
4
4
|
import eslintJS from "@eslint/js";
|
|
5
5
|
import globals from "globals";
|
|
6
6
|
import uniconPlugin from "eslint-plugin-unicorn";
|
|
7
7
|
import pluginStylistic from "@stylistic/eslint-plugin";
|
|
8
|
-
|
|
9
8
|
//#region src/globs.ts
|
|
10
9
|
const GLOB_VUE = "**/*.vue";
|
|
11
10
|
const GLOB_JS = "**/*.?([cm])js";
|
|
@@ -55,7 +54,6 @@ const GLOBS_EXCLUDES = [
|
|
|
55
54
|
"**/auto-import?(s).d.ts",
|
|
56
55
|
"**/components.d.ts"
|
|
57
56
|
];
|
|
58
|
-
|
|
59
57
|
//#endregion
|
|
60
58
|
//#region src/configs/ignores.ts
|
|
61
59
|
function ignores(options) {
|
|
@@ -64,7 +62,6 @@ function ignores(options) {
|
|
|
64
62
|
ignores: [...GLOBS_EXCLUDES, ...options?.userIgnores ?? []]
|
|
65
63
|
}];
|
|
66
64
|
}
|
|
67
|
-
|
|
68
65
|
//#endregion
|
|
69
66
|
//#region src/configs/imports.ts
|
|
70
67
|
function imports() {
|
|
@@ -72,18 +69,18 @@ function imports() {
|
|
|
72
69
|
name: "zjutjh/imports/setup",
|
|
73
70
|
plugins: {
|
|
74
71
|
"simple-import-sort": simpleImportSortPlugin,
|
|
75
|
-
"import":
|
|
72
|
+
"import-x": importXPlugin
|
|
76
73
|
}
|
|
77
74
|
}, {
|
|
78
75
|
name: "zjutjh/imports/rules",
|
|
79
76
|
rules: {
|
|
80
77
|
"simple-import-sort/imports": "error",
|
|
81
78
|
"simple-import-sort/exports": "error",
|
|
82
|
-
|
|
79
|
+
...flatConfigs.recommended.rules,
|
|
80
|
+
"import-x/no-unresolved": "off"
|
|
83
81
|
}
|
|
84
82
|
}];
|
|
85
83
|
}
|
|
86
|
-
|
|
87
84
|
//#endregion
|
|
88
85
|
//#region src/configs/javascript.ts
|
|
89
86
|
function javascript() {
|
|
@@ -131,7 +128,6 @@ function javascript() {
|
|
|
131
128
|
}
|
|
132
129
|
}];
|
|
133
130
|
}
|
|
134
|
-
|
|
135
131
|
//#endregion
|
|
136
132
|
//#region src/configs/jsx.ts
|
|
137
133
|
function jsx() {
|
|
@@ -141,7 +137,6 @@ function jsx() {
|
|
|
141
137
|
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }
|
|
142
138
|
}];
|
|
143
139
|
}
|
|
144
|
-
|
|
145
140
|
//#endregion
|
|
146
141
|
//#region src/configs/misc.ts
|
|
147
142
|
function misc() {
|
|
@@ -153,7 +148,6 @@ function misc() {
|
|
|
153
148
|
rules: { "unicorn/filename-case": ["error", { "case": "kebabCase" }] }
|
|
154
149
|
}];
|
|
155
150
|
}
|
|
156
|
-
|
|
157
151
|
//#endregion
|
|
158
152
|
//#region src/utils.ts
|
|
159
153
|
async function interopDefault(m) {
|
|
@@ -175,7 +169,6 @@ function resolveSubOptions(options, key) {
|
|
|
175
169
|
function getOverrides(options, key) {
|
|
176
170
|
return { ...options.overrides?.[key] };
|
|
177
171
|
}
|
|
178
|
-
|
|
179
172
|
//#endregion
|
|
180
173
|
//#region src/configs/prettier.ts
|
|
181
174
|
/**
|
|
@@ -278,7 +271,6 @@ async function prettier(options) {
|
|
|
278
271
|
} : {}
|
|
279
272
|
];
|
|
280
273
|
}
|
|
281
|
-
|
|
282
274
|
//#endregion
|
|
283
275
|
//#region src/configs/react.ts
|
|
284
276
|
async function react(options) {
|
|
@@ -292,16 +284,10 @@ async function react(options) {
|
|
|
292
284
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
293
285
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
294
286
|
]);
|
|
295
|
-
const plugins = pluginReact.configs.all.plugins;
|
|
296
287
|
return [{
|
|
297
288
|
name: "zjutjh/react/setup",
|
|
298
289
|
plugins: {
|
|
299
|
-
"@eslint-react":
|
|
300
|
-
"@eslint-react/dom": plugins["@eslint-react/dom"],
|
|
301
|
-
"@eslint-react/hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
302
|
-
"@eslint-react/naming-convention": plugins["@eslint-react/naming-convention"],
|
|
303
|
-
"@eslint-react/rsc": plugins["@eslint-react/rsc"],
|
|
304
|
-
"@eslint-react/web-api": plugins["@eslint-react/web-api"],
|
|
290
|
+
"@eslint-react": pluginReact,
|
|
305
291
|
"react-hooks": pluginReactHooks,
|
|
306
292
|
"react-refresh": pluginReactRefresh
|
|
307
293
|
}
|
|
@@ -317,14 +303,12 @@ async function react(options) {
|
|
|
317
303
|
...pluginReact.configs.recommended.rules,
|
|
318
304
|
...pluginReactHooks.configs.recommended.rules,
|
|
319
305
|
"react-refresh/only-export-components": "warn",
|
|
320
|
-
"@eslint-react/no-leaked-conditional-rendering": "error",
|
|
321
306
|
"@eslint-react/no-missing-component-display-name": "error",
|
|
322
307
|
"@eslint-react/no-missing-context-display-name": "error",
|
|
323
308
|
...options.overrides
|
|
324
309
|
}
|
|
325
310
|
}];
|
|
326
311
|
}
|
|
327
|
-
|
|
328
312
|
//#endregion
|
|
329
313
|
//#region src/configs/stylistic.ts
|
|
330
314
|
function stylistic(options) {
|
|
@@ -364,7 +348,6 @@ function stylistic(options) {
|
|
|
364
348
|
}
|
|
365
349
|
}];
|
|
366
350
|
}
|
|
367
|
-
|
|
368
351
|
//#endregion
|
|
369
352
|
//#region src/configs/typescript.ts
|
|
370
353
|
async function typescript(options) {
|
|
@@ -400,6 +383,14 @@ async function typescript(options) {
|
|
|
400
383
|
files,
|
|
401
384
|
rules: {
|
|
402
385
|
...pluginTs.configs.strict.rules,
|
|
386
|
+
"@typescript-eslint/restrict-template-expressions": ["error", {
|
|
387
|
+
allowNumber: true,
|
|
388
|
+
allowBoolean: false,
|
|
389
|
+
allowAny: false,
|
|
390
|
+
allowNullish: false,
|
|
391
|
+
allowRegExp: false,
|
|
392
|
+
allowArray: false
|
|
393
|
+
}],
|
|
403
394
|
"@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
404
395
|
"@typescript-eslint/require-await": "error",
|
|
405
396
|
"@typescript-eslint/no-shadow": "error",
|
|
@@ -422,7 +413,6 @@ async function typescript(options) {
|
|
|
422
413
|
}
|
|
423
414
|
];
|
|
424
415
|
}
|
|
425
|
-
|
|
426
416
|
//#endregion
|
|
427
417
|
//#region src/configs/vue.ts
|
|
428
418
|
async function vue(options) {
|
|
@@ -469,7 +459,6 @@ async function vue(options) {
|
|
|
469
459
|
}
|
|
470
460
|
}];
|
|
471
461
|
}
|
|
472
|
-
|
|
473
462
|
//#endregion
|
|
474
463
|
//#region src/factory.ts
|
|
475
464
|
async function zjutjh(options = {}, ...userConfigs) {
|
|
@@ -494,10 +483,8 @@ async function zjutjh(options = {}, ...userConfigs) {
|
|
|
494
483
|
if (enablePrettier) configs.push(await prettier(codeStyleOptions));
|
|
495
484
|
return configs.flat(1).concat(userConfigs);
|
|
496
485
|
}
|
|
497
|
-
|
|
498
486
|
//#endregion
|
|
499
487
|
//#region src/index.ts
|
|
500
488
|
var src_default = zjutjh;
|
|
501
|
-
|
|
502
489
|
//#endregion
|
|
503
|
-
export { src_default as default };
|
|
490
|
+
export { src_default as default };
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zjutjh/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "zjutjh",
|
|
7
|
-
"description": "
|
|
7
|
+
"description": "ESLint config used by zjutjh",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"import": "./dist/index.
|
|
14
|
-
"types": "./dist/index.d.
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.mts"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
18
|
+
"node": ">=24"
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"simple-git-hooks": {
|
|
28
|
-
"pre-commit": "
|
|
28
|
+
"pre-commit": "pnpm lint-staged"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@eslint-react/eslint-plugin": "^2.
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
33
|
-
"@typescript-eslint/parser": "^8.
|
|
34
|
-
"eslint": "^10.
|
|
31
|
+
"@eslint-react/eslint-plugin": "^4.2.3",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
33
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
34
|
+
"eslint": "^10.2.1",
|
|
35
35
|
"eslint-config-prettier": "^10.1.8",
|
|
36
|
-
"eslint-plugin-format": "^
|
|
36
|
+
"eslint-plugin-format": "^2.0.1",
|
|
37
37
|
"eslint-plugin-prettier": "^5.5.5",
|
|
38
|
-
"eslint-plugin-react-hooks": "^7.
|
|
39
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
38
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
39
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
40
40
|
"eslint-plugin-vue": "^10.8.0",
|
|
41
|
-
"prettier": "^3.8.
|
|
41
|
+
"prettier": "^3.8.3",
|
|
42
42
|
"vue-eslint-parser": "^10.4.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
@@ -78,41 +78,41 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@antfu/install-pkg": "^1.1.0",
|
|
81
|
-
"@clack/prompts": "^1.0
|
|
82
|
-
"@eslint/js": "^
|
|
83
|
-
"@stylistic/eslint-plugin": "^5.
|
|
84
|
-
"eslint-plugin-import": "^
|
|
85
|
-
"eslint-plugin-simple-import-sort": "^
|
|
86
|
-
"eslint-plugin-unicorn": "^
|
|
87
|
-
"globals": "^17.
|
|
81
|
+
"@clack/prompts": "^1.2.0",
|
|
82
|
+
"@eslint/js": "^10.0.1",
|
|
83
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
84
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
85
|
+
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
86
|
+
"eslint-plugin-unicorn": "^64.0.0",
|
|
87
|
+
"globals": "^17.5.0",
|
|
88
88
|
"local-pkg": "^1.1.2"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@eslint-react/eslint-plugin": "^2.
|
|
92
|
-
"@eslint/config-inspector": "^
|
|
93
|
-
"@eslint/core": "^1.1
|
|
94
|
-
"@types/node": "^25.
|
|
95
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
96
|
-
"@typescript-eslint/parser": "^8.
|
|
97
|
-
"bumpp": "^
|
|
98
|
-
"cspell": "^
|
|
99
|
-
"eslint": "^10.
|
|
91
|
+
"@eslint-react/eslint-plugin": "^4.2.3",
|
|
92
|
+
"@eslint/config-inspector": "^2.0.0",
|
|
93
|
+
"@eslint/core": "^1.2.1",
|
|
94
|
+
"@types/node": "^25.6.0",
|
|
95
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
96
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
97
|
+
"bumpp": "^11.0.1",
|
|
98
|
+
"cspell": "^10.0.0",
|
|
99
|
+
"eslint": "^10.2.1",
|
|
100
100
|
"eslint-config-prettier": "^10.1.8",
|
|
101
|
-
"eslint-plugin-format": "^
|
|
101
|
+
"eslint-plugin-format": "^2.0.1",
|
|
102
102
|
"eslint-plugin-prettier": "^5.5.5",
|
|
103
|
-
"eslint-plugin-react-hooks": "^7.
|
|
104
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
103
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
104
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
105
105
|
"eslint-plugin-vue": "^10.8.0",
|
|
106
|
-
"
|
|
107
|
-
"prettier": "^3.8.
|
|
106
|
+
"lint-staged": "^16.4.0",
|
|
107
|
+
"prettier": "^3.8.3",
|
|
108
108
|
"simple-git-hooks": "^2.13.1",
|
|
109
|
-
"tsdown": "^0.
|
|
110
|
-
"typescript": "^
|
|
109
|
+
"tsdown": "^0.21.9",
|
|
110
|
+
"typescript": "^6.0.3",
|
|
111
111
|
"vue-eslint-parser": "^10.4.0"
|
|
112
112
|
},
|
|
113
113
|
"scripts": {
|
|
114
114
|
"build": "tsdown",
|
|
115
|
-
"lint": "eslint
|
|
115
|
+
"lint": "eslint",
|
|
116
116
|
"typecheck": "tsc --noEmit",
|
|
117
117
|
"dev": "config-inspector",
|
|
118
118
|
"release": "bumpp && pnpm publish --access public",
|