@lincy/eslint-config 6.5.2 → 7.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 +1 -0
- package/dist/index.cjs +148 -254
- package/dist/index.d.cts +1681 -2151
- package/dist/index.d.mts +1680 -2150
- package/dist/index.mjs +135 -241
- package/package.json +40 -36
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
3
6
|
var __create = Object.create;
|
|
4
7
|
var __defProp = Object.defineProperty;
|
|
5
8
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,16 +10,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
10
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
12
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
20
19
|
}
|
|
21
20
|
return to;
|
|
22
21
|
};
|
|
@@ -24,7 +23,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
23
|
value: mod,
|
|
25
24
|
enumerable: true
|
|
26
25
|
}) : target, mod));
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
27
|
let eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
30
28
|
let node_process = require("node:process");
|
|
@@ -37,6 +35,8 @@ node_fs = __toESM(node_fs);
|
|
|
37
35
|
let node_path = require("node:path");
|
|
38
36
|
node_path = __toESM(node_path);
|
|
39
37
|
let local_pkg = require("local-pkg");
|
|
38
|
+
let _e18e_eslint_plugin = require("@e18e/eslint-plugin");
|
|
39
|
+
_e18e_eslint_plugin = __toESM(_e18e_eslint_plugin);
|
|
40
40
|
let _eslint_community_eslint_plugin_eslint_comments = require("@eslint-community/eslint-plugin-eslint-comments");
|
|
41
41
|
_eslint_community_eslint_plugin_eslint_comments = __toESM(_eslint_community_eslint_plugin_eslint_comments);
|
|
42
42
|
let eslint_plugin_antfu = require("eslint-plugin-antfu");
|
|
@@ -55,7 +55,6 @@ let globals = require("globals");
|
|
|
55
55
|
globals = __toESM(globals);
|
|
56
56
|
let eslint_merge_processors = require("eslint-merge-processors");
|
|
57
57
|
let eslint_plugin_regexp = require("eslint-plugin-regexp");
|
|
58
|
-
|
|
59
58
|
//#region node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
60
59
|
const toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, node_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
61
60
|
async function findUp(name, { cwd = node_process.default.cwd(), type = "file", stopAt } = {}) {
|
|
@@ -88,7 +87,6 @@ function findUpSync(name, { cwd = node_process.default.cwd(), type = "file", sto
|
|
|
88
87
|
directory = node_path.default.dirname(directory);
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
//#endregion
|
|
93
91
|
//#region src/configs/comments.ts
|
|
94
92
|
async function comments(options = {}) {
|
|
@@ -105,7 +103,6 @@ async function comments(options = {}) {
|
|
|
105
103
|
}
|
|
106
104
|
}];
|
|
107
105
|
}
|
|
108
|
-
|
|
109
106
|
//#endregion
|
|
110
107
|
//#region src/globs.ts
|
|
111
108
|
const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -179,7 +176,6 @@ const GLOB_EXCLUDE = [
|
|
|
179
176
|
"**/auto-import?(s).d.ts",
|
|
180
177
|
"**/components.d.ts"
|
|
181
178
|
];
|
|
182
|
-
|
|
183
179
|
//#endregion
|
|
184
180
|
//#region src/configs/disables.ts
|
|
185
181
|
async function disables() {
|
|
@@ -235,7 +231,26 @@ async function disables() {
|
|
|
235
231
|
}
|
|
236
232
|
];
|
|
237
233
|
}
|
|
238
|
-
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/configs/e18e.ts
|
|
236
|
+
async function e18e(options = {}) {
|
|
237
|
+
const { isInEditor = false, modernization = true, type = "app", moduleReplacements = type === "lib" && isInEditor, overrides = {}, performanceImprovements = true } = options;
|
|
238
|
+
const configs = _e18e_eslint_plugin.default.configs;
|
|
239
|
+
return [{
|
|
240
|
+
name: "eslint/e18e/rules",
|
|
241
|
+
plugins: { e18e: _e18e_eslint_plugin.default },
|
|
242
|
+
rules: {
|
|
243
|
+
...modernization ? { ...configs.modernization.rules } : {},
|
|
244
|
+
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
245
|
+
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
246
|
+
"e18e/prefer-array-to-reversed": "off",
|
|
247
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
248
|
+
"e18e/prefer-array-to-spliced": "off",
|
|
249
|
+
"e18e/prefer-spread-syntax": "off",
|
|
250
|
+
...overrides
|
|
251
|
+
}
|
|
252
|
+
}];
|
|
253
|
+
}
|
|
239
254
|
//#endregion
|
|
240
255
|
//#region src/utils.ts
|
|
241
256
|
const scopeUrl = (0, node_url.fileURLToPath)(new URL(".", require("url").pathToFileURL(__filename).href));
|
|
@@ -262,8 +277,8 @@ const parserPlain = {
|
|
|
262
277
|
/**
|
|
263
278
|
* Combine array and non-array configs into a single array.
|
|
264
279
|
*/
|
|
265
|
-
async function combine(...configs
|
|
266
|
-
return (await Promise.all(configs
|
|
280
|
+
async function combine(...configs) {
|
|
281
|
+
return (await Promise.all(configs)).flat();
|
|
267
282
|
}
|
|
268
283
|
function renameRules(rules, map) {
|
|
269
284
|
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
@@ -271,8 +286,8 @@ function renameRules(rules, map) {
|
|
|
271
286
|
return [key, value];
|
|
272
287
|
}));
|
|
273
288
|
}
|
|
274
|
-
function renamePluginInConfigs(configs
|
|
275
|
-
return configs
|
|
289
|
+
function renamePluginInConfigs(configs, map) {
|
|
290
|
+
return configs.map((i) => {
|
|
276
291
|
const clone = { ...i };
|
|
277
292
|
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
278
293
|
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
@@ -306,26 +321,26 @@ function isInEditorEnv() {
|
|
|
306
321
|
function isInGitHooksOrLintStaged() {
|
|
307
322
|
return !!(node_process.default.env.GIT_PARAMS || node_process.default.env.VSCODE_GIT_COMMAND || node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
308
323
|
}
|
|
309
|
-
|
|
310
324
|
//#endregion
|
|
311
325
|
//#region src/configs/stylistic.ts
|
|
312
326
|
const StylisticConfigDefaults = {
|
|
313
327
|
indent: 4,
|
|
314
328
|
jsx: true,
|
|
315
329
|
lessOpinionated: false,
|
|
330
|
+
other_indent: 2,
|
|
316
331
|
quotes: "single",
|
|
317
332
|
semi: false
|
|
318
333
|
};
|
|
319
334
|
async function stylistic(options = {}) {
|
|
320
|
-
const { overrides = {}, stylistic
|
|
321
|
-
const { indent, jsx
|
|
335
|
+
const { overrides = {}, stylistic = StylisticConfigDefaults } = options;
|
|
336
|
+
const { indent, jsx, lessOpinionated, quotes, semi } = typeof stylistic === "boolean" ? StylisticConfigDefaults : {
|
|
322
337
|
...StylisticConfigDefaults,
|
|
323
|
-
...stylistic
|
|
338
|
+
...stylistic
|
|
324
339
|
};
|
|
325
340
|
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
326
341
|
const config = pluginStylistic.configs.customize({
|
|
327
342
|
indent,
|
|
328
|
-
jsx
|
|
343
|
+
jsx,
|
|
329
344
|
pluginName: "style",
|
|
330
345
|
quotes,
|
|
331
346
|
semi
|
|
@@ -359,7 +374,6 @@ async function stylistic(options = {}) {
|
|
|
359
374
|
}
|
|
360
375
|
}];
|
|
361
376
|
}
|
|
362
|
-
|
|
363
377
|
//#endregion
|
|
364
378
|
//#region src/configs/formatters.ts
|
|
365
379
|
function mergePrettierOptions(options, overrides) {
|
|
@@ -369,18 +383,18 @@ function mergePrettierOptions(options, overrides) {
|
|
|
369
383
|
plugins: [...overrides.plugins || [], ...options.plugins || []]
|
|
370
384
|
};
|
|
371
385
|
}
|
|
372
|
-
async function formatters(options = {}, stylistic
|
|
386
|
+
async function formatters(options = {}, stylistic = {}) {
|
|
373
387
|
const defaultIndent = 4;
|
|
374
388
|
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
375
389
|
if (options === true) {
|
|
376
|
-
const isPrettierPluginXmlInScope
|
|
390
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
377
391
|
options = {
|
|
378
392
|
css: false,
|
|
379
393
|
graphql: true,
|
|
380
394
|
html: true,
|
|
381
395
|
markdown: true,
|
|
382
|
-
svg: isPrettierPluginXmlInScope
|
|
383
|
-
xml: isPrettierPluginXmlInScope
|
|
396
|
+
svg: isPrettierPluginXmlInScope,
|
|
397
|
+
xml: isPrettierPluginXmlInScope
|
|
384
398
|
};
|
|
385
399
|
} else options = {
|
|
386
400
|
css: options.css ?? false,
|
|
@@ -393,7 +407,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
393
407
|
await ensurePackages(["eslint-plugin-format", options.xml || options.svg ? "@prettier/plugin-xml" : void 0]);
|
|
394
408
|
const { indent, quotes, semi } = {
|
|
395
409
|
...StylisticConfigDefaults,
|
|
396
|
-
...stylistic
|
|
410
|
+
...stylistic
|
|
397
411
|
};
|
|
398
412
|
const prettierOptions = Object.assign({
|
|
399
413
|
endOfLine: "lf",
|
|
@@ -410,16 +424,17 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
410
424
|
xmlSortAttributesByKey: false,
|
|
411
425
|
xmlWhitespaceSensitivity: "ignore"
|
|
412
426
|
};
|
|
413
|
-
const dprintOptions =
|
|
427
|
+
const dprintOptions = {
|
|
414
428
|
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
415
429
|
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
416
|
-
useTabs: indent === "tab"
|
|
417
|
-
|
|
418
|
-
|
|
430
|
+
useTabs: indent === "tab",
|
|
431
|
+
...typeof options.dprintOptions === "boolean" ? {} : options.dprintOptions || {}
|
|
432
|
+
};
|
|
433
|
+
const configs = [{
|
|
419
434
|
name: "eslint/formatter/setup",
|
|
420
435
|
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
421
436
|
}];
|
|
422
|
-
if (options.css) configs
|
|
437
|
+
if (options.css) configs.push({
|
|
423
438
|
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
424
439
|
languageOptions: { parser: parserPlain },
|
|
425
440
|
name: "eslint/formatter/css",
|
|
@@ -435,13 +450,13 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
435
450
|
name: "eslint/formatter/less",
|
|
436
451
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
|
|
437
452
|
});
|
|
438
|
-
if (options.html) configs
|
|
453
|
+
if (options.html) configs.push({
|
|
439
454
|
files: [GLOB_HTML],
|
|
440
455
|
languageOptions: { parser: parserPlain },
|
|
441
456
|
name: "eslint/formatter/html",
|
|
442
457
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
443
458
|
});
|
|
444
|
-
if (options.xml) configs
|
|
459
|
+
if (options.xml) configs.push({
|
|
445
460
|
files: [GLOB_XML],
|
|
446
461
|
languageOptions: { parser: parserPlain },
|
|
447
462
|
name: "eslint/formatter/xml",
|
|
@@ -453,7 +468,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
453
468
|
plugins: ["@prettier/plugin-xml"]
|
|
454
469
|
})] }
|
|
455
470
|
});
|
|
456
|
-
if (options.svg) configs
|
|
471
|
+
if (options.svg) configs.push({
|
|
457
472
|
files: [GLOB_SVG],
|
|
458
473
|
languageOptions: { parser: parserPlain },
|
|
459
474
|
name: "eslint/formatter/svg",
|
|
@@ -467,7 +482,7 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
467
482
|
});
|
|
468
483
|
if (options.markdown) {
|
|
469
484
|
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
470
|
-
configs
|
|
485
|
+
configs.push({
|
|
471
486
|
files: [GLOB_MARKDOWN],
|
|
472
487
|
ignores: [],
|
|
473
488
|
languageOptions: { parser: parserPlain },
|
|
@@ -481,29 +496,30 @@ async function formatters(options = {}, stylistic$1 = {}) {
|
|
|
481
496
|
}] }
|
|
482
497
|
});
|
|
483
498
|
}
|
|
484
|
-
if (options.graphql) configs
|
|
499
|
+
if (options.graphql) configs.push({
|
|
485
500
|
files: [GLOB_GRAPHQL],
|
|
486
501
|
languageOptions: { parser: parserPlain },
|
|
487
502
|
name: "eslint/formatter/graphql",
|
|
488
503
|
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
489
504
|
});
|
|
490
|
-
return configs
|
|
505
|
+
return configs;
|
|
491
506
|
}
|
|
492
|
-
|
|
493
507
|
//#endregion
|
|
494
508
|
//#region src/configs/ignores.ts
|
|
495
|
-
async function ignores(
|
|
496
|
-
|
|
509
|
+
async function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
510
|
+
let ignores = [...GLOB_EXCLUDE];
|
|
511
|
+
if (ignoreTypeScript) ignores.push(GLOB_TS, GLOB_TSX);
|
|
512
|
+
if (typeof userIgnores === "function") ignores = userIgnores(ignores);
|
|
513
|
+
else ignores = [...ignores, ...userIgnores];
|
|
497
514
|
return [{
|
|
498
|
-
ignores
|
|
515
|
+
ignores,
|
|
499
516
|
name: "eslint/ignores"
|
|
500
517
|
}];
|
|
501
518
|
}
|
|
502
|
-
|
|
503
519
|
//#endregion
|
|
504
520
|
//#region src/configs/imports.ts
|
|
505
521
|
async function imports(options = {}) {
|
|
506
|
-
const { overrides = {}, stylistic
|
|
522
|
+
const { overrides = {}, stylistic = true } = options;
|
|
507
523
|
return [{
|
|
508
524
|
name: "eslint/imports/rules",
|
|
509
525
|
plugins: {
|
|
@@ -519,12 +535,11 @@ async function imports(options = {}) {
|
|
|
519
535
|
"import/no-duplicates": "error",
|
|
520
536
|
"import/no-mutable-exports": "error",
|
|
521
537
|
"import/no-named-default": "error",
|
|
522
|
-
...stylistic
|
|
538
|
+
...stylistic ? { "import/newline-after-import": ["error", { count: 1 }] } : {},
|
|
523
539
|
...overrides
|
|
524
540
|
}
|
|
525
541
|
}];
|
|
526
542
|
}
|
|
527
|
-
|
|
528
543
|
//#endregion
|
|
529
544
|
//#region src/configs/javascript.ts
|
|
530
545
|
async function javascript(options = {}) {
|
|
@@ -749,11 +764,10 @@ async function javascript(options = {}) {
|
|
|
749
764
|
}
|
|
750
765
|
}];
|
|
751
766
|
}
|
|
752
|
-
|
|
753
767
|
//#endregion
|
|
754
768
|
//#region src/configs/jsdoc.ts
|
|
755
769
|
async function jsdoc(options = {}) {
|
|
756
|
-
const { overrides = {}, stylistic
|
|
770
|
+
const { overrides = {}, stylistic = true } = options;
|
|
757
771
|
return [{
|
|
758
772
|
name: "eslint/jsdoc/setup",
|
|
759
773
|
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
|
|
@@ -776,7 +790,7 @@ async function jsdoc(options = {}) {
|
|
|
776
790
|
"jsdoc/require-returns-check": "warn",
|
|
777
791
|
"jsdoc/require-returns-description": "warn",
|
|
778
792
|
"jsdoc/require-yields-check": "warn",
|
|
779
|
-
...stylistic
|
|
793
|
+
...stylistic ? {
|
|
780
794
|
"jsdoc/check-alignment": "warn",
|
|
781
795
|
"jsdoc/multiline-blocks": "warn"
|
|
782
796
|
} : {},
|
|
@@ -784,7 +798,6 @@ async function jsdoc(options = {}) {
|
|
|
784
798
|
}
|
|
785
799
|
}];
|
|
786
800
|
}
|
|
787
|
-
|
|
788
801
|
//#endregion
|
|
789
802
|
//#region src/configs/jsonc.ts
|
|
790
803
|
async function jsonc(options = {}) {
|
|
@@ -792,7 +805,8 @@ async function jsonc(options = {}) {
|
|
|
792
805
|
GLOB_JSON,
|
|
793
806
|
GLOB_JSON5,
|
|
794
807
|
GLOB_JSONC
|
|
795
|
-
], overrides = {}, stylistic
|
|
808
|
+
], overrides = {}, stylistic = true } = options;
|
|
809
|
+
const { other_indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
796
810
|
return [{
|
|
797
811
|
name: "eslint/jsonc/setup",
|
|
798
812
|
plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
|
|
@@ -827,11 +841,11 @@ async function jsonc(options = {}) {
|
|
|
827
841
|
"jsonc/space-unary-ops": "error",
|
|
828
842
|
"jsonc/valid-json-number": "error",
|
|
829
843
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
830
|
-
...stylistic
|
|
844
|
+
...stylistic ? {
|
|
831
845
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
832
846
|
"jsonc/comma-dangle": ["error", "never"],
|
|
833
847
|
"jsonc/comma-style": ["error", "last"],
|
|
834
|
-
"jsonc/indent": ["error", 2],
|
|
848
|
+
"jsonc/indent": ["error", typeof other_indent === "number" ? other_indent : 2],
|
|
835
849
|
"jsonc/key-spacing": ["error", {
|
|
836
850
|
afterColon: true,
|
|
837
851
|
beforeColon: false
|
|
@@ -849,7 +863,6 @@ async function jsonc(options = {}) {
|
|
|
849
863
|
}
|
|
850
864
|
}];
|
|
851
865
|
}
|
|
852
|
-
|
|
853
866
|
//#endregion
|
|
854
867
|
//#region src/configs/jsx.ts
|
|
855
868
|
async function jsx() {
|
|
@@ -859,22 +872,21 @@ async function jsx() {
|
|
|
859
872
|
name: "eslint/jsx/setup"
|
|
860
873
|
}];
|
|
861
874
|
}
|
|
862
|
-
|
|
863
875
|
//#endregion
|
|
864
876
|
//#region src/configs/markdown.ts
|
|
865
877
|
async function markdown(options = {}) {
|
|
866
878
|
const { componentExts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
|
|
867
|
-
const markdown
|
|
879
|
+
const markdown = await interopDefault(import("@eslint/markdown"));
|
|
868
880
|
return [
|
|
869
881
|
{
|
|
870
882
|
name: "eslint/markdown/setup",
|
|
871
|
-
plugins: { markdown
|
|
883
|
+
plugins: { markdown }
|
|
872
884
|
},
|
|
873
885
|
{
|
|
874
886
|
files,
|
|
875
887
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
876
888
|
name: "eslint/markdown/processor",
|
|
877
|
-
processor: (0, eslint_merge_processors.mergeProcessors)([markdown
|
|
889
|
+
processor: (0, eslint_merge_processors.mergeProcessors)([markdown.processors.markdown, eslint_merge_processors.processorPassThrough])
|
|
878
890
|
},
|
|
879
891
|
{
|
|
880
892
|
files,
|
|
@@ -885,7 +897,8 @@ async function markdown(options = {}) {
|
|
|
885
897
|
files,
|
|
886
898
|
name: "eslint/markdown/rules",
|
|
887
899
|
rules: {
|
|
888
|
-
...markdown
|
|
900
|
+
...markdown.configs.recommended.at(0)?.rules,
|
|
901
|
+
"markdown/fenced-code-language": "off",
|
|
889
902
|
"markdown/no-missing-label-refs": "off",
|
|
890
903
|
...overridesMarkdown
|
|
891
904
|
}
|
|
@@ -911,7 +924,7 @@ async function markdown(options = {}) {
|
|
|
911
924
|
name: "eslint/markdown/disables/code",
|
|
912
925
|
rules: {
|
|
913
926
|
"antfu/no-top-level-await": "off",
|
|
914
|
-
"
|
|
927
|
+
"e18e/prefer-static-regex": "off",
|
|
915
928
|
"no-alert": "off",
|
|
916
929
|
"no-console": "off",
|
|
917
930
|
"no-labels": "off",
|
|
@@ -924,6 +937,7 @@ async function markdown(options = {}) {
|
|
|
924
937
|
"node/prefer-global/process": "off",
|
|
925
938
|
"style/comma-dangle": "off",
|
|
926
939
|
"style/eol-last": "off",
|
|
940
|
+
"style/padding-line-between-statements": "off",
|
|
927
941
|
"ts/consistent-type-imports": "off",
|
|
928
942
|
"ts/explicit-function-return-type": "off",
|
|
929
943
|
"ts/no-namespace": "off",
|
|
@@ -935,27 +949,11 @@ async function markdown(options = {}) {
|
|
|
935
949
|
"unicode-bom": "off",
|
|
936
950
|
"unused-imports/no-unused-imports": "off",
|
|
937
951
|
"unused-imports/no-unused-vars": "off",
|
|
938
|
-
"ts/await-thenable": "off",
|
|
939
|
-
"ts/dot-notation": "off",
|
|
940
|
-
"ts/no-floating-promises": "off",
|
|
941
|
-
"ts/no-for-in-array": "off",
|
|
942
|
-
"ts/no-implied-eval": "off",
|
|
943
|
-
"ts/no-misused-promises": "off",
|
|
944
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
945
|
-
"ts/no-unsafe-argument": "off",
|
|
946
|
-
"ts/no-unsafe-assignment": "off",
|
|
947
|
-
"ts/no-unsafe-call": "off",
|
|
948
|
-
"ts/no-unsafe-member-access": "off",
|
|
949
|
-
"ts/no-unsafe-return": "off",
|
|
950
|
-
"ts/restrict-plus-operands": "off",
|
|
951
|
-
"ts/restrict-template-expressions": "off",
|
|
952
|
-
"ts/unbound-method": "off",
|
|
953
952
|
...overrides
|
|
954
953
|
}
|
|
955
954
|
}
|
|
956
955
|
];
|
|
957
956
|
}
|
|
958
|
-
|
|
959
957
|
//#endregion
|
|
960
958
|
//#region src/configs/nextjs.ts
|
|
961
959
|
function normalizeRules(rules) {
|
|
@@ -988,7 +986,6 @@ async function nextjs(options = {}) {
|
|
|
988
986
|
settings: { react: { version: "detect" } }
|
|
989
987
|
}];
|
|
990
988
|
}
|
|
991
|
-
|
|
992
989
|
//#endregion
|
|
993
990
|
//#region src/configs/node.ts
|
|
994
991
|
async function node(options = {}) {
|
|
@@ -1012,7 +1009,6 @@ async function node(options = {}) {
|
|
|
1012
1009
|
}
|
|
1013
1010
|
}];
|
|
1014
1011
|
}
|
|
1015
|
-
|
|
1016
1012
|
//#endregion
|
|
1017
1013
|
//#region src/configs/perfectionist.ts
|
|
1018
1014
|
/**
|
|
@@ -1068,14 +1064,13 @@ async function perfectionist(options = {}) {
|
|
|
1068
1064
|
}
|
|
1069
1065
|
}];
|
|
1070
1066
|
}
|
|
1071
|
-
|
|
1072
1067
|
//#endregion
|
|
1073
1068
|
//#region src/configs/pnpm.ts
|
|
1074
1069
|
async function detectCatalogUsage() {
|
|
1075
1070
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1076
1071
|
if (!workspaceFile) return false;
|
|
1077
|
-
const yaml
|
|
1078
|
-
return yaml
|
|
1072
|
+
const yaml = await node_fs_promises.default.readFile(workspaceFile, "utf-8");
|
|
1073
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1079
1074
|
}
|
|
1080
1075
|
async function pnpm(options) {
|
|
1081
1076
|
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
@@ -1083,9 +1078,9 @@ async function pnpm(options) {
|
|
|
1083
1078
|
interopDefault(import("eslint-plugin-yml")),
|
|
1084
1079
|
interopDefault(import("yaml-eslint-parser"))
|
|
1085
1080
|
]);
|
|
1086
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1087
|
-
const configs
|
|
1088
|
-
if (json) configs
|
|
1081
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
|
|
1082
|
+
const configs = [];
|
|
1083
|
+
if (json) configs.push({
|
|
1089
1084
|
files: ["package.json", "**/package.json"],
|
|
1090
1085
|
language: "jsonc/x",
|
|
1091
1086
|
name: "eslint/pnpm/package-json",
|
|
@@ -1099,8 +1094,8 @@ async function pnpm(options) {
|
|
|
1099
1094
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1100
1095
|
}
|
|
1101
1096
|
});
|
|
1102
|
-
if (yaml
|
|
1103
|
-
configs
|
|
1097
|
+
if (yaml) {
|
|
1098
|
+
configs.push({
|
|
1104
1099
|
files: ["pnpm-workspace.yaml"],
|
|
1105
1100
|
languageOptions: { parser: yamlParser },
|
|
1106
1101
|
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
@@ -1114,7 +1109,7 @@ async function pnpm(options) {
|
|
|
1114
1109
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1115
1110
|
}
|
|
1116
1111
|
});
|
|
1117
|
-
if (sort) configs
|
|
1112
|
+
if (sort) configs.push({
|
|
1118
1113
|
files: ["pnpm-workspace.yaml"],
|
|
1119
1114
|
languageOptions: { parser: yamlParser },
|
|
1120
1115
|
name: "eslint/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1193,9 +1188,8 @@ async function pnpm(options) {
|
|
|
1193
1188
|
] }
|
|
1194
1189
|
});
|
|
1195
1190
|
}
|
|
1196
|
-
return configs
|
|
1191
|
+
return configs;
|
|
1197
1192
|
}
|
|
1198
|
-
|
|
1199
1193
|
//#endregion
|
|
1200
1194
|
//#region src/configs/react.ts
|
|
1201
1195
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1212,24 +1206,12 @@ const ReactRouterPackages = [
|
|
|
1212
1206
|
"@react-router/dev"
|
|
1213
1207
|
];
|
|
1214
1208
|
const NextJsPackages = ["next"];
|
|
1215
|
-
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
1216
1209
|
async function react(options = {}) {
|
|
1217
|
-
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {},
|
|
1218
|
-
await ensurePackages([
|
|
1219
|
-
"@eslint-react/eslint-plugin",
|
|
1220
|
-
"eslint-plugin-react-hooks",
|
|
1221
|
-
"eslint-plugin-react-refresh"
|
|
1222
|
-
]);
|
|
1210
|
+
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {}, tsconfigPath } = options;
|
|
1211
|
+
await ensurePackages(["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"]);
|
|
1223
1212
|
const isTypeAware = !!tsconfigPath;
|
|
1224
|
-
const typeAwareRules = {
|
|
1225
|
-
|
|
1226
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1227
|
-
};
|
|
1228
|
-
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1229
|
-
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1230
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1231
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1232
|
-
]);
|
|
1213
|
+
const typeAwareRules = { "react/no-leaked-conditional-rendering": "error" };
|
|
1214
|
+
const [pluginReact, pluginReactRefresh] = await Promise.all([interopDefault(import("@eslint-react/eslint-plugin")), interopDefault(import("eslint-plugin-react-refresh"))]);
|
|
1233
1215
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1234
1216
|
const isUsingRemix = RemixPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1235
1217
|
const isUsingReactRouter = ReactRouterPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
@@ -1241,8 +1223,6 @@ async function react(options = {}) {
|
|
|
1241
1223
|
plugins: {
|
|
1242
1224
|
"react": plugins["@eslint-react"],
|
|
1243
1225
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1244
|
-
"react-hooks": pluginReactHooks,
|
|
1245
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1246
1226
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1247
1227
|
"react-refresh": pluginReactRefresh,
|
|
1248
1228
|
"react-rsc": plugins["@eslint-react/rsc"],
|
|
@@ -1257,85 +1237,7 @@ async function react(options = {}) {
|
|
|
1257
1237
|
},
|
|
1258
1238
|
name: "eslint/react/rules",
|
|
1259
1239
|
rules: {
|
|
1260
|
-
|
|
1261
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1262
|
-
"react-dom/no-find-dom-node": "error",
|
|
1263
|
-
"react-dom/no-flush-sync": "error",
|
|
1264
|
-
"react-dom/no-hydrate": "error",
|
|
1265
|
-
"react-dom/no-namespace": "error",
|
|
1266
|
-
"react-dom/no-render": "error",
|
|
1267
|
-
"react-dom/no-render-return-value": "error",
|
|
1268
|
-
"react-dom/no-script-url": "warn",
|
|
1269
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1270
|
-
"react-dom/no-use-form-state": "error",
|
|
1271
|
-
"react-dom/no-void-elements-with-children": "error",
|
|
1272
|
-
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1273
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1274
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1275
|
-
"react-naming-convention/context-name": "warn",
|
|
1276
|
-
"react-naming-convention/ref-name": "warn",
|
|
1277
|
-
"react-naming-convention/use-state": "warn",
|
|
1278
|
-
"react-rsc/function-definition": "error",
|
|
1279
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1280
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1281
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1282
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1283
|
-
"react/jsx-key-before-spread": "warn",
|
|
1284
|
-
"react/jsx-no-comment-textnodes": "warn",
|
|
1285
|
-
"react/jsx-no-duplicate-props": "warn",
|
|
1286
|
-
"react/jsx-uses-react": "warn",
|
|
1287
|
-
"react/jsx-uses-vars": "warn",
|
|
1288
|
-
"react/no-access-state-in-setstate": "error",
|
|
1289
|
-
"react/no-array-index-key": "warn",
|
|
1290
|
-
"react/no-children-count": "warn",
|
|
1291
|
-
"react/no-children-for-each": "warn",
|
|
1292
|
-
"react/no-children-map": "warn",
|
|
1293
|
-
"react/no-children-only": "warn",
|
|
1294
|
-
"react/no-children-to-array": "warn",
|
|
1295
|
-
"react/no-clone-element": "warn",
|
|
1296
|
-
"react/no-component-will-mount": "error",
|
|
1297
|
-
"react/no-component-will-receive-props": "error",
|
|
1298
|
-
"react/no-component-will-update": "error",
|
|
1299
|
-
"react/no-context-provider": "warn",
|
|
1300
|
-
"react/no-create-ref": "error",
|
|
1301
|
-
"react/no-default-props": "error",
|
|
1302
|
-
"react/no-direct-mutation-state": "error",
|
|
1303
|
-
"react/no-forward-ref": "warn",
|
|
1304
|
-
"react/no-missing-key": "error",
|
|
1305
|
-
"react/no-nested-component-definitions": "error",
|
|
1306
|
-
"react/no-nested-lazy-component-declarations": "error",
|
|
1307
|
-
"react/no-prop-types": "error",
|
|
1308
|
-
"react/no-redundant-should-component-update": "error",
|
|
1309
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
1310
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
1311
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
1312
|
-
"react/no-string-refs": "error",
|
|
1313
|
-
"react/no-unnecessary-use-prefix": "warn",
|
|
1314
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
1315
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1316
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
1317
|
-
"react/no-unused-class-component-members": "warn",
|
|
1318
|
-
"react/no-use-context": "warn",
|
|
1319
|
-
"react/no-useless-forward-ref": "warn",
|
|
1320
|
-
"react/prefer-namespace-import": "error",
|
|
1321
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1322
|
-
...reactCompiler ? {
|
|
1323
|
-
"react-hooks/component-hook-factories": "error",
|
|
1324
|
-
"react-hooks/config": "error",
|
|
1325
|
-
"react-hooks/error-boundaries": "error",
|
|
1326
|
-
"react-hooks/gating": "error",
|
|
1327
|
-
"react-hooks/globals": "error",
|
|
1328
|
-
"react-hooks/immutability": "error",
|
|
1329
|
-
"react-hooks/incompatible-library": "warn",
|
|
1330
|
-
"react-hooks/preserve-manual-memoization": "error",
|
|
1331
|
-
"react-hooks/purity": "error",
|
|
1332
|
-
"react-hooks/refs": "error",
|
|
1333
|
-
"react-hooks/set-state-in-effect": "error",
|
|
1334
|
-
"react-hooks/set-state-in-render": "error",
|
|
1335
|
-
"react-hooks/static-components": "error",
|
|
1336
|
-
"react-hooks/unsupported-syntax": "warn",
|
|
1337
|
-
"react-hooks/use-memo": "error"
|
|
1338
|
-
} : {},
|
|
1240
|
+
...pluginReact.configs.recommended.rules,
|
|
1339
1241
|
"react-refresh/only-export-components": ["error", {
|
|
1340
1242
|
allowConstantExport: isAllowConstantExport,
|
|
1341
1243
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1365,6 +1267,7 @@ async function react(options = {}) {
|
|
|
1365
1267
|
"shouldRevalidate"
|
|
1366
1268
|
] : []]
|
|
1367
1269
|
}],
|
|
1270
|
+
"react/prefer-namespace-import": "error",
|
|
1368
1271
|
...overrides
|
|
1369
1272
|
}
|
|
1370
1273
|
},
|
|
@@ -1373,11 +1276,7 @@ async function react(options = {}) {
|
|
|
1373
1276
|
name: "eslint/react/typescript",
|
|
1374
1277
|
rules: {
|
|
1375
1278
|
"react-dom/no-string-style-prop": "off",
|
|
1376
|
-
"react-dom/no-unknown-property": "off"
|
|
1377
|
-
"react/jsx-no-duplicate-props": "off",
|
|
1378
|
-
"react/jsx-no-undef": "off",
|
|
1379
|
-
"react/jsx-uses-react": "off",
|
|
1380
|
-
"react/jsx-uses-vars": "off"
|
|
1279
|
+
"react-dom/no-unknown-property": "off"
|
|
1381
1280
|
}
|
|
1382
1281
|
},
|
|
1383
1282
|
...isTypeAware ? [{
|
|
@@ -1388,7 +1287,6 @@ async function react(options = {}) {
|
|
|
1388
1287
|
}] : []
|
|
1389
1288
|
];
|
|
1390
1289
|
}
|
|
1391
|
-
|
|
1392
1290
|
//#endregion
|
|
1393
1291
|
//#region src/configs/regexp.ts
|
|
1394
1292
|
async function regexp(options = {}) {
|
|
@@ -1406,7 +1304,6 @@ async function regexp(options = {}) {
|
|
|
1406
1304
|
}
|
|
1407
1305
|
}];
|
|
1408
1306
|
}
|
|
1409
|
-
|
|
1410
1307
|
//#endregion
|
|
1411
1308
|
//#region src/configs/sort.ts
|
|
1412
1309
|
/**
|
|
@@ -1639,7 +1536,6 @@ function sortTsconfig() {
|
|
|
1639
1536
|
] }
|
|
1640
1537
|
}];
|
|
1641
1538
|
}
|
|
1642
|
-
|
|
1643
1539
|
//#endregion
|
|
1644
1540
|
//#region src/configs/test.ts
|
|
1645
1541
|
async function test(options = {}) {
|
|
@@ -1668,6 +1564,7 @@ async function test(options = {}) {
|
|
|
1668
1564
|
"test/prefer-hooks-in-order": "error",
|
|
1669
1565
|
"test/prefer-lowercase-title": "error",
|
|
1670
1566
|
"antfu/no-top-level-await": "off",
|
|
1567
|
+
"e18e/prefer-static-regex": "off",
|
|
1671
1568
|
"no-unused-expressions": "off",
|
|
1672
1569
|
"node/prefer-global/process": "off",
|
|
1673
1570
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1675,12 +1572,11 @@ async function test(options = {}) {
|
|
|
1675
1572
|
}
|
|
1676
1573
|
}];
|
|
1677
1574
|
}
|
|
1678
|
-
|
|
1679
1575
|
//#endregion
|
|
1680
1576
|
//#region src/configs/toml.ts
|
|
1681
1577
|
async function toml(options = {}) {
|
|
1682
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1683
|
-
const {
|
|
1578
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1579
|
+
const { other_indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1684
1580
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1685
1581
|
return [{
|
|
1686
1582
|
name: "eslint/toml/setup",
|
|
@@ -1699,11 +1595,11 @@ async function toml(options = {}) {
|
|
|
1699
1595
|
"toml/precision-of-integer": "error",
|
|
1700
1596
|
"toml/tables-order": "error",
|
|
1701
1597
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1702
|
-
...stylistic
|
|
1598
|
+
...stylistic ? {
|
|
1703
1599
|
"toml/array-bracket-newline": "error",
|
|
1704
1600
|
"toml/array-bracket-spacing": "error",
|
|
1705
1601
|
"toml/array-element-newline": "error",
|
|
1706
|
-
"toml/indent": ["error", typeof
|
|
1602
|
+
"toml/indent": ["error", typeof other_indent === "number" ? other_indent : other_indent === "tab" ? "tab" : 4],
|
|
1707
1603
|
"toml/inline-table-curly-spacing": "error",
|
|
1708
1604
|
"toml/key-spacing": "error",
|
|
1709
1605
|
"toml/padding-line-between-pairs": "error",
|
|
@@ -1716,14 +1612,13 @@ async function toml(options = {}) {
|
|
|
1716
1612
|
}
|
|
1717
1613
|
}];
|
|
1718
1614
|
}
|
|
1719
|
-
|
|
1720
1615
|
//#endregion
|
|
1721
1616
|
//#region src/configs/typescript.ts
|
|
1722
1617
|
async function typescript(options = {}) {
|
|
1723
1618
|
const { componentExts = [], erasableOnly = false, overrides = {}, parserOptions = {}, type = "app" } = options;
|
|
1724
|
-
const files = options.files ?? [
|
|
1725
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1726
|
-
const filesTypeAware = options.filesTypeAware ?? [
|
|
1619
|
+
const files = options.files ?? ["**/*.?([cm])[jt]s?(x)", ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
1620
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [`**/*.md/**`];
|
|
1621
|
+
const filesTypeAware = options.filesTypeAware ?? ["**/*.?([cm])ts", "**/*.?([cm])tsx"];
|
|
1727
1622
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1728
1623
|
const isTypeAware = !!tsconfigPath;
|
|
1729
1624
|
const typeAwareRules = {
|
|
@@ -1753,10 +1648,10 @@ async function typescript(options = {}) {
|
|
|
1753
1648
|
"ts/unbound-method": "error"
|
|
1754
1649
|
};
|
|
1755
1650
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1756
|
-
function makeParser(typeAware, files
|
|
1651
|
+
function makeParser(typeAware, files, ignores) {
|
|
1757
1652
|
return {
|
|
1758
|
-
files
|
|
1759
|
-
...ignores
|
|
1653
|
+
files,
|
|
1654
|
+
...ignores ? { ignores } : {},
|
|
1760
1655
|
languageOptions: {
|
|
1761
1656
|
parser: parserTs,
|
|
1762
1657
|
parserOptions: {
|
|
@@ -1866,7 +1761,6 @@ async function typescript(options = {}) {
|
|
|
1866
1761
|
}] : []
|
|
1867
1762
|
];
|
|
1868
1763
|
}
|
|
1869
|
-
|
|
1870
1764
|
//#endregion
|
|
1871
1765
|
//#region src/configs/unicorn.ts
|
|
1872
1766
|
async function unicorn(options = {}) {
|
|
@@ -1896,7 +1790,6 @@ async function unicorn(options = {}) {
|
|
|
1896
1790
|
}
|
|
1897
1791
|
}];
|
|
1898
1792
|
}
|
|
1899
|
-
|
|
1900
1793
|
//#endregion
|
|
1901
1794
|
//#region src/configs/unocss.ts
|
|
1902
1795
|
async function unocss(options = {}) {
|
|
@@ -1914,7 +1807,6 @@ async function unocss(options = {}) {
|
|
|
1914
1807
|
}
|
|
1915
1808
|
}];
|
|
1916
1809
|
}
|
|
1917
|
-
|
|
1918
1810
|
//#endregion
|
|
1919
1811
|
//#region src/configs/vue.ts
|
|
1920
1812
|
const pkg = (0, local_pkg.getPackageInfoSync)("vue");
|
|
@@ -1922,9 +1814,9 @@ let vueVersion = pkg && pkg.version;
|
|
|
1922
1814
|
vueVersion = vueVersion && vueVersion[0];
|
|
1923
1815
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
1924
1816
|
async function vue(options = {}) {
|
|
1925
|
-
const { files = [GLOB_VUE], overrides = {}, stylistic
|
|
1817
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic = true } = options;
|
|
1926
1818
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1927
|
-
const { indent = 4 } = typeof stylistic
|
|
1819
|
+
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1928
1820
|
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1929
1821
|
interopDefault(import("eslint-plugin-vue")),
|
|
1930
1822
|
interopDefault(import("vue-eslint-parser")),
|
|
@@ -2077,7 +1969,7 @@ async function vue(options = {}) {
|
|
|
2077
1969
|
nonwords: false,
|
|
2078
1970
|
words: true
|
|
2079
1971
|
}],
|
|
2080
|
-
...stylistic
|
|
1972
|
+
...stylistic ? {
|
|
2081
1973
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2082
1974
|
"vue/arrow-spacing": ["error", {
|
|
2083
1975
|
after: true,
|
|
@@ -2125,12 +2017,11 @@ async function vue(options = {}) {
|
|
|
2125
2017
|
}
|
|
2126
2018
|
}];
|
|
2127
2019
|
}
|
|
2128
|
-
|
|
2129
2020
|
//#endregion
|
|
2130
2021
|
//#region src/configs/yaml.ts
|
|
2131
2022
|
async function yaml(options = {}) {
|
|
2132
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2133
|
-
const { quotes = "single" } = typeof stylistic
|
|
2023
|
+
const { files = [GLOB_YAML], overrides = {}, stylistic = true } = options;
|
|
2024
|
+
const { other_indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
2134
2025
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2135
2026
|
return [{
|
|
2136
2027
|
name: "eslint/yaml/setup",
|
|
@@ -2148,14 +2039,14 @@ async function yaml(options = {}) {
|
|
|
2148
2039
|
"yaml/no-irregular-whitespace": "error",
|
|
2149
2040
|
"yaml/plain-scalar": "error",
|
|
2150
2041
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2151
|
-
...stylistic
|
|
2042
|
+
...stylistic ? {
|
|
2152
2043
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2153
2044
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2154
2045
|
"yaml/flow-mapping-curly-newline": "error",
|
|
2155
2046
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
2156
2047
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
2157
2048
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2158
|
-
"yaml/indent": ["error", 2],
|
|
2049
|
+
"yaml/indent": ["error", typeof other_indent === "number" ? other_indent : 2],
|
|
2159
2050
|
"yaml/key-spacing": "error",
|
|
2160
2051
|
"yaml/no-tab-indent": "error",
|
|
2161
2052
|
"yaml/quotes": ["error", {
|
|
@@ -2168,7 +2059,6 @@ async function yaml(options = {}) {
|
|
|
2168
2059
|
}
|
|
2169
2060
|
}];
|
|
2170
2061
|
}
|
|
2171
|
-
|
|
2172
2062
|
//#endregion
|
|
2173
2063
|
//#region src/factory.ts
|
|
2174
2064
|
const flatConfigProps = [
|
|
@@ -2189,8 +2079,9 @@ const VuePackages = [
|
|
|
2189
2079
|
const defaultPluginRenaming = {
|
|
2190
2080
|
"@eslint-react": "react",
|
|
2191
2081
|
"@eslint-react/dom": "react-dom",
|
|
2192
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
2193
2082
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2083
|
+
"@eslint-react/rsc": "react-rsc",
|
|
2084
|
+
"@eslint-react/web-api": "react-web-api",
|
|
2194
2085
|
"@next/next": "next",
|
|
2195
2086
|
"@stylistic": "style",
|
|
2196
2087
|
"@typescript-eslint": "ts",
|
|
@@ -2210,7 +2101,7 @@ const defaultPluginRenaming = {
|
|
|
2210
2101
|
* 合并的 ESLint 配置
|
|
2211
2102
|
*/
|
|
2212
2103
|
function lincy(options = {}, ...userConfigs) {
|
|
2213
|
-
const { autoRenamePlugins = true, componentExts = [], gitignore: enableGitignore = true, ignores:
|
|
2104
|
+
const { autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsx: enableJsx = true, nextjs: enableNextjs = false, overrides = {}, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, type: appType = "app", typescript: enableTypeScript = (0, local_pkg.isPackageExists)("typescript") || (0, local_pkg.isPackageExists)("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => (0, local_pkg.isPackageExists)(i)) } = options;
|
|
2214
2105
|
let isInEditor = options.isInEditor;
|
|
2215
2106
|
if (isInEditor == null) {
|
|
2216
2107
|
isInEditor = isInEditorEnv();
|
|
@@ -2218,104 +2109,108 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2218
2109
|
}
|
|
2219
2110
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2220
2111
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
|
|
2221
|
-
const configs
|
|
2222
|
-
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs
|
|
2112
|
+
const configs = [];
|
|
2113
|
+
if (enableGitignore) if (typeof enableGitignore !== "boolean") configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2223
2114
|
name: "eslint/gitignore",
|
|
2224
2115
|
...enableGitignore
|
|
2225
2116
|
})]));
|
|
2226
|
-
else configs
|
|
2117
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2227
2118
|
name: "eslint/gitignore",
|
|
2228
2119
|
strict: false
|
|
2229
2120
|
})]));
|
|
2230
2121
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2231
2122
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2232
|
-
configs
|
|
2123
|
+
configs.push(ignores([...overrides.ignores || [], ...userIgnores], !enableTypeScript), javascript({
|
|
2233
2124
|
isInEditor,
|
|
2234
2125
|
overrides: getOverrides(options, "javascript")
|
|
2235
2126
|
}), comments({ overrides: getOverrides(options, "comments") }), node({ overrides: getOverrides(options, "node") }), jsdoc({
|
|
2236
2127
|
overrides: getOverrides(options, "jsdoc"),
|
|
2237
2128
|
stylistic: stylisticOptions
|
|
2238
2129
|
}), perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
2239
|
-
if (
|
|
2130
|
+
if (enableE18e) configs.push(e18e({
|
|
2131
|
+
isInEditor,
|
|
2132
|
+
...enableE18e === true ? {} : enableE18e
|
|
2133
|
+
}));
|
|
2134
|
+
if (enableUnicorn) configs.push(unicorn({
|
|
2240
2135
|
...enableUnicorn === true ? {} : enableUnicorn,
|
|
2241
2136
|
overrides: getOverrides(options, "unicorn")
|
|
2242
2137
|
}));
|
|
2243
|
-
if (enableImports) configs
|
|
2138
|
+
if (enableImports) configs.push(imports({
|
|
2244
2139
|
overrides: getOverrides(options, "imports"),
|
|
2245
2140
|
stylistic: stylisticOptions
|
|
2246
2141
|
}));
|
|
2247
2142
|
if (enableVue) componentExts.push("vue");
|
|
2248
|
-
if (enableJsx) configs
|
|
2249
|
-
if (enableTypeScript) configs
|
|
2143
|
+
if (enableJsx) configs.push(jsx());
|
|
2144
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2250
2145
|
...typescriptOptions,
|
|
2251
2146
|
componentExts,
|
|
2252
2147
|
overrides: getOverrides(options, "typescript"),
|
|
2253
2148
|
tsconfigPath,
|
|
2254
|
-
type:
|
|
2149
|
+
type: appType
|
|
2255
2150
|
}));
|
|
2256
|
-
if (stylisticOptions) configs
|
|
2151
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2257
2152
|
overrides: getOverrides(options, "stylistic"),
|
|
2258
2153
|
stylistic: stylisticOptions
|
|
2259
2154
|
}));
|
|
2260
|
-
if (enableRegexp) configs
|
|
2155
|
+
if (enableRegexp) configs.push(regexp({
|
|
2261
2156
|
...resolveSubOptions(options, "regexp"),
|
|
2262
2157
|
...getOverrides(options, "regexp")
|
|
2263
2158
|
}));
|
|
2264
|
-
if (options.test ?? true) configs
|
|
2159
|
+
if (options.test ?? true) configs.push(test({
|
|
2265
2160
|
...resolveSubOptions(options, "test"),
|
|
2266
2161
|
isInEditor,
|
|
2267
2162
|
overrides: getOverrides(options, "test")
|
|
2268
2163
|
}));
|
|
2269
|
-
if (enableVue) configs
|
|
2164
|
+
if (enableVue) configs.push(vue({
|
|
2270
2165
|
...resolveSubOptions(options, "vue"),
|
|
2271
2166
|
overrides: getOverrides(options, "vue"),
|
|
2272
2167
|
stylistic: stylisticOptions,
|
|
2273
2168
|
typescript: !!enableTypeScript
|
|
2274
2169
|
}));
|
|
2275
|
-
if (enableReact) configs
|
|
2170
|
+
if (enableReact) configs.push(react({
|
|
2276
2171
|
...typescriptOptions,
|
|
2277
2172
|
...resolveSubOptions(options, "react"),
|
|
2278
2173
|
overrides: getOverrides(options, "react"),
|
|
2279
2174
|
tsconfigPath
|
|
2280
2175
|
}));
|
|
2281
|
-
if (enableNextjs) configs
|
|
2282
|
-
if (enableUnoCSS) configs
|
|
2176
|
+
if (enableNextjs) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2177
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2283
2178
|
...resolveSubOptions(options, "unocss"),
|
|
2284
2179
|
overrides: getOverrides(options, "unocss")
|
|
2285
2180
|
}));
|
|
2286
|
-
if (options.jsonc ?? true) configs
|
|
2181
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2287
2182
|
...resolveSubOptions(options, "jsonc"),
|
|
2288
2183
|
overrides: getOverrides(options, "jsonc"),
|
|
2289
2184
|
stylistic: stylisticOptions
|
|
2290
2185
|
}), sortPackageJson(), sortTsconfig());
|
|
2291
|
-
if (enableCatalogs) configs
|
|
2186
|
+
if (enableCatalogs) configs.push(pnpm({
|
|
2292
2187
|
isInEditor,
|
|
2293
2188
|
...resolveSubOptions(options, "pnpm")
|
|
2294
2189
|
}));
|
|
2295
|
-
if (options.yaml ?? true) configs
|
|
2190
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2296
2191
|
...resolveSubOptions(options, "yaml"),
|
|
2297
2192
|
overrides: getOverrides(options, "yaml"),
|
|
2298
2193
|
stylistic: stylisticOptions
|
|
2299
2194
|
}));
|
|
2300
|
-
if (options.toml ?? true) configs
|
|
2195
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2301
2196
|
overrides: getOverrides(options, "toml"),
|
|
2302
2197
|
stylistic: stylisticOptions
|
|
2303
2198
|
}));
|
|
2304
|
-
if (options.markdown ?? true) configs
|
|
2199
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2305
2200
|
...resolveSubOptions(options, "markdown"),
|
|
2306
2201
|
componentExts,
|
|
2307
2202
|
overrides: getOverrides(options, "markdown")
|
|
2308
2203
|
}));
|
|
2309
|
-
if (options.formatters) configs
|
|
2310
|
-
configs
|
|
2204
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2205
|
+
configs.push(disables());
|
|
2311
2206
|
if ("files" in options) throw new Error("[@lincy/eslint-config] 第一个参数不应包含“files”属性,因为选项应该是全局的。请将其放在第二个或更后面的配置中。");
|
|
2312
2207
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2313
2208
|
if (key in options) acc[key] = options[key];
|
|
2314
2209
|
return acc;
|
|
2315
2210
|
}, {});
|
|
2316
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2211
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2317
2212
|
let composer = new eslint_flat_config_utils.FlatConfigComposer();
|
|
2318
|
-
composer = composer.append(...configs
|
|
2213
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2319
2214
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2320
2215
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2321
2216
|
"unused-imports/no-unused-imports",
|
|
@@ -2334,11 +2229,9 @@ function getOverrides(options, key) {
|
|
|
2334
2229
|
..."overrides" in sub ? sub.overrides : {}
|
|
2335
2230
|
};
|
|
2336
2231
|
}
|
|
2337
|
-
|
|
2338
2232
|
//#endregion
|
|
2339
2233
|
//#region src/index.ts
|
|
2340
2234
|
var src_default = lincy;
|
|
2341
|
-
|
|
2342
2235
|
//#endregion
|
|
2343
2236
|
exports.GLOB_ALL_SRC = GLOB_ALL_SRC;
|
|
2344
2237
|
exports.GLOB_CSS = GLOB_CSS;
|
|
@@ -2374,6 +2267,7 @@ exports.comments = comments;
|
|
|
2374
2267
|
exports.default = src_default;
|
|
2375
2268
|
exports.defaultPluginRenaming = defaultPluginRenaming;
|
|
2376
2269
|
exports.disables = disables;
|
|
2270
|
+
exports.e18e = e18e;
|
|
2377
2271
|
exports.ensurePackages = ensurePackages;
|
|
2378
2272
|
exports.formatters = formatters;
|
|
2379
2273
|
exports.getOverrides = getOverrides;
|
|
@@ -2409,4 +2303,4 @@ exports.typescript = typescript;
|
|
|
2409
2303
|
exports.unicorn = unicorn;
|
|
2410
2304
|
exports.unocss = unocss;
|
|
2411
2305
|
exports.vue = vue;
|
|
2412
|
-
exports.yaml = yaml;
|
|
2306
|
+
exports.yaml = yaml;
|