@lincy/eslint-config 6.5.1 → 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 +155 -255
- package/dist/index.d.cts +1683 -2153
- package/dist/index.d.mts +1682 -2152
- package/dist/index.mjs +142 -242
- 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,14 +986,16 @@ 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 = {}) {
|
|
995
992
|
const { overrides = {} } = options;
|
|
996
993
|
return [{
|
|
994
|
+
name: "eslint/node/setup",
|
|
995
|
+
plugins: { node: eslint_plugin_n.default }
|
|
996
|
+
}, {
|
|
997
|
+
files: [GLOB_SRC],
|
|
997
998
|
name: "eslint/node/rules",
|
|
998
|
-
plugins: { node: eslint_plugin_n.default },
|
|
999
999
|
rules: {
|
|
1000
1000
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
1001
1001
|
"node/no-deprecated-api": "error",
|
|
@@ -1009,7 +1009,6 @@ async function node(options = {}) {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
}];
|
|
1011
1011
|
}
|
|
1012
|
-
|
|
1013
1012
|
//#endregion
|
|
1014
1013
|
//#region src/configs/perfectionist.ts
|
|
1015
1014
|
/**
|
|
@@ -1065,14 +1064,13 @@ async function perfectionist(options = {}) {
|
|
|
1065
1064
|
}
|
|
1066
1065
|
}];
|
|
1067
1066
|
}
|
|
1068
|
-
|
|
1069
1067
|
//#endregion
|
|
1070
1068
|
//#region src/configs/pnpm.ts
|
|
1071
1069
|
async function detectCatalogUsage() {
|
|
1072
1070
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1073
1071
|
if (!workspaceFile) return false;
|
|
1074
|
-
const yaml
|
|
1075
|
-
return yaml
|
|
1072
|
+
const yaml = await node_fs_promises.default.readFile(workspaceFile, "utf-8");
|
|
1073
|
+
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1076
1074
|
}
|
|
1077
1075
|
async function pnpm(options) {
|
|
1078
1076
|
const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
|
|
@@ -1080,9 +1078,9 @@ async function pnpm(options) {
|
|
|
1080
1078
|
interopDefault(import("eslint-plugin-yml")),
|
|
1081
1079
|
interopDefault(import("yaml-eslint-parser"))
|
|
1082
1080
|
]);
|
|
1083
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml
|
|
1084
|
-
const configs
|
|
1085
|
-
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({
|
|
1086
1084
|
files: ["package.json", "**/package.json"],
|
|
1087
1085
|
language: "jsonc/x",
|
|
1088
1086
|
name: "eslint/pnpm/package-json",
|
|
@@ -1096,8 +1094,8 @@ async function pnpm(options) {
|
|
|
1096
1094
|
"pnpm/json-valid-catalog": ["error", { autofix: !isInEditor }]
|
|
1097
1095
|
}
|
|
1098
1096
|
});
|
|
1099
|
-
if (yaml
|
|
1100
|
-
configs
|
|
1097
|
+
if (yaml) {
|
|
1098
|
+
configs.push({
|
|
1101
1099
|
files: ["pnpm-workspace.yaml"],
|
|
1102
1100
|
languageOptions: { parser: yamlParser },
|
|
1103
1101
|
name: "eslint/pnpm/pnpm-workspace-yaml",
|
|
@@ -1111,7 +1109,7 @@ async function pnpm(options) {
|
|
|
1111
1109
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1112
1110
|
}
|
|
1113
1111
|
});
|
|
1114
|
-
if (sort) configs
|
|
1112
|
+
if (sort) configs.push({
|
|
1115
1113
|
files: ["pnpm-workspace.yaml"],
|
|
1116
1114
|
languageOptions: { parser: yamlParser },
|
|
1117
1115
|
name: "eslint/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1190,9 +1188,8 @@ async function pnpm(options) {
|
|
|
1190
1188
|
] }
|
|
1191
1189
|
});
|
|
1192
1190
|
}
|
|
1193
|
-
return configs
|
|
1191
|
+
return configs;
|
|
1194
1192
|
}
|
|
1195
|
-
|
|
1196
1193
|
//#endregion
|
|
1197
1194
|
//#region src/configs/react.ts
|
|
1198
1195
|
const ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
@@ -1209,24 +1206,12 @@ const ReactRouterPackages = [
|
|
|
1209
1206
|
"@react-router/dev"
|
|
1210
1207
|
];
|
|
1211
1208
|
const NextJsPackages = ["next"];
|
|
1212
|
-
const ReactCompilerPackages = ["babel-plugin-react-compiler"];
|
|
1213
1209
|
async function react(options = {}) {
|
|
1214
|
-
const { files = [GLOB_SRC], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`], overrides = {},
|
|
1215
|
-
await ensurePackages([
|
|
1216
|
-
"@eslint-react/eslint-plugin",
|
|
1217
|
-
"eslint-plugin-react-hooks",
|
|
1218
|
-
"eslint-plugin-react-refresh"
|
|
1219
|
-
]);
|
|
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"]);
|
|
1220
1212
|
const isTypeAware = !!tsconfigPath;
|
|
1221
|
-
const typeAwareRules = {
|
|
1222
|
-
|
|
1223
|
-
"react/no-leaked-conditional-rendering": "warn"
|
|
1224
|
-
};
|
|
1225
|
-
const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
|
|
1226
|
-
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1227
|
-
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1228
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1229
|
-
]);
|
|
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"))]);
|
|
1230
1215
|
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1231
1216
|
const isUsingRemix = RemixPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
1232
1217
|
const isUsingReactRouter = ReactRouterPackages.some((i) => (0, local_pkg.isPackageExists)(i));
|
|
@@ -1238,8 +1223,6 @@ async function react(options = {}) {
|
|
|
1238
1223
|
plugins: {
|
|
1239
1224
|
"react": plugins["@eslint-react"],
|
|
1240
1225
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1241
|
-
"react-hooks": pluginReactHooks,
|
|
1242
|
-
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1243
1226
|
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1244
1227
|
"react-refresh": pluginReactRefresh,
|
|
1245
1228
|
"react-rsc": plugins["@eslint-react/rsc"],
|
|
@@ -1254,85 +1237,7 @@ async function react(options = {}) {
|
|
|
1254
1237
|
},
|
|
1255
1238
|
name: "eslint/react/rules",
|
|
1256
1239
|
rules: {
|
|
1257
|
-
|
|
1258
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1259
|
-
"react-dom/no-find-dom-node": "error",
|
|
1260
|
-
"react-dom/no-flush-sync": "error",
|
|
1261
|
-
"react-dom/no-hydrate": "error",
|
|
1262
|
-
"react-dom/no-namespace": "error",
|
|
1263
|
-
"react-dom/no-render": "error",
|
|
1264
|
-
"react-dom/no-render-return-value": "error",
|
|
1265
|
-
"react-dom/no-script-url": "warn",
|
|
1266
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1267
|
-
"react-dom/no-use-form-state": "error",
|
|
1268
|
-
"react-dom/no-void-elements-with-children": "error",
|
|
1269
|
-
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1270
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1271
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1272
|
-
"react-naming-convention/context-name": "warn",
|
|
1273
|
-
"react-naming-convention/ref-name": "warn",
|
|
1274
|
-
"react-naming-convention/use-state": "warn",
|
|
1275
|
-
"react-rsc/function-definition": "error",
|
|
1276
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1277
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1278
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1279
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1280
|
-
"react/jsx-key-before-spread": "warn",
|
|
1281
|
-
"react/jsx-no-comment-textnodes": "warn",
|
|
1282
|
-
"react/jsx-no-duplicate-props": "warn",
|
|
1283
|
-
"react/jsx-uses-react": "warn",
|
|
1284
|
-
"react/jsx-uses-vars": "warn",
|
|
1285
|
-
"react/no-access-state-in-setstate": "error",
|
|
1286
|
-
"react/no-array-index-key": "warn",
|
|
1287
|
-
"react/no-children-count": "warn",
|
|
1288
|
-
"react/no-children-for-each": "warn",
|
|
1289
|
-
"react/no-children-map": "warn",
|
|
1290
|
-
"react/no-children-only": "warn",
|
|
1291
|
-
"react/no-children-to-array": "warn",
|
|
1292
|
-
"react/no-clone-element": "warn",
|
|
1293
|
-
"react/no-component-will-mount": "error",
|
|
1294
|
-
"react/no-component-will-receive-props": "error",
|
|
1295
|
-
"react/no-component-will-update": "error",
|
|
1296
|
-
"react/no-context-provider": "warn",
|
|
1297
|
-
"react/no-create-ref": "error",
|
|
1298
|
-
"react/no-default-props": "error",
|
|
1299
|
-
"react/no-direct-mutation-state": "error",
|
|
1300
|
-
"react/no-forward-ref": "warn",
|
|
1301
|
-
"react/no-missing-key": "error",
|
|
1302
|
-
"react/no-nested-component-definitions": "error",
|
|
1303
|
-
"react/no-nested-lazy-component-declarations": "error",
|
|
1304
|
-
"react/no-prop-types": "error",
|
|
1305
|
-
"react/no-redundant-should-component-update": "error",
|
|
1306
|
-
"react/no-set-state-in-component-did-mount": "warn",
|
|
1307
|
-
"react/no-set-state-in-component-did-update": "warn",
|
|
1308
|
-
"react/no-set-state-in-component-will-update": "warn",
|
|
1309
|
-
"react/no-string-refs": "error",
|
|
1310
|
-
"react/no-unnecessary-use-prefix": "warn",
|
|
1311
|
-
"react/no-unsafe-component-will-mount": "warn",
|
|
1312
|
-
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1313
|
-
"react/no-unsafe-component-will-update": "warn",
|
|
1314
|
-
"react/no-unused-class-component-members": "warn",
|
|
1315
|
-
"react/no-use-context": "warn",
|
|
1316
|
-
"react/no-useless-forward-ref": "warn",
|
|
1317
|
-
"react/prefer-namespace-import": "error",
|
|
1318
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1319
|
-
...reactCompiler ? {
|
|
1320
|
-
"react-hooks/component-hook-factories": "error",
|
|
1321
|
-
"react-hooks/config": "error",
|
|
1322
|
-
"react-hooks/error-boundaries": "error",
|
|
1323
|
-
"react-hooks/gating": "error",
|
|
1324
|
-
"react-hooks/globals": "error",
|
|
1325
|
-
"react-hooks/immutability": "error",
|
|
1326
|
-
"react-hooks/incompatible-library": "warn",
|
|
1327
|
-
"react-hooks/preserve-manual-memoization": "error",
|
|
1328
|
-
"react-hooks/purity": "error",
|
|
1329
|
-
"react-hooks/refs": "error",
|
|
1330
|
-
"react-hooks/set-state-in-effect": "error",
|
|
1331
|
-
"react-hooks/set-state-in-render": "error",
|
|
1332
|
-
"react-hooks/static-components": "error",
|
|
1333
|
-
"react-hooks/unsupported-syntax": "warn",
|
|
1334
|
-
"react-hooks/use-memo": "error"
|
|
1335
|
-
} : {},
|
|
1240
|
+
...pluginReact.configs.recommended.rules,
|
|
1336
1241
|
"react-refresh/only-export-components": ["error", {
|
|
1337
1242
|
allowConstantExport: isAllowConstantExport,
|
|
1338
1243
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1362,6 +1267,7 @@ async function react(options = {}) {
|
|
|
1362
1267
|
"shouldRevalidate"
|
|
1363
1268
|
] : []]
|
|
1364
1269
|
}],
|
|
1270
|
+
"react/prefer-namespace-import": "error",
|
|
1365
1271
|
...overrides
|
|
1366
1272
|
}
|
|
1367
1273
|
},
|
|
@@ -1370,11 +1276,7 @@ async function react(options = {}) {
|
|
|
1370
1276
|
name: "eslint/react/typescript",
|
|
1371
1277
|
rules: {
|
|
1372
1278
|
"react-dom/no-string-style-prop": "off",
|
|
1373
|
-
"react-dom/no-unknown-property": "off"
|
|
1374
|
-
"react/jsx-no-duplicate-props": "off",
|
|
1375
|
-
"react/jsx-no-undef": "off",
|
|
1376
|
-
"react/jsx-uses-react": "off",
|
|
1377
|
-
"react/jsx-uses-vars": "off"
|
|
1279
|
+
"react-dom/no-unknown-property": "off"
|
|
1378
1280
|
}
|
|
1379
1281
|
},
|
|
1380
1282
|
...isTypeAware ? [{
|
|
@@ -1385,7 +1287,6 @@ async function react(options = {}) {
|
|
|
1385
1287
|
}] : []
|
|
1386
1288
|
];
|
|
1387
1289
|
}
|
|
1388
|
-
|
|
1389
1290
|
//#endregion
|
|
1390
1291
|
//#region src/configs/regexp.ts
|
|
1391
1292
|
async function regexp(options = {}) {
|
|
@@ -1403,7 +1304,6 @@ async function regexp(options = {}) {
|
|
|
1403
1304
|
}
|
|
1404
1305
|
}];
|
|
1405
1306
|
}
|
|
1406
|
-
|
|
1407
1307
|
//#endregion
|
|
1408
1308
|
//#region src/configs/sort.ts
|
|
1409
1309
|
/**
|
|
@@ -1636,7 +1536,6 @@ function sortTsconfig() {
|
|
|
1636
1536
|
] }
|
|
1637
1537
|
}];
|
|
1638
1538
|
}
|
|
1639
|
-
|
|
1640
1539
|
//#endregion
|
|
1641
1540
|
//#region src/configs/test.ts
|
|
1642
1541
|
async function test(options = {}) {
|
|
@@ -1665,6 +1564,7 @@ async function test(options = {}) {
|
|
|
1665
1564
|
"test/prefer-hooks-in-order": "error",
|
|
1666
1565
|
"test/prefer-lowercase-title": "error",
|
|
1667
1566
|
"antfu/no-top-level-await": "off",
|
|
1567
|
+
"e18e/prefer-static-regex": "off",
|
|
1668
1568
|
"no-unused-expressions": "off",
|
|
1669
1569
|
"node/prefer-global/process": "off",
|
|
1670
1570
|
"ts/explicit-function-return-type": "off",
|
|
@@ -1672,12 +1572,11 @@ async function test(options = {}) {
|
|
|
1672
1572
|
}
|
|
1673
1573
|
}];
|
|
1674
1574
|
}
|
|
1675
|
-
|
|
1676
1575
|
//#endregion
|
|
1677
1576
|
//#region src/configs/toml.ts
|
|
1678
1577
|
async function toml(options = {}) {
|
|
1679
|
-
const { files = [GLOB_TOML], overrides = {}, stylistic
|
|
1680
|
-
const {
|
|
1578
|
+
const { files = [GLOB_TOML], overrides = {}, stylistic = true } = options;
|
|
1579
|
+
const { other_indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1681
1580
|
const [pluginToml, parserToml] = await Promise.all([interopDefault(import("eslint-plugin-toml")), interopDefault(import("toml-eslint-parser"))]);
|
|
1682
1581
|
return [{
|
|
1683
1582
|
name: "eslint/toml/setup",
|
|
@@ -1696,11 +1595,11 @@ async function toml(options = {}) {
|
|
|
1696
1595
|
"toml/precision-of-integer": "error",
|
|
1697
1596
|
"toml/tables-order": "error",
|
|
1698
1597
|
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1699
|
-
...stylistic
|
|
1598
|
+
...stylistic ? {
|
|
1700
1599
|
"toml/array-bracket-newline": "error",
|
|
1701
1600
|
"toml/array-bracket-spacing": "error",
|
|
1702
1601
|
"toml/array-element-newline": "error",
|
|
1703
|
-
"toml/indent": ["error", typeof
|
|
1602
|
+
"toml/indent": ["error", typeof other_indent === "number" ? other_indent : other_indent === "tab" ? "tab" : 4],
|
|
1704
1603
|
"toml/inline-table-curly-spacing": "error",
|
|
1705
1604
|
"toml/key-spacing": "error",
|
|
1706
1605
|
"toml/padding-line-between-pairs": "error",
|
|
@@ -1713,14 +1612,13 @@ async function toml(options = {}) {
|
|
|
1713
1612
|
}
|
|
1714
1613
|
}];
|
|
1715
1614
|
}
|
|
1716
|
-
|
|
1717
1615
|
//#endregion
|
|
1718
1616
|
//#region src/configs/typescript.ts
|
|
1719
1617
|
async function typescript(options = {}) {
|
|
1720
1618
|
const { componentExts = [], erasableOnly = false, overrides = {}, parserOptions = {}, type = "app" } = options;
|
|
1721
|
-
const files = options.files ?? [
|
|
1722
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1723
|
-
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"];
|
|
1724
1622
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1725
1623
|
const isTypeAware = !!tsconfigPath;
|
|
1726
1624
|
const typeAwareRules = {
|
|
@@ -1750,10 +1648,10 @@ async function typescript(options = {}) {
|
|
|
1750
1648
|
"ts/unbound-method": "error"
|
|
1751
1649
|
};
|
|
1752
1650
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1753
|
-
function makeParser(typeAware, files
|
|
1651
|
+
function makeParser(typeAware, files, ignores) {
|
|
1754
1652
|
return {
|
|
1755
|
-
files
|
|
1756
|
-
...ignores
|
|
1653
|
+
files,
|
|
1654
|
+
...ignores ? { ignores } : {},
|
|
1757
1655
|
languageOptions: {
|
|
1758
1656
|
parser: parserTs,
|
|
1759
1657
|
parserOptions: {
|
|
@@ -1863,7 +1761,6 @@ async function typescript(options = {}) {
|
|
|
1863
1761
|
}] : []
|
|
1864
1762
|
];
|
|
1865
1763
|
}
|
|
1866
|
-
|
|
1867
1764
|
//#endregion
|
|
1868
1765
|
//#region src/configs/unicorn.ts
|
|
1869
1766
|
async function unicorn(options = {}) {
|
|
@@ -1893,7 +1790,6 @@ async function unicorn(options = {}) {
|
|
|
1893
1790
|
}
|
|
1894
1791
|
}];
|
|
1895
1792
|
}
|
|
1896
|
-
|
|
1897
1793
|
//#endregion
|
|
1898
1794
|
//#region src/configs/unocss.ts
|
|
1899
1795
|
async function unocss(options = {}) {
|
|
@@ -1911,7 +1807,6 @@ async function unocss(options = {}) {
|
|
|
1911
1807
|
}
|
|
1912
1808
|
}];
|
|
1913
1809
|
}
|
|
1914
|
-
|
|
1915
1810
|
//#endregion
|
|
1916
1811
|
//#region src/configs/vue.ts
|
|
1917
1812
|
const pkg = (0, local_pkg.getPackageInfoSync)("vue");
|
|
@@ -1919,9 +1814,9 @@ let vueVersion = pkg && pkg.version;
|
|
|
1919
1814
|
vueVersion = vueVersion && vueVersion[0];
|
|
1920
1815
|
vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
|
|
1921
1816
|
async function vue(options = {}) {
|
|
1922
|
-
const { files = [GLOB_VUE], overrides = {}, stylistic
|
|
1817
|
+
const { files = [GLOB_VUE], overrides = {}, stylistic = true } = options;
|
|
1923
1818
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
1924
|
-
const { indent = 4 } = typeof stylistic
|
|
1819
|
+
const { indent = 4 } = typeof stylistic === "boolean" ? {} : stylistic;
|
|
1925
1820
|
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1926
1821
|
interopDefault(import("eslint-plugin-vue")),
|
|
1927
1822
|
interopDefault(import("vue-eslint-parser")),
|
|
@@ -2074,7 +1969,7 @@ async function vue(options = {}) {
|
|
|
2074
1969
|
nonwords: false,
|
|
2075
1970
|
words: true
|
|
2076
1971
|
}],
|
|
2077
|
-
...stylistic
|
|
1972
|
+
...stylistic ? {
|
|
2078
1973
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
2079
1974
|
"vue/arrow-spacing": ["error", {
|
|
2080
1975
|
after: true,
|
|
@@ -2122,12 +2017,11 @@ async function vue(options = {}) {
|
|
|
2122
2017
|
}
|
|
2123
2018
|
}];
|
|
2124
2019
|
}
|
|
2125
|
-
|
|
2126
2020
|
//#endregion
|
|
2127
2021
|
//#region src/configs/yaml.ts
|
|
2128
2022
|
async function yaml(options = {}) {
|
|
2129
|
-
const { files = [GLOB_YAML], overrides = {}, stylistic
|
|
2130
|
-
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;
|
|
2131
2025
|
const [pluginYaml, parserYaml] = await Promise.all([interopDefault(import("eslint-plugin-yml")), interopDefault(import("yaml-eslint-parser"))]);
|
|
2132
2026
|
return [{
|
|
2133
2027
|
name: "eslint/yaml/setup",
|
|
@@ -2145,14 +2039,14 @@ async function yaml(options = {}) {
|
|
|
2145
2039
|
"yaml/no-irregular-whitespace": "error",
|
|
2146
2040
|
"yaml/plain-scalar": "error",
|
|
2147
2041
|
"yaml/vue-custom-block/no-parsing-error": "error",
|
|
2148
|
-
...stylistic
|
|
2042
|
+
...stylistic ? {
|
|
2149
2043
|
"yaml/block-mapping-question-indicator-newline": "error",
|
|
2150
2044
|
"yaml/block-sequence-hyphen-indicator-newline": "error",
|
|
2151
2045
|
"yaml/flow-mapping-curly-newline": "error",
|
|
2152
2046
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
2153
2047
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
2154
2048
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2155
|
-
"yaml/indent": ["error", 2],
|
|
2049
|
+
"yaml/indent": ["error", typeof other_indent === "number" ? other_indent : 2],
|
|
2156
2050
|
"yaml/key-spacing": "error",
|
|
2157
2051
|
"yaml/no-tab-indent": "error",
|
|
2158
2052
|
"yaml/quotes": ["error", {
|
|
@@ -2165,7 +2059,6 @@ async function yaml(options = {}) {
|
|
|
2165
2059
|
}
|
|
2166
2060
|
}];
|
|
2167
2061
|
}
|
|
2168
|
-
|
|
2169
2062
|
//#endregion
|
|
2170
2063
|
//#region src/factory.ts
|
|
2171
2064
|
const flatConfigProps = [
|
|
@@ -2186,8 +2079,9 @@ const VuePackages = [
|
|
|
2186
2079
|
const defaultPluginRenaming = {
|
|
2187
2080
|
"@eslint-react": "react",
|
|
2188
2081
|
"@eslint-react/dom": "react-dom",
|
|
2189
|
-
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
2190
2082
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2083
|
+
"@eslint-react/rsc": "react-rsc",
|
|
2084
|
+
"@eslint-react/web-api": "react-web-api",
|
|
2191
2085
|
"@next/next": "next",
|
|
2192
2086
|
"@stylistic": "style",
|
|
2193
2087
|
"@typescript-eslint": "ts",
|
|
@@ -2207,7 +2101,7 @@ const defaultPluginRenaming = {
|
|
|
2207
2101
|
* 合并的 ESLint 配置
|
|
2208
2102
|
*/
|
|
2209
2103
|
function lincy(options = {}, ...userConfigs) {
|
|
2210
|
-
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;
|
|
2211
2105
|
let isInEditor = options.isInEditor;
|
|
2212
2106
|
if (isInEditor == null) {
|
|
2213
2107
|
isInEditor = isInEditorEnv();
|
|
@@ -2215,101 +2109,108 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2215
2109
|
}
|
|
2216
2110
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2217
2111
|
if (stylisticOptions && !("jsx" in stylisticOptions)) stylisticOptions.jsx = enableJsx;
|
|
2218
|
-
const configs
|
|
2219
|
-
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({
|
|
2220
2114
|
name: "eslint/gitignore",
|
|
2221
2115
|
...enableGitignore
|
|
2222
2116
|
})]));
|
|
2223
|
-
else configs
|
|
2117
|
+
else configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2224
2118
|
name: "eslint/gitignore",
|
|
2225
2119
|
strict: false
|
|
2226
2120
|
})]));
|
|
2227
2121
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2228
2122
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2229
|
-
configs
|
|
2123
|
+
configs.push(ignores([...overrides.ignores || [], ...userIgnores], !enableTypeScript), javascript({
|
|
2230
2124
|
isInEditor,
|
|
2231
2125
|
overrides: getOverrides(options, "javascript")
|
|
2232
2126
|
}), comments({ overrides: getOverrides(options, "comments") }), node({ overrides: getOverrides(options, "node") }), jsdoc({
|
|
2233
2127
|
overrides: getOverrides(options, "jsdoc"),
|
|
2234
2128
|
stylistic: stylisticOptions
|
|
2235
2129
|
}), perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
2236
|
-
if (
|
|
2130
|
+
if (enableE18e) configs.push(e18e({
|
|
2131
|
+
isInEditor,
|
|
2132
|
+
...enableE18e === true ? {} : enableE18e
|
|
2133
|
+
}));
|
|
2134
|
+
if (enableUnicorn) configs.push(unicorn({
|
|
2237
2135
|
...enableUnicorn === true ? {} : enableUnicorn,
|
|
2238
2136
|
overrides: getOverrides(options, "unicorn")
|
|
2239
2137
|
}));
|
|
2240
|
-
if (enableImports) configs
|
|
2138
|
+
if (enableImports) configs.push(imports({
|
|
2241
2139
|
overrides: getOverrides(options, "imports"),
|
|
2242
2140
|
stylistic: stylisticOptions
|
|
2243
2141
|
}));
|
|
2244
2142
|
if (enableVue) componentExts.push("vue");
|
|
2245
|
-
if (enableJsx) configs
|
|
2246
|
-
if (enableTypeScript) configs
|
|
2143
|
+
if (enableJsx) configs.push(jsx());
|
|
2144
|
+
if (enableTypeScript) configs.push(typescript({
|
|
2247
2145
|
...typescriptOptions,
|
|
2248
2146
|
componentExts,
|
|
2249
2147
|
overrides: getOverrides(options, "typescript"),
|
|
2250
2148
|
tsconfigPath,
|
|
2251
|
-
type:
|
|
2149
|
+
type: appType
|
|
2252
2150
|
}));
|
|
2253
|
-
if (stylisticOptions) configs
|
|
2151
|
+
if (stylisticOptions) configs.push(stylistic({
|
|
2254
2152
|
overrides: getOverrides(options, "stylistic"),
|
|
2255
2153
|
stylistic: stylisticOptions
|
|
2256
2154
|
}));
|
|
2257
|
-
if (enableRegexp) configs
|
|
2155
|
+
if (enableRegexp) configs.push(regexp({
|
|
2258
2156
|
...resolveSubOptions(options, "regexp"),
|
|
2259
2157
|
...getOverrides(options, "regexp")
|
|
2260
2158
|
}));
|
|
2261
|
-
if (options.test ?? true) configs
|
|
2159
|
+
if (options.test ?? true) configs.push(test({
|
|
2262
2160
|
...resolveSubOptions(options, "test"),
|
|
2263
2161
|
isInEditor,
|
|
2264
2162
|
overrides: getOverrides(options, "test")
|
|
2265
2163
|
}));
|
|
2266
|
-
if (enableVue) configs
|
|
2164
|
+
if (enableVue) configs.push(vue({
|
|
2267
2165
|
...resolveSubOptions(options, "vue"),
|
|
2268
2166
|
overrides: getOverrides(options, "vue"),
|
|
2269
2167
|
stylistic: stylisticOptions,
|
|
2270
2168
|
typescript: !!enableTypeScript
|
|
2271
2169
|
}));
|
|
2272
|
-
if (enableReact) configs
|
|
2170
|
+
if (enableReact) configs.push(react({
|
|
2273
2171
|
...typescriptOptions,
|
|
2274
2172
|
...resolveSubOptions(options, "react"),
|
|
2275
2173
|
overrides: getOverrides(options, "react"),
|
|
2276
2174
|
tsconfigPath
|
|
2277
2175
|
}));
|
|
2278
|
-
if (enableNextjs) configs
|
|
2279
|
-
if (enableUnoCSS) configs
|
|
2176
|
+
if (enableNextjs) configs.push(nextjs({ overrides: getOverrides(options, "nextjs") }));
|
|
2177
|
+
if (enableUnoCSS) configs.push(unocss({
|
|
2280
2178
|
...resolveSubOptions(options, "unocss"),
|
|
2281
2179
|
overrides: getOverrides(options, "unocss")
|
|
2282
2180
|
}));
|
|
2283
|
-
if (options.jsonc ?? true) configs
|
|
2181
|
+
if (options.jsonc ?? true) configs.push(jsonc({
|
|
2284
2182
|
...resolveSubOptions(options, "jsonc"),
|
|
2285
2183
|
overrides: getOverrides(options, "jsonc"),
|
|
2286
2184
|
stylistic: stylisticOptions
|
|
2287
2185
|
}), sortPackageJson(), sortTsconfig());
|
|
2288
|
-
if (enableCatalogs) configs
|
|
2289
|
-
|
|
2186
|
+
if (enableCatalogs) configs.push(pnpm({
|
|
2187
|
+
isInEditor,
|
|
2188
|
+
...resolveSubOptions(options, "pnpm")
|
|
2189
|
+
}));
|
|
2190
|
+
if (options.yaml ?? true) configs.push(yaml({
|
|
2290
2191
|
...resolveSubOptions(options, "yaml"),
|
|
2291
2192
|
overrides: getOverrides(options, "yaml"),
|
|
2292
2193
|
stylistic: stylisticOptions
|
|
2293
2194
|
}));
|
|
2294
|
-
if (options.toml ?? true) configs
|
|
2195
|
+
if (options.toml ?? true) configs.push(toml({
|
|
2295
2196
|
overrides: getOverrides(options, "toml"),
|
|
2296
2197
|
stylistic: stylisticOptions
|
|
2297
2198
|
}));
|
|
2298
|
-
if (options.markdown ?? true) configs
|
|
2199
|
+
if (options.markdown ?? true) configs.push(markdown({
|
|
2299
2200
|
...resolveSubOptions(options, "markdown"),
|
|
2300
2201
|
componentExts,
|
|
2301
2202
|
overrides: getOverrides(options, "markdown")
|
|
2302
2203
|
}));
|
|
2303
|
-
if (options.formatters) configs
|
|
2304
|
-
configs
|
|
2204
|
+
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
2205
|
+
configs.push(disables());
|
|
2305
2206
|
if ("files" in options) throw new Error("[@lincy/eslint-config] 第一个参数不应包含“files”属性,因为选项应该是全局的。请将其放在第二个或更后面的配置中。");
|
|
2306
2207
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2307
2208
|
if (key in options) acc[key] = options[key];
|
|
2308
2209
|
return acc;
|
|
2309
2210
|
}, {});
|
|
2310
|
-
if (Object.keys(fusedConfig).length) configs
|
|
2211
|
+
if (Object.keys(fusedConfig).length) configs.push([fusedConfig]);
|
|
2311
2212
|
let composer = new eslint_flat_config_utils.FlatConfigComposer();
|
|
2312
|
-
composer = composer.append(...configs
|
|
2213
|
+
composer = composer.append(...configs, ...userConfigs);
|
|
2313
2214
|
if (autoRenamePlugins) composer = composer.renamePlugins(defaultPluginRenaming);
|
|
2314
2215
|
if (isInEditor) composer = composer.disableRulesFix([
|
|
2315
2216
|
"unused-imports/no-unused-imports",
|
|
@@ -2328,11 +2229,9 @@ function getOverrides(options, key) {
|
|
|
2328
2229
|
..."overrides" in sub ? sub.overrides : {}
|
|
2329
2230
|
};
|
|
2330
2231
|
}
|
|
2331
|
-
|
|
2332
2232
|
//#endregion
|
|
2333
2233
|
//#region src/index.ts
|
|
2334
2234
|
var src_default = lincy;
|
|
2335
|
-
|
|
2336
2235
|
//#endregion
|
|
2337
2236
|
exports.GLOB_ALL_SRC = GLOB_ALL_SRC;
|
|
2338
2237
|
exports.GLOB_CSS = GLOB_CSS;
|
|
@@ -2368,6 +2267,7 @@ exports.comments = comments;
|
|
|
2368
2267
|
exports.default = src_default;
|
|
2369
2268
|
exports.defaultPluginRenaming = defaultPluginRenaming;
|
|
2370
2269
|
exports.disables = disables;
|
|
2270
|
+
exports.e18e = e18e;
|
|
2371
2271
|
exports.ensurePackages = ensurePackages;
|
|
2372
2272
|
exports.formatters = formatters;
|
|
2373
2273
|
exports.getOverrides = getOverrides;
|
|
@@ -2403,4 +2303,4 @@ exports.typescript = typescript;
|
|
|
2403
2303
|
exports.unicorn = unicorn;
|
|
2404
2304
|
exports.unocss = unocss;
|
|
2405
2305
|
exports.vue = vue;
|
|
2406
|
-
exports.yaml = yaml;
|
|
2306
|
+
exports.yaml = yaml;
|