@tofrankie/eslint 0.0.20 → 0.0.22
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 +9 -0
- package/README.md +0 -8
- package/dist/index.cjs +140 -66
- package/dist/index.mjs +140 -66
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## eslint@0.0.22 (2026-04-07)
|
|
4
|
+
|
|
5
|
+
- Fix lessOpinionated preset detection logic
|
|
6
|
+
- Update dependencies
|
|
7
|
+
|
|
8
|
+
## eslint@0.0.21 (2026-04-07)
|
|
9
|
+
|
|
10
|
+
- Fix `pnpm` detection logic
|
|
11
|
+
|
|
3
12
|
## eslint@0.0.20 (2026-04-07)
|
|
4
13
|
|
|
5
14
|
- Refactor `defineConfig()` (layered options, presets, and post-antfu patches)
|
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
|
@@ -25,63 +25,124 @@ let _antfu_eslint_config = require("@antfu/eslint-config");
|
|
|
25
25
|
_antfu_eslint_config = __toESM(_antfu_eslint_config);
|
|
26
26
|
let eslint_plugin_jsdoc = require("eslint-plugin-jsdoc");
|
|
27
27
|
let defu = require("defu");
|
|
28
|
+
let find_up_simple = require("find-up-simple");
|
|
28
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
|
|
29
42
|
//#region src/presets/e18e.ts
|
|
30
|
-
|
|
43
|
+
/**
|
|
44
|
+
* - rule: `e18e/*`
|
|
45
|
+
* - plugin: `@e18e/eslint-plugin`
|
|
46
|
+
* @see https://github.com/e18e/eslint-plugin
|
|
47
|
+
*/
|
|
48
|
+
const E18E_RULES = {
|
|
31
49
|
"e18e/ban-dependencies": "off",
|
|
32
50
|
"e18e/prefer-array-to-sorted": "off",
|
|
33
51
|
"e18e/prefer-static-regex": "off"
|
|
34
52
|
};
|
|
35
53
|
//#endregion
|
|
36
54
|
//#region src/presets/eslint-comments.ts
|
|
37
|
-
|
|
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" };
|
|
38
62
|
//#endregion
|
|
39
63
|
//#region src/presets/javascript.ts
|
|
40
|
-
|
|
64
|
+
/**
|
|
65
|
+
* - rule: `*`
|
|
66
|
+
* - plugin: `none`
|
|
67
|
+
* @see https://eslint.org/docs/latest/rules/
|
|
68
|
+
*/
|
|
69
|
+
const JAVASCRIPT_RULES = {
|
|
41
70
|
"no-console": "off",
|
|
42
71
|
"no-debugger": "warn",
|
|
43
|
-
"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
|
+
}]
|
|
44
81
|
};
|
|
45
82
|
//#endregion
|
|
46
83
|
//#region src/presets/jsdoc.ts
|
|
47
|
-
|
|
84
|
+
/**
|
|
85
|
+
* - rule: `jsodc/*`
|
|
86
|
+
* - plugin: `eslint-plugin-jsdoc`
|
|
87
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc
|
|
88
|
+
*/
|
|
89
|
+
const COMMON_RULES = {
|
|
48
90
|
"jsdoc/check-syntax": "error",
|
|
49
|
-
"jsdoc/newline-after-description": "off",
|
|
50
91
|
"jsdoc/no-defaults": "off",
|
|
51
|
-
"jsdoc/reject-any-type": "off",
|
|
52
92
|
"jsdoc/require-jsdoc": "off",
|
|
53
93
|
"jsdoc/require-param-description": "off",
|
|
54
|
-
"jsdoc/require-param-type": "warn",
|
|
55
94
|
"jsdoc/require-property-description": "off",
|
|
56
95
|
"jsdoc/require-returns": "off",
|
|
96
|
+
"jsdoc/require-returns-type": "off",
|
|
57
97
|
"jsdoc/require-returns-description": "off",
|
|
58
|
-
"jsdoc/require-returns-type": "off"
|
|
59
|
-
};
|
|
60
|
-
const jsdocTypeScriptRules = {
|
|
61
|
-
"jsdoc/check-syntax": "error",
|
|
62
98
|
"jsdoc/newline-after-description": "off",
|
|
63
|
-
"jsdoc/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"jsdoc/require-param-type": "
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"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"
|
|
72
108
|
};
|
|
73
109
|
//#endregion
|
|
74
110
|
//#region src/presets/node.ts
|
|
75
|
-
|
|
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" };
|
|
76
119
|
//#endregion
|
|
77
120
|
//#region src/presets/pnpm.ts
|
|
78
|
-
|
|
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" };
|
|
79
128
|
//#endregion
|
|
80
129
|
//#region src/presets/react.ts
|
|
81
|
-
|
|
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" };
|
|
82
136
|
//#endregion
|
|
83
137
|
//#region src/presets/stylistic.ts
|
|
84
|
-
|
|
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 = {
|
|
85
146
|
"style/quotes": [
|
|
86
147
|
"error",
|
|
87
148
|
"single",
|
|
@@ -126,18 +187,30 @@ const stylisticRules = {
|
|
|
126
187
|
"style/jsx-curly-newline": "off",
|
|
127
188
|
"style/jsx-one-expression-per-line": "off",
|
|
128
189
|
"style/jsx-wrap-multilines": "off",
|
|
129
|
-
"style/multiline-ternary": "off"
|
|
130
|
-
|
|
131
|
-
const stylisticLessOpinionatedRules = {
|
|
132
|
-
"antfu/consistent-list-newline": "off",
|
|
133
|
-
"antfu/if-newline": "off"
|
|
190
|
+
"style/multiline-ternary": "off",
|
|
191
|
+
"object-curly-spacing": "off"
|
|
134
192
|
};
|
|
135
193
|
//#endregion
|
|
136
194
|
//#region src/presets/test.ts
|
|
137
|
-
|
|
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" };
|
|
138
204
|
//#endregion
|
|
139
205
|
//#region src/presets/typescript.ts
|
|
140
|
-
|
|
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 = {
|
|
141
214
|
"no-unused-vars": "off",
|
|
142
215
|
"unused-imports/no-unused-vars": "off",
|
|
143
216
|
"ts/no-unused-vars": ["error", {
|
|
@@ -152,15 +225,15 @@ const typescriptRules = {
|
|
|
152
225
|
};
|
|
153
226
|
//#endregion
|
|
154
227
|
//#region src/presets/index.ts
|
|
155
|
-
const
|
|
228
|
+
const INTEGRATION_RULE_PRESETS = [
|
|
156
229
|
{
|
|
157
230
|
key: "javascript",
|
|
158
|
-
rules:
|
|
231
|
+
rules: JAVASCRIPT_RULES
|
|
159
232
|
},
|
|
160
233
|
{
|
|
161
234
|
key: "e18e",
|
|
162
235
|
option: "e18e",
|
|
163
|
-
rules:
|
|
236
|
+
rules: E18E_RULES
|
|
164
237
|
},
|
|
165
238
|
{
|
|
166
239
|
key: "unicorn",
|
|
@@ -170,26 +243,28 @@ const integrationRulePresets = [
|
|
|
170
243
|
{
|
|
171
244
|
key: "react",
|
|
172
245
|
option: "react",
|
|
173
|
-
rules:
|
|
246
|
+
rules: REACT_RULES
|
|
174
247
|
},
|
|
175
248
|
{
|
|
176
249
|
key: "stylistic",
|
|
177
250
|
option: "stylistic",
|
|
178
|
-
rules:
|
|
251
|
+
rules: STYLISTIC_RULES
|
|
179
252
|
},
|
|
180
253
|
{
|
|
181
254
|
key: "stylistic",
|
|
182
|
-
|
|
255
|
+
option: "lessOpinionated",
|
|
256
|
+
expected: false,
|
|
257
|
+
rules: ANTFU_LESS_OPINIONATED_RULES
|
|
183
258
|
},
|
|
184
259
|
{
|
|
185
260
|
key: "test",
|
|
186
261
|
option: "test",
|
|
187
|
-
rules:
|
|
262
|
+
rules: TEST_RULES
|
|
188
263
|
},
|
|
189
264
|
{
|
|
190
265
|
key: "typescript",
|
|
191
266
|
option: "typescript",
|
|
192
|
-
rules:
|
|
267
|
+
rules: TYPESCRIPT_RULES
|
|
193
268
|
},
|
|
194
269
|
{
|
|
195
270
|
key: "vue",
|
|
@@ -210,20 +285,20 @@ const integrationRulePresets = [
|
|
|
210
285
|
}
|
|
211
286
|
}
|
|
212
287
|
];
|
|
213
|
-
const
|
|
288
|
+
const CONFIG_ITEM_RULE_PRESETS = [
|
|
214
289
|
{
|
|
215
290
|
name: "eslint-comments",
|
|
216
|
-
rules:
|
|
291
|
+
rules: ESLINT_COMMENTS_RULES
|
|
217
292
|
},
|
|
218
293
|
{
|
|
219
294
|
name: "node",
|
|
220
295
|
option: "node",
|
|
221
|
-
rules:
|
|
296
|
+
rules: NODE_RULES
|
|
222
297
|
},
|
|
223
298
|
{
|
|
224
299
|
name: "pnpm",
|
|
225
300
|
option: "pnpm",
|
|
226
|
-
rules:
|
|
301
|
+
rules: PNPM_RULES
|
|
227
302
|
}
|
|
228
303
|
];
|
|
229
304
|
//#endregion
|
|
@@ -240,7 +315,7 @@ const CONFIG_ITEM_RULE_TARGETS = {
|
|
|
240
315
|
"pnpm/": "antfu/pnpm/pnpm-workspace-yaml"
|
|
241
316
|
};
|
|
242
317
|
const applyConfigItemRulePatches = (composer, options) => {
|
|
243
|
-
for (const preset of
|
|
318
|
+
for (const preset of CONFIG_ITEM_RULE_PRESETS) {
|
|
244
319
|
if (preset.option != null && !options[preset.option]) continue;
|
|
245
320
|
const targetName = resolveConfigItemTarget(preset);
|
|
246
321
|
if (!targetName) continue;
|
|
@@ -300,23 +375,13 @@ const applyJsdocPatch = (composer, options) => {
|
|
|
300
375
|
function buildManagedJsdocItems() {
|
|
301
376
|
return [...toConfigItems((0, eslint_plugin_jsdoc.jsdoc)({
|
|
302
377
|
config: "flat/recommended-typescript-flavor-error",
|
|
303
|
-
files: [
|
|
304
|
-
|
|
305
|
-
"**/*.jsx",
|
|
306
|
-
"**/*.cjs",
|
|
307
|
-
"**/*.mjs"
|
|
308
|
-
],
|
|
309
|
-
rules: jsdocJavaScriptRules,
|
|
378
|
+
files: ["**/*.?([cm])js?(x)"],
|
|
379
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
310
380
|
settings: SHARED_SETTINGS
|
|
311
381
|
})), ...toConfigItems((0, eslint_plugin_jsdoc.jsdoc)({
|
|
312
382
|
config: "flat/recommended-typescript-error",
|
|
313
|
-
files: [
|
|
314
|
-
|
|
315
|
-
"**/*.tsx",
|
|
316
|
-
"**/*.cts",
|
|
317
|
-
"**/*.mts"
|
|
318
|
-
],
|
|
319
|
-
rules: jsdocTypeScriptRules,
|
|
383
|
+
files: ["**/*.?([cm])ts?(x)"],
|
|
384
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
320
385
|
settings: SHARED_SETTINGS
|
|
321
386
|
}))];
|
|
322
387
|
}
|
|
@@ -329,7 +394,7 @@ function buildAntfuJsdocItems() {
|
|
|
329
394
|
"**/*.cjs",
|
|
330
395
|
"**/*.mjs"
|
|
331
396
|
],
|
|
332
|
-
rules:
|
|
397
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
333
398
|
settings: SHARED_SETTINGS
|
|
334
399
|
}, {
|
|
335
400
|
name: "tofrankie/jsdoc/typescript",
|
|
@@ -339,7 +404,7 @@ function buildAntfuJsdocItems() {
|
|
|
339
404
|
"**/*.cts",
|
|
340
405
|
"**/*.mts"
|
|
341
406
|
],
|
|
342
|
-
rules:
|
|
407
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
343
408
|
settings: SHARED_SETTINGS
|
|
344
409
|
}];
|
|
345
410
|
}
|
|
@@ -363,8 +428,8 @@ function applyPostAntfuPatches(composer, options) {
|
|
|
363
428
|
//#region src/core/compose-preset.ts
|
|
364
429
|
function composePreset(options) {
|
|
365
430
|
const preset = {};
|
|
366
|
-
for (const integrationRulePreset of
|
|
367
|
-
if (!isPresetEnabled(integrationRulePreset.option, options)) continue;
|
|
431
|
+
for (const integrationRulePreset of INTEGRATION_RULE_PRESETS) {
|
|
432
|
+
if (!isPresetEnabled(integrationRulePreset.option, integrationRulePreset.expected, options)) continue;
|
|
368
433
|
mergeRulesIntoIntegrationOptions(preset, integrationRulePreset.key, integrationRulePreset.rules);
|
|
369
434
|
}
|
|
370
435
|
return preset;
|
|
@@ -384,8 +449,9 @@ function mergeRulesIntoIntegrationOptions(preset, key, rules) {
|
|
|
384
449
|
function isObjectLike$1(value) {
|
|
385
450
|
return typeof value === "object" && value !== null;
|
|
386
451
|
}
|
|
387
|
-
function isPresetEnabled(option, options) {
|
|
388
|
-
|
|
452
|
+
function isPresetEnabled(option, expected, options) {
|
|
453
|
+
if (option == null) return true;
|
|
454
|
+
return options[option] === (expected ?? true);
|
|
389
455
|
}
|
|
390
456
|
//#endregion
|
|
391
457
|
//#region src/core/merge-options.ts
|
|
@@ -461,6 +527,9 @@ function resolveFormattersOption(value) {
|
|
|
461
527
|
function detectPackage(name) {
|
|
462
528
|
return (0, local_pkg.isPackageExists)(name);
|
|
463
529
|
}
|
|
530
|
+
function detectPnpmWorkspaceYaml(cwd) {
|
|
531
|
+
return (0, find_up_simple.findUpSync)("pnpm-workspace.yaml", cwd === void 0 ? void 0 : { cwd }) !== void 0;
|
|
532
|
+
}
|
|
464
533
|
//#endregion
|
|
465
534
|
//#region src/core/jsdoc-mode.ts
|
|
466
535
|
const INTERNAL_JSDOC_MODE = "antfu";
|
|
@@ -475,7 +544,7 @@ function resolveConfigOptions(options) {
|
|
|
475
544
|
jsdocMode: INTERNAL_JSDOC_MODE,
|
|
476
545
|
lessOpinionated: options.lessOpinionated === true,
|
|
477
546
|
node: isEnabledByDefault(options.node),
|
|
478
|
-
pnpm:
|
|
547
|
+
pnpm: isPnpmEnabled(options.pnpm),
|
|
479
548
|
react: isExplicitlyEnabled(options.react),
|
|
480
549
|
stylistic: isEnabledByDefault(options.stylistic),
|
|
481
550
|
test: isEnabledByDefault(options.test),
|
|
@@ -491,6 +560,11 @@ function isEnabledByDefault(value) {
|
|
|
491
560
|
function isExplicitlyEnabled(value) {
|
|
492
561
|
return value === true || isOptionObject(value);
|
|
493
562
|
}
|
|
563
|
+
function isPnpmEnabled(pnpmOption) {
|
|
564
|
+
if (pnpmOption === false) return false;
|
|
565
|
+
if (isExplicitlyEnabled(pnpmOption)) return true;
|
|
566
|
+
return detectPnpmWorkspaceYaml();
|
|
567
|
+
}
|
|
494
568
|
function isAutoDetectedEnabled(value, packageName) {
|
|
495
569
|
if (value === false) return false;
|
|
496
570
|
return isExplicitlyEnabled(value) || detectPackage(packageName);
|
package/dist/index.mjs
CHANGED
|
@@ -1,64 +1,125 @@
|
|
|
1
1
|
import antfu from "@antfu/eslint-config";
|
|
2
2
|
import { jsdoc } from "eslint-plugin-jsdoc";
|
|
3
3
|
import { createDefu } from "defu";
|
|
4
|
+
import { findUpSync } from "find-up-simple";
|
|
4
5
|
import { isPackageExists } from "local-pkg";
|
|
5
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
|
|
6
19
|
//#region src/presets/e18e.ts
|
|
7
|
-
|
|
20
|
+
/**
|
|
21
|
+
* - rule: `e18e/*`
|
|
22
|
+
* - plugin: `@e18e/eslint-plugin`
|
|
23
|
+
* @see https://github.com/e18e/eslint-plugin
|
|
24
|
+
*/
|
|
25
|
+
const E18E_RULES = {
|
|
8
26
|
"e18e/ban-dependencies": "off",
|
|
9
27
|
"e18e/prefer-array-to-sorted": "off",
|
|
10
28
|
"e18e/prefer-static-regex": "off"
|
|
11
29
|
};
|
|
12
30
|
//#endregion
|
|
13
31
|
//#region src/presets/eslint-comments.ts
|
|
14
|
-
|
|
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" };
|
|
15
39
|
//#endregion
|
|
16
40
|
//#region src/presets/javascript.ts
|
|
17
|
-
|
|
41
|
+
/**
|
|
42
|
+
* - rule: `*`
|
|
43
|
+
* - plugin: `none`
|
|
44
|
+
* @see https://eslint.org/docs/latest/rules/
|
|
45
|
+
*/
|
|
46
|
+
const JAVASCRIPT_RULES = {
|
|
18
47
|
"no-console": "off",
|
|
19
48
|
"no-debugger": "warn",
|
|
20
|
-
"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
|
+
}]
|
|
21
58
|
};
|
|
22
59
|
//#endregion
|
|
23
60
|
//#region src/presets/jsdoc.ts
|
|
24
|
-
|
|
61
|
+
/**
|
|
62
|
+
* - rule: `jsodc/*`
|
|
63
|
+
* - plugin: `eslint-plugin-jsdoc`
|
|
64
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc
|
|
65
|
+
*/
|
|
66
|
+
const COMMON_RULES = {
|
|
25
67
|
"jsdoc/check-syntax": "error",
|
|
26
|
-
"jsdoc/newline-after-description": "off",
|
|
27
68
|
"jsdoc/no-defaults": "off",
|
|
28
|
-
"jsdoc/reject-any-type": "off",
|
|
29
69
|
"jsdoc/require-jsdoc": "off",
|
|
30
70
|
"jsdoc/require-param-description": "off",
|
|
31
|
-
"jsdoc/require-param-type": "warn",
|
|
32
71
|
"jsdoc/require-property-description": "off",
|
|
33
72
|
"jsdoc/require-returns": "off",
|
|
73
|
+
"jsdoc/require-returns-type": "off",
|
|
34
74
|
"jsdoc/require-returns-description": "off",
|
|
35
|
-
"jsdoc/require-returns-type": "off"
|
|
36
|
-
};
|
|
37
|
-
const jsdocTypeScriptRules = {
|
|
38
|
-
"jsdoc/check-syntax": "error",
|
|
39
75
|
"jsdoc/newline-after-description": "off",
|
|
40
|
-
"jsdoc/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"jsdoc/require-param-type": "
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"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"
|
|
49
85
|
};
|
|
50
86
|
//#endregion
|
|
51
87
|
//#region src/presets/node.ts
|
|
52
|
-
|
|
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" };
|
|
53
96
|
//#endregion
|
|
54
97
|
//#region src/presets/pnpm.ts
|
|
55
|
-
|
|
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" };
|
|
56
105
|
//#endregion
|
|
57
106
|
//#region src/presets/react.ts
|
|
58
|
-
|
|
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" };
|
|
59
113
|
//#endregion
|
|
60
114
|
//#region src/presets/stylistic.ts
|
|
61
|
-
|
|
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 = {
|
|
62
123
|
"style/quotes": [
|
|
63
124
|
"error",
|
|
64
125
|
"single",
|
|
@@ -103,18 +164,30 @@ const stylisticRules = {
|
|
|
103
164
|
"style/jsx-curly-newline": "off",
|
|
104
165
|
"style/jsx-one-expression-per-line": "off",
|
|
105
166
|
"style/jsx-wrap-multilines": "off",
|
|
106
|
-
"style/multiline-ternary": "off"
|
|
107
|
-
|
|
108
|
-
const stylisticLessOpinionatedRules = {
|
|
109
|
-
"antfu/consistent-list-newline": "off",
|
|
110
|
-
"antfu/if-newline": "off"
|
|
167
|
+
"style/multiline-ternary": "off",
|
|
168
|
+
"object-curly-spacing": "off"
|
|
111
169
|
};
|
|
112
170
|
//#endregion
|
|
113
171
|
//#region src/presets/test.ts
|
|
114
|
-
|
|
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" };
|
|
115
181
|
//#endregion
|
|
116
182
|
//#region src/presets/typescript.ts
|
|
117
|
-
|
|
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 = {
|
|
118
191
|
"no-unused-vars": "off",
|
|
119
192
|
"unused-imports/no-unused-vars": "off",
|
|
120
193
|
"ts/no-unused-vars": ["error", {
|
|
@@ -129,15 +202,15 @@ const typescriptRules = {
|
|
|
129
202
|
};
|
|
130
203
|
//#endregion
|
|
131
204
|
//#region src/presets/index.ts
|
|
132
|
-
const
|
|
205
|
+
const INTEGRATION_RULE_PRESETS = [
|
|
133
206
|
{
|
|
134
207
|
key: "javascript",
|
|
135
|
-
rules:
|
|
208
|
+
rules: JAVASCRIPT_RULES
|
|
136
209
|
},
|
|
137
210
|
{
|
|
138
211
|
key: "e18e",
|
|
139
212
|
option: "e18e",
|
|
140
|
-
rules:
|
|
213
|
+
rules: E18E_RULES
|
|
141
214
|
},
|
|
142
215
|
{
|
|
143
216
|
key: "unicorn",
|
|
@@ -147,26 +220,28 @@ const integrationRulePresets = [
|
|
|
147
220
|
{
|
|
148
221
|
key: "react",
|
|
149
222
|
option: "react",
|
|
150
|
-
rules:
|
|
223
|
+
rules: REACT_RULES
|
|
151
224
|
},
|
|
152
225
|
{
|
|
153
226
|
key: "stylistic",
|
|
154
227
|
option: "stylistic",
|
|
155
|
-
rules:
|
|
228
|
+
rules: STYLISTIC_RULES
|
|
156
229
|
},
|
|
157
230
|
{
|
|
158
231
|
key: "stylistic",
|
|
159
|
-
|
|
232
|
+
option: "lessOpinionated",
|
|
233
|
+
expected: false,
|
|
234
|
+
rules: ANTFU_LESS_OPINIONATED_RULES
|
|
160
235
|
},
|
|
161
236
|
{
|
|
162
237
|
key: "test",
|
|
163
238
|
option: "test",
|
|
164
|
-
rules:
|
|
239
|
+
rules: TEST_RULES
|
|
165
240
|
},
|
|
166
241
|
{
|
|
167
242
|
key: "typescript",
|
|
168
243
|
option: "typescript",
|
|
169
|
-
rules:
|
|
244
|
+
rules: TYPESCRIPT_RULES
|
|
170
245
|
},
|
|
171
246
|
{
|
|
172
247
|
key: "vue",
|
|
@@ -187,20 +262,20 @@ const integrationRulePresets = [
|
|
|
187
262
|
}
|
|
188
263
|
}
|
|
189
264
|
];
|
|
190
|
-
const
|
|
265
|
+
const CONFIG_ITEM_RULE_PRESETS = [
|
|
191
266
|
{
|
|
192
267
|
name: "eslint-comments",
|
|
193
|
-
rules:
|
|
268
|
+
rules: ESLINT_COMMENTS_RULES
|
|
194
269
|
},
|
|
195
270
|
{
|
|
196
271
|
name: "node",
|
|
197
272
|
option: "node",
|
|
198
|
-
rules:
|
|
273
|
+
rules: NODE_RULES
|
|
199
274
|
},
|
|
200
275
|
{
|
|
201
276
|
name: "pnpm",
|
|
202
277
|
option: "pnpm",
|
|
203
|
-
rules:
|
|
278
|
+
rules: PNPM_RULES
|
|
204
279
|
}
|
|
205
280
|
];
|
|
206
281
|
//#endregion
|
|
@@ -217,7 +292,7 @@ const CONFIG_ITEM_RULE_TARGETS = {
|
|
|
217
292
|
"pnpm/": "antfu/pnpm/pnpm-workspace-yaml"
|
|
218
293
|
};
|
|
219
294
|
const applyConfigItemRulePatches = (composer, options) => {
|
|
220
|
-
for (const preset of
|
|
295
|
+
for (const preset of CONFIG_ITEM_RULE_PRESETS) {
|
|
221
296
|
if (preset.option != null && !options[preset.option]) continue;
|
|
222
297
|
const targetName = resolveConfigItemTarget(preset);
|
|
223
298
|
if (!targetName) continue;
|
|
@@ -277,23 +352,13 @@ const applyJsdocPatch = (composer, options) => {
|
|
|
277
352
|
function buildManagedJsdocItems() {
|
|
278
353
|
return [...toConfigItems(jsdoc({
|
|
279
354
|
config: "flat/recommended-typescript-flavor-error",
|
|
280
|
-
files: [
|
|
281
|
-
|
|
282
|
-
"**/*.jsx",
|
|
283
|
-
"**/*.cjs",
|
|
284
|
-
"**/*.mjs"
|
|
285
|
-
],
|
|
286
|
-
rules: jsdocJavaScriptRules,
|
|
355
|
+
files: ["**/*.?([cm])js?(x)"],
|
|
356
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
287
357
|
settings: SHARED_SETTINGS
|
|
288
358
|
})), ...toConfigItems(jsdoc({
|
|
289
359
|
config: "flat/recommended-typescript-error",
|
|
290
|
-
files: [
|
|
291
|
-
|
|
292
|
-
"**/*.tsx",
|
|
293
|
-
"**/*.cts",
|
|
294
|
-
"**/*.mts"
|
|
295
|
-
],
|
|
296
|
-
rules: jsdocTypeScriptRules,
|
|
360
|
+
files: ["**/*.?([cm])ts?(x)"],
|
|
361
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
297
362
|
settings: SHARED_SETTINGS
|
|
298
363
|
}))];
|
|
299
364
|
}
|
|
@@ -306,7 +371,7 @@ function buildAntfuJsdocItems() {
|
|
|
306
371
|
"**/*.cjs",
|
|
307
372
|
"**/*.mjs"
|
|
308
373
|
],
|
|
309
|
-
rules:
|
|
374
|
+
rules: JSDOC_JAVASCRIPT_RULES,
|
|
310
375
|
settings: SHARED_SETTINGS
|
|
311
376
|
}, {
|
|
312
377
|
name: "tofrankie/jsdoc/typescript",
|
|
@@ -316,7 +381,7 @@ function buildAntfuJsdocItems() {
|
|
|
316
381
|
"**/*.cts",
|
|
317
382
|
"**/*.mts"
|
|
318
383
|
],
|
|
319
|
-
rules:
|
|
384
|
+
rules: JSDOC_TYPESCRIPT_RULES,
|
|
320
385
|
settings: SHARED_SETTINGS
|
|
321
386
|
}];
|
|
322
387
|
}
|
|
@@ -340,8 +405,8 @@ function applyPostAntfuPatches(composer, options) {
|
|
|
340
405
|
//#region src/core/compose-preset.ts
|
|
341
406
|
function composePreset(options) {
|
|
342
407
|
const preset = {};
|
|
343
|
-
for (const integrationRulePreset of
|
|
344
|
-
if (!isPresetEnabled(integrationRulePreset.option, options)) continue;
|
|
408
|
+
for (const integrationRulePreset of INTEGRATION_RULE_PRESETS) {
|
|
409
|
+
if (!isPresetEnabled(integrationRulePreset.option, integrationRulePreset.expected, options)) continue;
|
|
345
410
|
mergeRulesIntoIntegrationOptions(preset, integrationRulePreset.key, integrationRulePreset.rules);
|
|
346
411
|
}
|
|
347
412
|
return preset;
|
|
@@ -361,8 +426,9 @@ function mergeRulesIntoIntegrationOptions(preset, key, rules) {
|
|
|
361
426
|
function isObjectLike$1(value) {
|
|
362
427
|
return typeof value === "object" && value !== null;
|
|
363
428
|
}
|
|
364
|
-
function isPresetEnabled(option, options) {
|
|
365
|
-
|
|
429
|
+
function isPresetEnabled(option, expected, options) {
|
|
430
|
+
if (option == null) return true;
|
|
431
|
+
return options[option] === (expected ?? true);
|
|
366
432
|
}
|
|
367
433
|
//#endregion
|
|
368
434
|
//#region src/core/merge-options.ts
|
|
@@ -438,6 +504,9 @@ function resolveFormattersOption(value) {
|
|
|
438
504
|
function detectPackage(name) {
|
|
439
505
|
return isPackageExists(name);
|
|
440
506
|
}
|
|
507
|
+
function detectPnpmWorkspaceYaml(cwd) {
|
|
508
|
+
return findUpSync("pnpm-workspace.yaml", cwd === void 0 ? void 0 : { cwd }) !== void 0;
|
|
509
|
+
}
|
|
441
510
|
//#endregion
|
|
442
511
|
//#region src/core/jsdoc-mode.ts
|
|
443
512
|
const INTERNAL_JSDOC_MODE = "antfu";
|
|
@@ -452,7 +521,7 @@ function resolveConfigOptions(options) {
|
|
|
452
521
|
jsdocMode: INTERNAL_JSDOC_MODE,
|
|
453
522
|
lessOpinionated: options.lessOpinionated === true,
|
|
454
523
|
node: isEnabledByDefault(options.node),
|
|
455
|
-
pnpm:
|
|
524
|
+
pnpm: isPnpmEnabled(options.pnpm),
|
|
456
525
|
react: isExplicitlyEnabled(options.react),
|
|
457
526
|
stylistic: isEnabledByDefault(options.stylistic),
|
|
458
527
|
test: isEnabledByDefault(options.test),
|
|
@@ -468,6 +537,11 @@ function isEnabledByDefault(value) {
|
|
|
468
537
|
function isExplicitlyEnabled(value) {
|
|
469
538
|
return value === true || isOptionObject(value);
|
|
470
539
|
}
|
|
540
|
+
function isPnpmEnabled(pnpmOption) {
|
|
541
|
+
if (pnpmOption === false) return false;
|
|
542
|
+
if (isExplicitlyEnabled(pnpmOption)) return true;
|
|
543
|
+
return detectPnpmWorkspaceYaml();
|
|
544
|
+
}
|
|
471
545
|
function isAutoDetectedEnabled(value, packageName) {
|
|
472
546
|
if (value === false) return false;
|
|
473
547
|
return isExplicitlyEnabled(value) || detectPackage(packageName);
|
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.22",
|
|
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",
|
|
@@ -68,12 +68,13 @@
|
|
|
68
68
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
69
69
|
"eslint-plugin-solid": "^0.14.5",
|
|
70
70
|
"eslint-plugin-svelte": "^3.17.0",
|
|
71
|
+
"find-up-simple": "^1.0.1",
|
|
71
72
|
"local-pkg": "^1.1.2",
|
|
72
73
|
"prettier-plugin-astro": "^0.14.1"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
76
|
"eslint": "^10.2.0",
|
|
76
|
-
"vitest": "^4.1.
|
|
77
|
+
"vitest": "^4.1.3",
|
|
77
78
|
"@tofrankie/tsconfig": "0.0.5"
|
|
78
79
|
},
|
|
79
80
|
"scripts": {
|