@tofrankie/eslint 0.0.21 → 0.0.23
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/CHANGELOG.md +10 -0
- package/README.md +0 -8
- package/dist/index.cjs +130 -65
- package/dist/index.mjs +130 -65
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## eslint@0.0.23 (2026-04-07)
|
|
4
|
+
|
|
5
|
+
- Fix `style/object-curly-spacing` rule name
|
|
6
|
+
|
|
7
|
+
## eslint@0.0.22 (2026-04-07)
|
|
8
|
+
|
|
9
|
+
- Fix lessOpinionated preset detection logic
|
|
10
|
+
- Disable `unused-imports/no-unused-vars` rule, use `no-unused-vars` / `ts/no-unused-vars` instead
|
|
11
|
+
- Update dependencies
|
|
12
|
+
|
|
3
13
|
## eslint@0.0.21 (2026-04-07)
|
|
4
14
|
|
|
5
15
|
- Fix `pnpm` detection logic
|
package/README.md
CHANGED
|
@@ -125,14 +125,6 @@ export default defineConfig({
|
|
|
125
125
|
JSDoc stays on antfu's built-in integration; this package layers rule and settings overrides without registering the `jsdoc` plugin twice. Details: [JSDoc strategy](./docs/jsdoc-strategy.md).
|
|
126
126
|
-->
|
|
127
127
|
|
|
128
|
-
## Unused variables
|
|
129
|
-
|
|
130
|
-
With default options:
|
|
131
|
-
|
|
132
|
-
- `.js` — `unused-imports/no-unused-vars`
|
|
133
|
-
- `.ts` — `ts/no-unused-vars`
|
|
134
|
-
- Vue SFCs with TypeScript `<script>` — `ts/no-unused-vars`
|
|
135
|
-
|
|
136
128
|
## WeChat miniprogram
|
|
137
129
|
|
|
138
130
|
`MINIPROGRAM_LANGUAGE_OPTIONS` exposes common miniprogram globals for an extra flat item:
|
package/dist/index.cjs
CHANGED
|
@@ -27,62 +27,122 @@ let eslint_plugin_jsdoc = require("eslint-plugin-jsdoc");
|
|
|
27
27
|
let defu = require("defu");
|
|
28
28
|
let find_up_simple = require("find-up-simple");
|
|
29
29
|
let local_pkg = require("local-pkg");
|
|
30
|
+
//#region src/presets/antfu.ts
|
|
31
|
+
/**
|
|
32
|
+
* - rule: `antfu/*`
|
|
33
|
+
* - plugin: `eslint-plugin-antfu`
|
|
34
|
+
* @see https://github.com/antfu/eslint-config#top-level-function-style-etc
|
|
35
|
+
* @see https://github.com/antfu/eslint-plugin-antfu
|
|
36
|
+
*/
|
|
37
|
+
const ANTFU_LESS_OPINIONATED_RULES = {
|
|
38
|
+
"antfu/consistent-list-newline": "off",
|
|
39
|
+
"antfu/if-newline": "off"
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
30
42
|
//#region src/presets/e18e.ts
|
|
31
|
-
|
|
43
|
+
/**
|
|
44
|
+
* - rule: `e18e/*`
|
|
45
|
+
* - plugin: `@e18e/eslint-plugin`
|
|
46
|
+
* @see https://github.com/e18e/eslint-plugin
|
|
47
|
+
*/
|
|
48
|
+
const E18E_RULES = {
|
|
32
49
|
"e18e/ban-dependencies": "off",
|
|
33
50
|
"e18e/prefer-array-to-sorted": "off",
|
|
34
51
|
"e18e/prefer-static-regex": "off"
|
|
35
52
|
};
|
|
36
53
|
//#endregion
|
|
37
54
|
//#region src/presets/eslint-comments.ts
|
|
38
|
-
|
|
55
|
+
/**
|
|
56
|
+
* - rule: `eslint-comments/*`
|
|
57
|
+
* - plugin: `eslint-plugin-eslint-comments`
|
|
58
|
+
* @see https://github.com/antfu/eslint-config
|
|
59
|
+
* @see https://github.com/eslint-community/eslint-plugin-eslint-comments
|
|
60
|
+
*/
|
|
61
|
+
const ESLINT_COMMENTS_RULES = { "eslint-comments/no-unlimited-disable": "off" };
|
|
39
62
|
//#endregion
|
|
40
63
|
//#region src/presets/javascript.ts
|
|
41
|
-
|
|
64
|
+
/**
|
|
65
|
+
* - rule: `*`
|
|
66
|
+
* - plugin: `none`
|
|
67
|
+
* @see https://eslint.org/docs/latest/rules/
|
|
68
|
+
*/
|
|
69
|
+
const JAVASCRIPT_RULES = {
|
|
42
70
|
"no-console": "off",
|
|
43
71
|
"no-debugger": "warn",
|
|
44
|
-
"no-unused-vars": "off"
|
|
72
|
+
"unused-imports/no-unused-vars": "off",
|
|
73
|
+
"no-unused-vars": ["error", {
|
|
74
|
+
vars: "all",
|
|
75
|
+
args: "all",
|
|
76
|
+
argsIgnorePattern: "^_",
|
|
77
|
+
destructuredArrayIgnorePattern: "^_",
|
|
78
|
+
varsIgnorePattern: "^_",
|
|
79
|
+
ignoreRestSiblings: true
|
|
80
|
+
}]
|
|
45
81
|
};
|
|
46
82
|
//#endregion
|
|
47
83
|
//#region src/presets/jsdoc.ts
|
|
48
|
-
|
|
84
|
+
/**
|
|
85
|
+
* - rule: `jsodc/*`
|
|
86
|
+
* - plugin: `eslint-plugin-jsdoc`
|
|
87
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc
|
|
88
|
+
*/
|
|
89
|
+
const COMMON_RULES = {
|
|
49
90
|
"jsdoc/check-syntax": "error",
|
|
50
|
-
"jsdoc/newline-after-description": "off",
|
|
51
91
|
"jsdoc/no-defaults": "off",
|
|
52
|
-
"jsdoc/reject-any-type": "off",
|
|
53
92
|
"jsdoc/require-jsdoc": "off",
|
|
54
93
|
"jsdoc/require-param-description": "off",
|
|
55
|
-
"jsdoc/require-param-type": "warn",
|
|
56
94
|
"jsdoc/require-property-description": "off",
|
|
57
95
|
"jsdoc/require-returns": "off",
|
|
96
|
+
"jsdoc/require-returns-type": "off",
|
|
58
97
|
"jsdoc/require-returns-description": "off",
|
|
59
|
-
"jsdoc/require-returns-type": "off"
|
|
60
|
-
};
|
|
61
|
-
const jsdocTypeScriptRules = {
|
|
62
|
-
"jsdoc/check-syntax": "error",
|
|
63
98
|
"jsdoc/newline-after-description": "off",
|
|
64
|
-
"jsdoc/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"jsdoc/require-param-type": "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"jsdoc/require-
|
|
99
|
+
"jsdoc/reject-any-type": "off"
|
|
100
|
+
};
|
|
101
|
+
const JSDOC_JAVASCRIPT_RULES = {
|
|
102
|
+
...COMMON_RULES,
|
|
103
|
+
"jsdoc/require-param-type": "warn"
|
|
104
|
+
};
|
|
105
|
+
const JSDOC_TYPESCRIPT_RULES = {
|
|
106
|
+
...COMMON_RULES,
|
|
107
|
+
"jsdoc/require-param-type": "off"
|
|
73
108
|
};
|
|
74
109
|
//#endregion
|
|
75
110
|
//#region src/presets/node.ts
|
|
76
|
-
|
|
111
|
+
/**
|
|
112
|
+
* - rule: `node/*`
|
|
113
|
+
* - original rule: `n/*`
|
|
114
|
+
* - plugin: `eslint-plugin-n`
|
|
115
|
+
* @see https://github.com/antfu/eslint-config#node
|
|
116
|
+
* @see https://github.com/eslint-community/eslint-plugin-n
|
|
117
|
+
*/
|
|
118
|
+
const NODE_RULES = { "node/prefer-global/process": "off" };
|
|
77
119
|
//#endregion
|
|
78
120
|
//#region src/presets/pnpm.ts
|
|
79
|
-
|
|
121
|
+
/**
|
|
122
|
+
* - rule: `pnpm/*`
|
|
123
|
+
* - plugin: `eslint-plugin-pnpm`
|
|
124
|
+
* @see https://github.com/antfu/eslint-config
|
|
125
|
+
* @see https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm
|
|
126
|
+
*/
|
|
127
|
+
const PNPM_RULES = { "pnpm/yaml-enforce-settings": "off" };
|
|
80
128
|
//#endregion
|
|
81
129
|
//#region src/presets/react.ts
|
|
82
|
-
|
|
130
|
+
/**
|
|
131
|
+
* - rule: `react/*`、`react-hooks-extra/*`
|
|
132
|
+
* - plugin: `eslint-plugin-react-hooks-extra`
|
|
133
|
+
* @see https://www.npmjs.com/package/eslint-plugin-react-hooks-extra
|
|
134
|
+
*/
|
|
135
|
+
const REACT_RULES = { "react-hooks-extra/no-direct-set-state-in-use-effect": "off" };
|
|
83
136
|
//#endregion
|
|
84
137
|
//#region src/presets/stylistic.ts
|
|
85
|
-
|
|
138
|
+
/**
|
|
139
|
+
* - rule: `style/*`
|
|
140
|
+
* - original rule: `@stylistic/*`
|
|
141
|
+
* - plugin: `@stylistic/eslint-plugin`
|
|
142
|
+
* @see https://github.com/antfu/eslint-config#stylistic
|
|
143
|
+
* @see https://eslint.style/rules
|
|
144
|
+
*/
|
|
145
|
+
const STYLISTIC_RULES = {
|
|
86
146
|
"style/quotes": [
|
|
87
147
|
"error",
|
|
88
148
|
"single",
|
|
@@ -127,18 +187,30 @@ const stylisticRules = {
|
|
|
127
187
|
"style/jsx-curly-newline": "off",
|
|
128
188
|
"style/jsx-one-expression-per-line": "off",
|
|
129
189
|
"style/jsx-wrap-multilines": "off",
|
|
130
|
-
"style/multiline-ternary": "off"
|
|
131
|
-
|
|
132
|
-
const stylisticLessOpinionatedRules = {
|
|
133
|
-
"antfu/consistent-list-newline": "off",
|
|
134
|
-
"antfu/if-newline": "off"
|
|
190
|
+
"style/multiline-ternary": "off",
|
|
191
|
+
"style/object-curly-spacing": "off"
|
|
135
192
|
};
|
|
136
193
|
//#endregion
|
|
137
194
|
//#region src/presets/test.ts
|
|
138
|
-
|
|
195
|
+
/**
|
|
196
|
+
* - rule: `test/*`
|
|
197
|
+
* - original rule: `vitest/*`, `no-only-tests/*`
|
|
198
|
+
* - plugin: `@vitest/eslint-plugin`, `eslint-plugin-no-only-tests`
|
|
199
|
+
* @see https://github.com/antfu/eslint-config#test
|
|
200
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest
|
|
201
|
+
* @see https://github.com/levibuzolic/eslint-plugin-no-only-tests
|
|
202
|
+
*/
|
|
203
|
+
const TEST_RULES = { "test/prefer-lowercase-title": "off" };
|
|
139
204
|
//#endregion
|
|
140
205
|
//#region src/presets/typescript.ts
|
|
141
|
-
|
|
206
|
+
/**
|
|
207
|
+
* - rule: `ts/*`
|
|
208
|
+
* - original rule: `@typescript-eslint/*`
|
|
209
|
+
* - plugin: `@typescript-eslint/eslint-plugin`
|
|
210
|
+
* @see https://github.com/antfu/eslint-config#typescript
|
|
211
|
+
* @see https://typescript-eslint.io/rules/
|
|
212
|
+
*/
|
|
213
|
+
const TYPESCRIPT_RULES = {
|
|
142
214
|
"no-unused-vars": "off",
|
|
143
215
|
"unused-imports/no-unused-vars": "off",
|
|
144
216
|
"ts/no-unused-vars": ["error", {
|
|
@@ -153,15 +225,15 @@ const typescriptRules = {
|
|
|
153
225
|
};
|
|
154
226
|
//#endregion
|
|
155
227
|
//#region src/presets/index.ts
|
|
156
|
-
const
|
|
228
|
+
const INTEGRATION_RULE_PRESETS = [
|
|
157
229
|
{
|
|
158
230
|
key: "javascript",
|
|
159
|
-
rules:
|
|
231
|
+
rules: JAVASCRIPT_RULES
|
|
160
232
|
},
|
|
161
233
|
{
|
|
162
234
|
key: "e18e",
|
|
163
235
|
option: "e18e",
|
|
164
|
-
rules:
|
|
236
|
+
rules: E18E_RULES
|
|
165
237
|
},
|
|
166
238
|
{
|
|
167
239
|
key: "unicorn",
|
|
@@ -171,26 +243,28 @@ const integrationRulePresets = [
|
|
|
171
243
|
{
|
|
172
244
|
key: "react",
|
|
173
245
|
option: "react",
|
|
174
|
-
rules:
|
|
246
|
+
rules: REACT_RULES
|
|
175
247
|
},
|
|
176
248
|
{
|
|
177
249
|
key: "stylistic",
|
|
178
250
|
option: "stylistic",
|
|
179
|
-
rules:
|
|
251
|
+
rules: STYLISTIC_RULES
|
|
180
252
|
},
|
|
181
253
|
{
|
|
182
254
|
key: "stylistic",
|
|
183
|
-
|
|
255
|
+
option: "lessOpinionated",
|
|
256
|
+
expected: false,
|
|
257
|
+
rules: ANTFU_LESS_OPINIONATED_RULES
|
|
184
258
|
},
|
|
185
259
|
{
|
|
186
260
|
key: "test",
|
|
187
261
|
option: "test",
|
|
188
|
-
rules:
|
|
262
|
+
rules: TEST_RULES
|
|
189
263
|
},
|
|
190
264
|
{
|
|
191
265
|
key: "typescript",
|
|
192
266
|
option: "typescript",
|
|
193
|
-
rules:
|
|
267
|
+
rules: TYPESCRIPT_RULES
|
|
194
268
|
},
|
|
195
269
|
{
|
|
196
270
|
key: "vue",
|
|
@@ -211,20 +285,20 @@ const integrationRulePresets = [
|
|
|
211
285
|
}
|
|
212
286
|
}
|
|
213
287
|
];
|
|
214
|
-
const
|
|
288
|
+
const CONFIG_ITEM_RULE_PRESETS = [
|
|
215
289
|
{
|
|
216
290
|
name: "eslint-comments",
|
|
217
|
-
rules:
|
|
291
|
+
rules: ESLINT_COMMENTS_RULES
|
|
218
292
|
},
|
|
219
293
|
{
|
|
220
294
|
name: "node",
|
|
221
295
|
option: "node",
|
|
222
|
-
rules:
|
|
296
|
+
rules: NODE_RULES
|
|
223
297
|
},
|
|
224
298
|
{
|
|
225
299
|
name: "pnpm",
|
|
226
300
|
option: "pnpm",
|
|
227
|
-
rules:
|
|
301
|
+
rules: PNPM_RULES
|
|
228
302
|
}
|
|
229
303
|
];
|
|
230
304
|
//#endregion
|
|
@@ -241,7 +315,7 @@ const CONFIG_ITEM_RULE_TARGETS = {
|
|
|
241
315
|
"pnpm/": "antfu/pnpm/pnpm-workspace-yaml"
|
|
242
316
|
};
|
|
243
317
|
const applyConfigItemRulePatches = (composer, options) => {
|
|
244
|
-
for (const preset of
|
|
318
|
+
for (const preset of CONFIG_ITEM_RULE_PRESETS) {
|
|
245
319
|
if (preset.option != null && !options[preset.option]) continue;
|
|
246
320
|
const targetName = resolveConfigItemTarget(preset);
|
|
247
321
|
if (!targetName) continue;
|
|
@@ -301,23 +375,13 @@ const applyJsdocPatch = (composer, options) => {
|
|
|
301
375
|
function buildManagedJsdocItems() {
|
|
302
376
|
return [...toConfigItems((0, eslint_plugin_jsdoc.jsdoc)({
|
|
303
377
|
config: "flat/recommended-typescript-flavor-error",
|
|
304
|
-
files: [
|
|
305
|
-
|
|
306
|
-
"**/*.jsx",
|
|
307
|
-
"**/*.cjs",
|
|
308
|
-
"**/*.mjs"
|
|
309
|
-
],
|
|
310
|
-
rules: jsdocJavaScriptRules,
|
|
378
|
+
files: ["**/*.?([cm])js?(x)"],
|
|
379
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
311
380
|
settings: SHARED_SETTINGS
|
|
312
381
|
})), ...toConfigItems((0, eslint_plugin_jsdoc.jsdoc)({
|
|
313
382
|
config: "flat/recommended-typescript-error",
|
|
314
|
-
files: [
|
|
315
|
-
|
|
316
|
-
"**/*.tsx",
|
|
317
|
-
"**/*.cts",
|
|
318
|
-
"**/*.mts"
|
|
319
|
-
],
|
|
320
|
-
rules: jsdocTypeScriptRules,
|
|
383
|
+
files: ["**/*.?([cm])ts?(x)"],
|
|
384
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
321
385
|
settings: SHARED_SETTINGS
|
|
322
386
|
}))];
|
|
323
387
|
}
|
|
@@ -330,7 +394,7 @@ function buildAntfuJsdocItems() {
|
|
|
330
394
|
"**/*.cjs",
|
|
331
395
|
"**/*.mjs"
|
|
332
396
|
],
|
|
333
|
-
rules:
|
|
397
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
334
398
|
settings: SHARED_SETTINGS
|
|
335
399
|
}, {
|
|
336
400
|
name: "tofrankie/jsdoc/typescript",
|
|
@@ -340,7 +404,7 @@ function buildAntfuJsdocItems() {
|
|
|
340
404
|
"**/*.cts",
|
|
341
405
|
"**/*.mts"
|
|
342
406
|
],
|
|
343
|
-
rules:
|
|
407
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
344
408
|
settings: SHARED_SETTINGS
|
|
345
409
|
}];
|
|
346
410
|
}
|
|
@@ -364,8 +428,8 @@ function applyPostAntfuPatches(composer, options) {
|
|
|
364
428
|
//#region src/core/compose-preset.ts
|
|
365
429
|
function composePreset(options) {
|
|
366
430
|
const preset = {};
|
|
367
|
-
for (const integrationRulePreset of
|
|
368
|
-
if (!isPresetEnabled(integrationRulePreset.option, options)) continue;
|
|
431
|
+
for (const integrationRulePreset of INTEGRATION_RULE_PRESETS) {
|
|
432
|
+
if (!isPresetEnabled(integrationRulePreset.option, integrationRulePreset.expected, options)) continue;
|
|
369
433
|
mergeRulesIntoIntegrationOptions(preset, integrationRulePreset.key, integrationRulePreset.rules);
|
|
370
434
|
}
|
|
371
435
|
return preset;
|
|
@@ -385,8 +449,9 @@ function mergeRulesIntoIntegrationOptions(preset, key, rules) {
|
|
|
385
449
|
function isObjectLike$1(value) {
|
|
386
450
|
return typeof value === "object" && value !== null;
|
|
387
451
|
}
|
|
388
|
-
function isPresetEnabled(option, options) {
|
|
389
|
-
|
|
452
|
+
function isPresetEnabled(option, expected, options) {
|
|
453
|
+
if (option == null) return true;
|
|
454
|
+
return options[option] === (expected ?? true);
|
|
390
455
|
}
|
|
391
456
|
//#endregion
|
|
392
457
|
//#region src/core/merge-options.ts
|
package/dist/index.mjs
CHANGED
|
@@ -4,62 +4,122 @@ import { createDefu } from "defu";
|
|
|
4
4
|
import { findUpSync } from "find-up-simple";
|
|
5
5
|
import { isPackageExists } from "local-pkg";
|
|
6
6
|
export * from "@antfu/eslint-config";
|
|
7
|
+
//#region src/presets/antfu.ts
|
|
8
|
+
/**
|
|
9
|
+
* - rule: `antfu/*`
|
|
10
|
+
* - plugin: `eslint-plugin-antfu`
|
|
11
|
+
* @see https://github.com/antfu/eslint-config#top-level-function-style-etc
|
|
12
|
+
* @see https://github.com/antfu/eslint-plugin-antfu
|
|
13
|
+
*/
|
|
14
|
+
const ANTFU_LESS_OPINIONATED_RULES = {
|
|
15
|
+
"antfu/consistent-list-newline": "off",
|
|
16
|
+
"antfu/if-newline": "off"
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
7
19
|
//#region src/presets/e18e.ts
|
|
8
|
-
|
|
20
|
+
/**
|
|
21
|
+
* - rule: `e18e/*`
|
|
22
|
+
* - plugin: `@e18e/eslint-plugin`
|
|
23
|
+
* @see https://github.com/e18e/eslint-plugin
|
|
24
|
+
*/
|
|
25
|
+
const E18E_RULES = {
|
|
9
26
|
"e18e/ban-dependencies": "off",
|
|
10
27
|
"e18e/prefer-array-to-sorted": "off",
|
|
11
28
|
"e18e/prefer-static-regex": "off"
|
|
12
29
|
};
|
|
13
30
|
//#endregion
|
|
14
31
|
//#region src/presets/eslint-comments.ts
|
|
15
|
-
|
|
32
|
+
/**
|
|
33
|
+
* - rule: `eslint-comments/*`
|
|
34
|
+
* - plugin: `eslint-plugin-eslint-comments`
|
|
35
|
+
* @see https://github.com/antfu/eslint-config
|
|
36
|
+
* @see https://github.com/eslint-community/eslint-plugin-eslint-comments
|
|
37
|
+
*/
|
|
38
|
+
const ESLINT_COMMENTS_RULES = { "eslint-comments/no-unlimited-disable": "off" };
|
|
16
39
|
//#endregion
|
|
17
40
|
//#region src/presets/javascript.ts
|
|
18
|
-
|
|
41
|
+
/**
|
|
42
|
+
* - rule: `*`
|
|
43
|
+
* - plugin: `none`
|
|
44
|
+
* @see https://eslint.org/docs/latest/rules/
|
|
45
|
+
*/
|
|
46
|
+
const JAVASCRIPT_RULES = {
|
|
19
47
|
"no-console": "off",
|
|
20
48
|
"no-debugger": "warn",
|
|
21
|
-
"no-unused-vars": "off"
|
|
49
|
+
"unused-imports/no-unused-vars": "off",
|
|
50
|
+
"no-unused-vars": ["error", {
|
|
51
|
+
vars: "all",
|
|
52
|
+
args: "all",
|
|
53
|
+
argsIgnorePattern: "^_",
|
|
54
|
+
destructuredArrayIgnorePattern: "^_",
|
|
55
|
+
varsIgnorePattern: "^_",
|
|
56
|
+
ignoreRestSiblings: true
|
|
57
|
+
}]
|
|
22
58
|
};
|
|
23
59
|
//#endregion
|
|
24
60
|
//#region src/presets/jsdoc.ts
|
|
25
|
-
|
|
61
|
+
/**
|
|
62
|
+
* - rule: `jsodc/*`
|
|
63
|
+
* - plugin: `eslint-plugin-jsdoc`
|
|
64
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc
|
|
65
|
+
*/
|
|
66
|
+
const COMMON_RULES = {
|
|
26
67
|
"jsdoc/check-syntax": "error",
|
|
27
|
-
"jsdoc/newline-after-description": "off",
|
|
28
68
|
"jsdoc/no-defaults": "off",
|
|
29
|
-
"jsdoc/reject-any-type": "off",
|
|
30
69
|
"jsdoc/require-jsdoc": "off",
|
|
31
70
|
"jsdoc/require-param-description": "off",
|
|
32
|
-
"jsdoc/require-param-type": "warn",
|
|
33
71
|
"jsdoc/require-property-description": "off",
|
|
34
72
|
"jsdoc/require-returns": "off",
|
|
73
|
+
"jsdoc/require-returns-type": "off",
|
|
35
74
|
"jsdoc/require-returns-description": "off",
|
|
36
|
-
"jsdoc/require-returns-type": "off"
|
|
37
|
-
};
|
|
38
|
-
const jsdocTypeScriptRules = {
|
|
39
|
-
"jsdoc/check-syntax": "error",
|
|
40
75
|
"jsdoc/newline-after-description": "off",
|
|
41
|
-
"jsdoc/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"jsdoc/require-param-type": "
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"jsdoc/require-
|
|
76
|
+
"jsdoc/reject-any-type": "off"
|
|
77
|
+
};
|
|
78
|
+
const JSDOC_JAVASCRIPT_RULES = {
|
|
79
|
+
...COMMON_RULES,
|
|
80
|
+
"jsdoc/require-param-type": "warn"
|
|
81
|
+
};
|
|
82
|
+
const JSDOC_TYPESCRIPT_RULES = {
|
|
83
|
+
...COMMON_RULES,
|
|
84
|
+
"jsdoc/require-param-type": "off"
|
|
50
85
|
};
|
|
51
86
|
//#endregion
|
|
52
87
|
//#region src/presets/node.ts
|
|
53
|
-
|
|
88
|
+
/**
|
|
89
|
+
* - rule: `node/*`
|
|
90
|
+
* - original rule: `n/*`
|
|
91
|
+
* - plugin: `eslint-plugin-n`
|
|
92
|
+
* @see https://github.com/antfu/eslint-config#node
|
|
93
|
+
* @see https://github.com/eslint-community/eslint-plugin-n
|
|
94
|
+
*/
|
|
95
|
+
const NODE_RULES = { "node/prefer-global/process": "off" };
|
|
54
96
|
//#endregion
|
|
55
97
|
//#region src/presets/pnpm.ts
|
|
56
|
-
|
|
98
|
+
/**
|
|
99
|
+
* - rule: `pnpm/*`
|
|
100
|
+
* - plugin: `eslint-plugin-pnpm`
|
|
101
|
+
* @see https://github.com/antfu/eslint-config
|
|
102
|
+
* @see https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm
|
|
103
|
+
*/
|
|
104
|
+
const PNPM_RULES = { "pnpm/yaml-enforce-settings": "off" };
|
|
57
105
|
//#endregion
|
|
58
106
|
//#region src/presets/react.ts
|
|
59
|
-
|
|
107
|
+
/**
|
|
108
|
+
* - rule: `react/*`、`react-hooks-extra/*`
|
|
109
|
+
* - plugin: `eslint-plugin-react-hooks-extra`
|
|
110
|
+
* @see https://www.npmjs.com/package/eslint-plugin-react-hooks-extra
|
|
111
|
+
*/
|
|
112
|
+
const REACT_RULES = { "react-hooks-extra/no-direct-set-state-in-use-effect": "off" };
|
|
60
113
|
//#endregion
|
|
61
114
|
//#region src/presets/stylistic.ts
|
|
62
|
-
|
|
115
|
+
/**
|
|
116
|
+
* - rule: `style/*`
|
|
117
|
+
* - original rule: `@stylistic/*`
|
|
118
|
+
* - plugin: `@stylistic/eslint-plugin`
|
|
119
|
+
* @see https://github.com/antfu/eslint-config#stylistic
|
|
120
|
+
* @see https://eslint.style/rules
|
|
121
|
+
*/
|
|
122
|
+
const STYLISTIC_RULES = {
|
|
63
123
|
"style/quotes": [
|
|
64
124
|
"error",
|
|
65
125
|
"single",
|
|
@@ -104,18 +164,30 @@ const stylisticRules = {
|
|
|
104
164
|
"style/jsx-curly-newline": "off",
|
|
105
165
|
"style/jsx-one-expression-per-line": "off",
|
|
106
166
|
"style/jsx-wrap-multilines": "off",
|
|
107
|
-
"style/multiline-ternary": "off"
|
|
108
|
-
|
|
109
|
-
const stylisticLessOpinionatedRules = {
|
|
110
|
-
"antfu/consistent-list-newline": "off",
|
|
111
|
-
"antfu/if-newline": "off"
|
|
167
|
+
"style/multiline-ternary": "off",
|
|
168
|
+
"style/object-curly-spacing": "off"
|
|
112
169
|
};
|
|
113
170
|
//#endregion
|
|
114
171
|
//#region src/presets/test.ts
|
|
115
|
-
|
|
172
|
+
/**
|
|
173
|
+
* - rule: `test/*`
|
|
174
|
+
* - original rule: `vitest/*`, `no-only-tests/*`
|
|
175
|
+
* - plugin: `@vitest/eslint-plugin`, `eslint-plugin-no-only-tests`
|
|
176
|
+
* @see https://github.com/antfu/eslint-config#test
|
|
177
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest
|
|
178
|
+
* @see https://github.com/levibuzolic/eslint-plugin-no-only-tests
|
|
179
|
+
*/
|
|
180
|
+
const TEST_RULES = { "test/prefer-lowercase-title": "off" };
|
|
116
181
|
//#endregion
|
|
117
182
|
//#region src/presets/typescript.ts
|
|
118
|
-
|
|
183
|
+
/**
|
|
184
|
+
* - rule: `ts/*`
|
|
185
|
+
* - original rule: `@typescript-eslint/*`
|
|
186
|
+
* - plugin: `@typescript-eslint/eslint-plugin`
|
|
187
|
+
* @see https://github.com/antfu/eslint-config#typescript
|
|
188
|
+
* @see https://typescript-eslint.io/rules/
|
|
189
|
+
*/
|
|
190
|
+
const TYPESCRIPT_RULES = {
|
|
119
191
|
"no-unused-vars": "off",
|
|
120
192
|
"unused-imports/no-unused-vars": "off",
|
|
121
193
|
"ts/no-unused-vars": ["error", {
|
|
@@ -130,15 +202,15 @@ const typescriptRules = {
|
|
|
130
202
|
};
|
|
131
203
|
//#endregion
|
|
132
204
|
//#region src/presets/index.ts
|
|
133
|
-
const
|
|
205
|
+
const INTEGRATION_RULE_PRESETS = [
|
|
134
206
|
{
|
|
135
207
|
key: "javascript",
|
|
136
|
-
rules:
|
|
208
|
+
rules: JAVASCRIPT_RULES
|
|
137
209
|
},
|
|
138
210
|
{
|
|
139
211
|
key: "e18e",
|
|
140
212
|
option: "e18e",
|
|
141
|
-
rules:
|
|
213
|
+
rules: E18E_RULES
|
|
142
214
|
},
|
|
143
215
|
{
|
|
144
216
|
key: "unicorn",
|
|
@@ -148,26 +220,28 @@ const integrationRulePresets = [
|
|
|
148
220
|
{
|
|
149
221
|
key: "react",
|
|
150
222
|
option: "react",
|
|
151
|
-
rules:
|
|
223
|
+
rules: REACT_RULES
|
|
152
224
|
},
|
|
153
225
|
{
|
|
154
226
|
key: "stylistic",
|
|
155
227
|
option: "stylistic",
|
|
156
|
-
rules:
|
|
228
|
+
rules: STYLISTIC_RULES
|
|
157
229
|
},
|
|
158
230
|
{
|
|
159
231
|
key: "stylistic",
|
|
160
|
-
|
|
232
|
+
option: "lessOpinionated",
|
|
233
|
+
expected: false,
|
|
234
|
+
rules: ANTFU_LESS_OPINIONATED_RULES
|
|
161
235
|
},
|
|
162
236
|
{
|
|
163
237
|
key: "test",
|
|
164
238
|
option: "test",
|
|
165
|
-
rules:
|
|
239
|
+
rules: TEST_RULES
|
|
166
240
|
},
|
|
167
241
|
{
|
|
168
242
|
key: "typescript",
|
|
169
243
|
option: "typescript",
|
|
170
|
-
rules:
|
|
244
|
+
rules: TYPESCRIPT_RULES
|
|
171
245
|
},
|
|
172
246
|
{
|
|
173
247
|
key: "vue",
|
|
@@ -188,20 +262,20 @@ const integrationRulePresets = [
|
|
|
188
262
|
}
|
|
189
263
|
}
|
|
190
264
|
];
|
|
191
|
-
const
|
|
265
|
+
const CONFIG_ITEM_RULE_PRESETS = [
|
|
192
266
|
{
|
|
193
267
|
name: "eslint-comments",
|
|
194
|
-
rules:
|
|
268
|
+
rules: ESLINT_COMMENTS_RULES
|
|
195
269
|
},
|
|
196
270
|
{
|
|
197
271
|
name: "node",
|
|
198
272
|
option: "node",
|
|
199
|
-
rules:
|
|
273
|
+
rules: NODE_RULES
|
|
200
274
|
},
|
|
201
275
|
{
|
|
202
276
|
name: "pnpm",
|
|
203
277
|
option: "pnpm",
|
|
204
|
-
rules:
|
|
278
|
+
rules: PNPM_RULES
|
|
205
279
|
}
|
|
206
280
|
];
|
|
207
281
|
//#endregion
|
|
@@ -218,7 +292,7 @@ const CONFIG_ITEM_RULE_TARGETS = {
|
|
|
218
292
|
"pnpm/": "antfu/pnpm/pnpm-workspace-yaml"
|
|
219
293
|
};
|
|
220
294
|
const applyConfigItemRulePatches = (composer, options) => {
|
|
221
|
-
for (const preset of
|
|
295
|
+
for (const preset of CONFIG_ITEM_RULE_PRESETS) {
|
|
222
296
|
if (preset.option != null && !options[preset.option]) continue;
|
|
223
297
|
const targetName = resolveConfigItemTarget(preset);
|
|
224
298
|
if (!targetName) continue;
|
|
@@ -278,23 +352,13 @@ const applyJsdocPatch = (composer, options) => {
|
|
|
278
352
|
function buildManagedJsdocItems() {
|
|
279
353
|
return [...toConfigItems(jsdoc({
|
|
280
354
|
config: "flat/recommended-typescript-flavor-error",
|
|
281
|
-
files: [
|
|
282
|
-
|
|
283
|
-
"**/*.jsx",
|
|
284
|
-
"**/*.cjs",
|
|
285
|
-
"**/*.mjs"
|
|
286
|
-
],
|
|
287
|
-
rules: jsdocJavaScriptRules,
|
|
355
|
+
files: ["**/*.?([cm])js?(x)"],
|
|
356
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
288
357
|
settings: SHARED_SETTINGS
|
|
289
358
|
})), ...toConfigItems(jsdoc({
|
|
290
359
|
config: "flat/recommended-typescript-error",
|
|
291
|
-
files: [
|
|
292
|
-
|
|
293
|
-
"**/*.tsx",
|
|
294
|
-
"**/*.cts",
|
|
295
|
-
"**/*.mts"
|
|
296
|
-
],
|
|
297
|
-
rules: jsdocTypeScriptRules,
|
|
360
|
+
files: ["**/*.?([cm])ts?(x)"],
|
|
361
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
298
362
|
settings: SHARED_SETTINGS
|
|
299
363
|
}))];
|
|
300
364
|
}
|
|
@@ -307,7 +371,7 @@ function buildAntfuJsdocItems() {
|
|
|
307
371
|
"**/*.cjs",
|
|
308
372
|
"**/*.mjs"
|
|
309
373
|
],
|
|
310
|
-
rules:
|
|
374
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
311
375
|
settings: SHARED_SETTINGS
|
|
312
376
|
}, {
|
|
313
377
|
name: "tofrankie/jsdoc/typescript",
|
|
@@ -317,7 +381,7 @@ function buildAntfuJsdocItems() {
|
|
|
317
381
|
"**/*.cts",
|
|
318
382
|
"**/*.mts"
|
|
319
383
|
],
|
|
320
|
-
rules:
|
|
384
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
321
385
|
settings: SHARED_SETTINGS
|
|
322
386
|
}];
|
|
323
387
|
}
|
|
@@ -341,8 +405,8 @@ function applyPostAntfuPatches(composer, options) {
|
|
|
341
405
|
//#region src/core/compose-preset.ts
|
|
342
406
|
function composePreset(options) {
|
|
343
407
|
const preset = {};
|
|
344
|
-
for (const integrationRulePreset of
|
|
345
|
-
if (!isPresetEnabled(integrationRulePreset.option, options)) continue;
|
|
408
|
+
for (const integrationRulePreset of INTEGRATION_RULE_PRESETS) {
|
|
409
|
+
if (!isPresetEnabled(integrationRulePreset.option, integrationRulePreset.expected, options)) continue;
|
|
346
410
|
mergeRulesIntoIntegrationOptions(preset, integrationRulePreset.key, integrationRulePreset.rules);
|
|
347
411
|
}
|
|
348
412
|
return preset;
|
|
@@ -362,8 +426,9 @@ function mergeRulesIntoIntegrationOptions(preset, key, rules) {
|
|
|
362
426
|
function isObjectLike$1(value) {
|
|
363
427
|
return typeof value === "object" && value !== null;
|
|
364
428
|
}
|
|
365
|
-
function isPresetEnabled(option, options) {
|
|
366
|
-
|
|
429
|
+
function isPresetEnabled(option, expected, options) {
|
|
430
|
+
if (option == null) return true;
|
|
431
|
+
return options[option] === (expected ?? true);
|
|
367
432
|
}
|
|
368
433
|
//#endregion
|
|
369
434
|
//#region src/core/merge-options.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tofrankie/eslint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.23",
|
|
5
5
|
"description": "Shared ESLint configuration",
|
|
6
6
|
"author": "Frankie <1426203851@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@next/eslint-plugin-next": "^16.2.2",
|
|
61
61
|
"@prettier/plugin-xml": "^3.4.2",
|
|
62
62
|
"@unocss/eslint-plugin": "^66.6.7",
|
|
63
|
-
"defu": "^6.1.
|
|
63
|
+
"defu": "^6.1.7",
|
|
64
64
|
"eslint-plugin-astro": "^1.6.0",
|
|
65
65
|
"eslint-plugin-format": "^2.0.1",
|
|
66
66
|
"eslint-plugin-jsdoc": "^62.9.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"eslint": "^10.2.0",
|
|
77
|
-
"vitest": "^4.1.
|
|
77
|
+
"vitest": "^4.1.3",
|
|
78
78
|
"@tofrankie/tsconfig": "0.0.5"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|