@lincy/eslint-config 4.7.0 → 5.1.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 +6 -7
- package/dist/index.cjs +666 -552
- package/dist/index.d.cts +594 -190
- package/dist/index.d.ts +594 -190
- package/dist/index.js +667 -563
- package/package.json +48 -37
package/dist/index.cjs
CHANGED
|
@@ -50,23 +50,28 @@ __export(src_exports, {
|
|
|
50
50
|
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
51
51
|
GLOB_STYLE: () => GLOB_STYLE,
|
|
52
52
|
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
53
|
+
GLOB_SVG: () => GLOB_SVG,
|
|
53
54
|
GLOB_TESTS: () => GLOB_TESTS,
|
|
54
55
|
GLOB_TOML: () => GLOB_TOML,
|
|
55
56
|
GLOB_TS: () => GLOB_TS,
|
|
56
57
|
GLOB_TSX: () => GLOB_TSX,
|
|
57
58
|
GLOB_VUE: () => GLOB_VUE,
|
|
59
|
+
GLOB_XML: () => GLOB_XML,
|
|
58
60
|
GLOB_YAML: () => GLOB_YAML,
|
|
59
61
|
StylisticConfigDefaults: () => StylisticConfigDefaults,
|
|
60
62
|
combine: () => combine,
|
|
61
63
|
comments: () => comments,
|
|
62
64
|
default: () => src_default,
|
|
63
65
|
defaultPluginRenaming: () => defaultPluginRenaming,
|
|
66
|
+
disables: () => disables,
|
|
64
67
|
ensurePackages: () => ensurePackages,
|
|
65
68
|
formatters: () => formatters,
|
|
66
69
|
ignores: () => ignores,
|
|
67
70
|
imports: () => imports,
|
|
68
71
|
interopDefault: () => interopDefault,
|
|
69
72
|
isInEditorEnv: () => isInEditorEnv,
|
|
73
|
+
isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
|
|
74
|
+
isPackageInScope: () => isPackageInScope,
|
|
70
75
|
javascript: () => javascript,
|
|
71
76
|
jsdoc: () => jsdoc,
|
|
72
77
|
jsonc: () => jsonc,
|
|
@@ -74,6 +79,7 @@ __export(src_exports, {
|
|
|
74
79
|
lincy: () => lincy,
|
|
75
80
|
markdown: () => markdown,
|
|
76
81
|
node: () => node,
|
|
82
|
+
parserPlain: () => parserPlain,
|
|
77
83
|
perfectionist: () => perfectionist,
|
|
78
84
|
react: () => react,
|
|
79
85
|
regexp: () => regexp,
|
|
@@ -93,24 +99,28 @@ __export(src_exports, {
|
|
|
93
99
|
});
|
|
94
100
|
module.exports = __toCommonJS(src_exports);
|
|
95
101
|
|
|
102
|
+
// node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.45_tsx@4.19.1_typescript@5.6.2_yaml@2.5.1/node_modules/tsup/assets/cjs_shims.js
|
|
103
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
104
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
105
|
+
|
|
96
106
|
// src/factory.ts
|
|
97
|
-
var import_local_pkg4 = require("local-pkg");
|
|
98
107
|
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
108
|
+
var import_local_pkg4 = require("local-pkg");
|
|
99
109
|
|
|
100
110
|
// src/plugins.ts
|
|
111
|
+
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
101
112
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
102
|
-
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
103
113
|
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
104
114
|
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
115
|
+
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
105
116
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
106
117
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
107
|
-
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
108
118
|
|
|
109
119
|
// src/configs/comments.ts
|
|
110
120
|
async function comments() {
|
|
111
121
|
return [
|
|
112
122
|
{
|
|
113
|
-
name: "eslint
|
|
123
|
+
name: "eslint/comments/rules",
|
|
114
124
|
plugins: {
|
|
115
125
|
"eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
116
126
|
},
|
|
@@ -145,6 +155,8 @@ var GLOB_SVELTE = "**/*.svelte";
|
|
|
145
155
|
var GLOB_VUE = "**/*.vue";
|
|
146
156
|
var GLOB_YAML = "**/*.y?(a)ml";
|
|
147
157
|
var GLOB_TOML = "**/*.toml";
|
|
158
|
+
var GLOB_XML = "**/*.xml";
|
|
159
|
+
var GLOB_SVG = "**/*.svg";
|
|
148
160
|
var GLOB_HTML = "**/*.htm?(l)";
|
|
149
161
|
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
150
162
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
@@ -195,6 +207,408 @@ var GLOB_EXCLUDE = [
|
|
|
195
207
|
"**/components.d.ts"
|
|
196
208
|
];
|
|
197
209
|
|
|
210
|
+
// src/configs/disables.ts
|
|
211
|
+
async function disables() {
|
|
212
|
+
return [
|
|
213
|
+
{
|
|
214
|
+
files: [`scripts/${GLOB_SRC}`],
|
|
215
|
+
name: "eslint/disables/scripts",
|
|
216
|
+
rules: {
|
|
217
|
+
"no-console": "off",
|
|
218
|
+
"ts/explicit-function-return-type": "off"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
223
|
+
name: "eslint/disables/cli",
|
|
224
|
+
rules: {
|
|
225
|
+
"no-console": "off"
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
230
|
+
name: "eslint/disables/bin",
|
|
231
|
+
rules: {
|
|
232
|
+
"antfu/no-import-dist": "off",
|
|
233
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
files: ["**/*.d.?([cm])ts"],
|
|
238
|
+
name: "eslint/disables/dts",
|
|
239
|
+
rules: {
|
|
240
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
241
|
+
"import/no-duplicates": "off",
|
|
242
|
+
"no-restricted-syntax": "off",
|
|
243
|
+
"unused-imports/no-unused-vars": "off"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
248
|
+
name: "eslint/disables/test",
|
|
249
|
+
rules: {
|
|
250
|
+
"no-unused-expressions": "off"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
255
|
+
name: "eslint/disables/cjs",
|
|
256
|
+
rules: {
|
|
257
|
+
"ts/no-require-imports": "off"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/utils.ts
|
|
264
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
265
|
+
var import_node_url = require("url");
|
|
266
|
+
var import_local_pkg = require("local-pkg");
|
|
267
|
+
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
268
|
+
var isCwdInScope = (0, import_local_pkg.isPackageExists)("@antfu/eslint-config");
|
|
269
|
+
var parserPlain = {
|
|
270
|
+
meta: {
|
|
271
|
+
name: "parser-plain"
|
|
272
|
+
},
|
|
273
|
+
parseForESLint: (code) => ({
|
|
274
|
+
ast: {
|
|
275
|
+
body: [],
|
|
276
|
+
comments: [],
|
|
277
|
+
loc: { end: code.length, start: 0 },
|
|
278
|
+
range: [0, code.length],
|
|
279
|
+
tokens: [],
|
|
280
|
+
type: "Program"
|
|
281
|
+
},
|
|
282
|
+
scopeManager: null,
|
|
283
|
+
services: { isPlain: true },
|
|
284
|
+
visitorKeys: {
|
|
285
|
+
Program: []
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
};
|
|
289
|
+
async function combine(...configs2) {
|
|
290
|
+
const resolved = await Promise.all(configs2);
|
|
291
|
+
return resolved.flat();
|
|
292
|
+
}
|
|
293
|
+
function renameRules(rules, map) {
|
|
294
|
+
return Object.fromEntries(
|
|
295
|
+
Object.entries(rules).map(([key, value]) => {
|
|
296
|
+
for (const [from, to] of Object.entries(map)) {
|
|
297
|
+
if (key.startsWith(`${from}/`)) {
|
|
298
|
+
return [to + key.slice(from.length), value];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return [key, value];
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
function renamePluginInConfigs(configs2, map) {
|
|
306
|
+
return configs2.map((i) => {
|
|
307
|
+
const clone = { ...i };
|
|
308
|
+
if (clone.rules) {
|
|
309
|
+
clone.rules = renameRules(clone.rules, map);
|
|
310
|
+
}
|
|
311
|
+
if (clone.plugins) {
|
|
312
|
+
clone.plugins = Object.fromEntries(
|
|
313
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
314
|
+
if (key in map) {
|
|
315
|
+
return [map[key], value];
|
|
316
|
+
}
|
|
317
|
+
return [key, value];
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
return clone;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function toArray(value) {
|
|
325
|
+
return Array.isArray(value) ? value : [value];
|
|
326
|
+
}
|
|
327
|
+
async function interopDefault(m) {
|
|
328
|
+
const resolved = await m;
|
|
329
|
+
return resolved.default || resolved;
|
|
330
|
+
}
|
|
331
|
+
function isPackageInScope(name) {
|
|
332
|
+
return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
333
|
+
}
|
|
334
|
+
async function ensurePackages(packages) {
|
|
335
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
|
|
336
|
+
return;
|
|
337
|
+
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
338
|
+
if (nonExistingPackages.length === 0)
|
|
339
|
+
return;
|
|
340
|
+
const p = await import("@clack/prompts");
|
|
341
|
+
const result = await p.confirm({
|
|
342
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
343
|
+
});
|
|
344
|
+
if (result)
|
|
345
|
+
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
346
|
+
}
|
|
347
|
+
function isInEditorEnv() {
|
|
348
|
+
if (import_node_process.default.env.CI)
|
|
349
|
+
return false;
|
|
350
|
+
if (isInGitHooksOrLintStaged())
|
|
351
|
+
return false;
|
|
352
|
+
return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
|
|
353
|
+
}
|
|
354
|
+
function isInGitHooksOrLintStaged() {
|
|
355
|
+
return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/configs/stylistic.ts
|
|
359
|
+
var StylisticConfigDefaults = {
|
|
360
|
+
indent: 4,
|
|
361
|
+
jsx: true,
|
|
362
|
+
lessOpinionated: false,
|
|
363
|
+
quotes: "single",
|
|
364
|
+
semi: false
|
|
365
|
+
};
|
|
366
|
+
async function stylistic(options = {}) {
|
|
367
|
+
const {
|
|
368
|
+
overrides = {},
|
|
369
|
+
stylistic: stylistic2 = StylisticConfigDefaults
|
|
370
|
+
} = options;
|
|
371
|
+
const {
|
|
372
|
+
indent,
|
|
373
|
+
jsx: jsx2,
|
|
374
|
+
lessOpinionated,
|
|
375
|
+
quotes,
|
|
376
|
+
semi
|
|
377
|
+
} = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
|
|
378
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
379
|
+
const config = pluginStylistic.configs.customize({
|
|
380
|
+
flat: true,
|
|
381
|
+
indent,
|
|
382
|
+
jsx: jsx2,
|
|
383
|
+
pluginName: "style",
|
|
384
|
+
quotes,
|
|
385
|
+
semi
|
|
386
|
+
});
|
|
387
|
+
return [
|
|
388
|
+
{
|
|
389
|
+
name: "eslint/stylistic/rules",
|
|
390
|
+
plugins: {
|
|
391
|
+
antfu: import_eslint_plugin_antfu.default,
|
|
392
|
+
style: pluginStylistic
|
|
393
|
+
},
|
|
394
|
+
rules: {
|
|
395
|
+
...config.rules,
|
|
396
|
+
"antfu/consistent-chaining": "error",
|
|
397
|
+
"antfu/consistent-list-newline": "off",
|
|
398
|
+
...lessOpinionated ? {
|
|
399
|
+
curly: ["error", "all"]
|
|
400
|
+
} : {
|
|
401
|
+
"antfu/curly": "error",
|
|
402
|
+
"antfu/if-newline": "error",
|
|
403
|
+
"antfu/top-level-function": "error"
|
|
404
|
+
},
|
|
405
|
+
// 覆盖`stylistic`默认规则
|
|
406
|
+
"style/brace-style": ["error", "stroustrup"],
|
|
407
|
+
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
408
|
+
"style/multiline-ternary": ["error", "never"],
|
|
409
|
+
...overrides
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// src/configs/formatters.ts
|
|
416
|
+
async function formatters(options = {}, stylistic2 = {}) {
|
|
417
|
+
const defaultIndent = 4;
|
|
418
|
+
if (options === true) {
|
|
419
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
420
|
+
options = {
|
|
421
|
+
css: false,
|
|
422
|
+
graphql: true,
|
|
423
|
+
html: true,
|
|
424
|
+
markdown: true,
|
|
425
|
+
svg: isPrettierPluginXmlInScope,
|
|
426
|
+
xml: isPrettierPluginXmlInScope
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
await ensurePackages([
|
|
430
|
+
"eslint-plugin-format",
|
|
431
|
+
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
432
|
+
]);
|
|
433
|
+
const {
|
|
434
|
+
indent,
|
|
435
|
+
quotes,
|
|
436
|
+
semi
|
|
437
|
+
} = {
|
|
438
|
+
...StylisticConfigDefaults,
|
|
439
|
+
...stylistic2
|
|
440
|
+
};
|
|
441
|
+
const prettierOptions = Object.assign(
|
|
442
|
+
{
|
|
443
|
+
endOfLine: "lf",
|
|
444
|
+
printWidth: 200,
|
|
445
|
+
semi,
|
|
446
|
+
singleQuote: quotes === "single",
|
|
447
|
+
tabWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
448
|
+
trailingComma: "all",
|
|
449
|
+
useTabs: indent === "tab"
|
|
450
|
+
},
|
|
451
|
+
options.prettierOptions || {}
|
|
452
|
+
);
|
|
453
|
+
const prettierXmlOptions = {
|
|
454
|
+
xmlQuoteAttributes: "double",
|
|
455
|
+
xmlSelfClosingSpace: true,
|
|
456
|
+
xmlSortAttributesByKey: false,
|
|
457
|
+
xmlWhitespaceSensitivity: "ignore"
|
|
458
|
+
};
|
|
459
|
+
const dprintOptions = Object.assign(
|
|
460
|
+
{
|
|
461
|
+
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
462
|
+
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
463
|
+
useTabs: indent === "tab"
|
|
464
|
+
},
|
|
465
|
+
options.dprintOptions || {}
|
|
466
|
+
);
|
|
467
|
+
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
468
|
+
const configs2 = [
|
|
469
|
+
{
|
|
470
|
+
name: "eslint/formatters/setup",
|
|
471
|
+
plugins: {
|
|
472
|
+
format: pluginFormat
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
];
|
|
476
|
+
if (options.css) {
|
|
477
|
+
configs2.push(
|
|
478
|
+
{
|
|
479
|
+
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
480
|
+
languageOptions: {
|
|
481
|
+
parser: parserPlain
|
|
482
|
+
},
|
|
483
|
+
name: "eslint/formatters/css",
|
|
484
|
+
rules: {
|
|
485
|
+
"format/prettier": [
|
|
486
|
+
"error",
|
|
487
|
+
{
|
|
488
|
+
...prettierOptions,
|
|
489
|
+
parser: "css"
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
files: [GLOB_SCSS],
|
|
496
|
+
languageOptions: {
|
|
497
|
+
parser: parserPlain
|
|
498
|
+
},
|
|
499
|
+
name: "eslint/formatters/scss",
|
|
500
|
+
rules: {
|
|
501
|
+
"format/prettier": [
|
|
502
|
+
"error",
|
|
503
|
+
{
|
|
504
|
+
...prettierOptions,
|
|
505
|
+
parser: "scss"
|
|
506
|
+
}
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
files: [GLOB_LESS],
|
|
512
|
+
languageOptions: {
|
|
513
|
+
parser: parserPlain
|
|
514
|
+
},
|
|
515
|
+
name: "eslint/formatters/less",
|
|
516
|
+
rules: {
|
|
517
|
+
"format/prettier": [
|
|
518
|
+
"error",
|
|
519
|
+
{
|
|
520
|
+
...prettierOptions,
|
|
521
|
+
parser: "less"
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
if (options.html) {
|
|
529
|
+
configs2.push({
|
|
530
|
+
files: [GLOB_HTML],
|
|
531
|
+
languageOptions: {
|
|
532
|
+
parser: parserPlain
|
|
533
|
+
},
|
|
534
|
+
name: "eslint/formatters/html",
|
|
535
|
+
rules: {
|
|
536
|
+
"format/prettier": [
|
|
537
|
+
"error",
|
|
538
|
+
{
|
|
539
|
+
...prettierOptions,
|
|
540
|
+
parser: "html"
|
|
541
|
+
}
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
if (options.svg) {
|
|
547
|
+
configs2.push({
|
|
548
|
+
files: [GLOB_SVG],
|
|
549
|
+
languageOptions: {
|
|
550
|
+
parser: parserPlain
|
|
551
|
+
},
|
|
552
|
+
name: "eslint/formatters/svg",
|
|
553
|
+
rules: {
|
|
554
|
+
"format/prettier": [
|
|
555
|
+
"error",
|
|
556
|
+
{
|
|
557
|
+
...prettierXmlOptions,
|
|
558
|
+
...prettierOptions,
|
|
559
|
+
parser: "xml",
|
|
560
|
+
plugins: [
|
|
561
|
+
"@prettier/plugin-xml"
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
]
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
if (options.markdown) {
|
|
569
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
570
|
+
configs2.push({
|
|
571
|
+
files: [GLOB_MARKDOWN],
|
|
572
|
+
languageOptions: {
|
|
573
|
+
parser: parserPlain
|
|
574
|
+
},
|
|
575
|
+
name: "eslint/formatters/markdown",
|
|
576
|
+
rules: {
|
|
577
|
+
[`format/${formater}`]: [
|
|
578
|
+
"error",
|
|
579
|
+
formater === "prettier" ? {
|
|
580
|
+
...prettierOptions,
|
|
581
|
+
embeddedLanguageFormatting: "off",
|
|
582
|
+
parser: "markdown"
|
|
583
|
+
} : {
|
|
584
|
+
...dprintOptions,
|
|
585
|
+
language: "markdown"
|
|
586
|
+
}
|
|
587
|
+
]
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
if (options.graphql) {
|
|
592
|
+
configs2.push({
|
|
593
|
+
files: [GLOB_GRAPHQL],
|
|
594
|
+
languageOptions: {
|
|
595
|
+
parser: parserPlain
|
|
596
|
+
},
|
|
597
|
+
name: "eslint/formatters/graphql",
|
|
598
|
+
rules: {
|
|
599
|
+
"format/prettier": [
|
|
600
|
+
"error",
|
|
601
|
+
{
|
|
602
|
+
...prettierOptions,
|
|
603
|
+
parser: "graphql"
|
|
604
|
+
}
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
return configs2;
|
|
610
|
+
}
|
|
611
|
+
|
|
198
612
|
// src/configs/ignores.ts
|
|
199
613
|
async function ignores(options = {}) {
|
|
200
614
|
const {
|
|
@@ -206,7 +620,7 @@ async function ignores(options = {}) {
|
|
|
206
620
|
...GLOB_EXCLUDE,
|
|
207
621
|
...ignores2
|
|
208
622
|
],
|
|
209
|
-
name: "eslint
|
|
623
|
+
name: "eslint/ignores"
|
|
210
624
|
}
|
|
211
625
|
];
|
|
212
626
|
}
|
|
@@ -218,7 +632,7 @@ async function imports(options = {}) {
|
|
|
218
632
|
} = options;
|
|
219
633
|
return [
|
|
220
634
|
{
|
|
221
|
-
name: "eslint
|
|
635
|
+
name: "eslint/imports/rules",
|
|
222
636
|
plugins: {
|
|
223
637
|
antfu: import_eslint_plugin_antfu.default,
|
|
224
638
|
import: pluginImport
|
|
@@ -233,19 +647,10 @@ async function imports(options = {}) {
|
|
|
233
647
|
"import/no-named-default": "error",
|
|
234
648
|
"import/no-self-import": "error",
|
|
235
649
|
"import/no-webpack-loader-syntax": "error",
|
|
236
|
-
"import/order": "error",
|
|
237
650
|
...stylistic2 ? {
|
|
238
651
|
"import/newline-after-import": ["error", { considerComments: true, count: 1 }]
|
|
239
652
|
} : {}
|
|
240
653
|
}
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
244
|
-
name: "eslint:imports:disables:bin",
|
|
245
|
-
rules: {
|
|
246
|
-
"antfu/no-import-dist": "off",
|
|
247
|
-
"antfu/no-import-node-modules-by-path": "off"
|
|
248
|
-
}
|
|
249
654
|
}
|
|
250
655
|
];
|
|
251
656
|
}
|
|
@@ -281,10 +686,10 @@ async function javascript(options = {}) {
|
|
|
281
686
|
linterOptions: {
|
|
282
687
|
reportUnusedDisableDirectives: true
|
|
283
688
|
},
|
|
284
|
-
name: "eslint
|
|
689
|
+
name: "eslint/javascript/setup"
|
|
285
690
|
},
|
|
286
691
|
{
|
|
287
|
-
name: "eslint
|
|
692
|
+
name: "eslint/javascript/rules",
|
|
288
693
|
plugins: {
|
|
289
694
|
"antfu": import_eslint_plugin_antfu.default,
|
|
290
695
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
@@ -363,9 +768,6 @@ async function javascript(options = {}) {
|
|
|
363
768
|
],
|
|
364
769
|
"no-restricted-syntax": [
|
|
365
770
|
"error",
|
|
366
|
-
"DebuggerStatement",
|
|
367
|
-
"LabeledStatement",
|
|
368
|
-
"WithStatement",
|
|
369
771
|
"TSEnumDeclaration[const=true]",
|
|
370
772
|
"TSExportAssignment"
|
|
371
773
|
],
|
|
@@ -464,85 +866,9 @@ async function javascript(options = {}) {
|
|
|
464
866
|
"vars-on-top": "error",
|
|
465
867
|
"yoda": ["error", "never"],
|
|
466
868
|
...overrides
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
471
|
-
name: "eslint:scripts:disables",
|
|
472
|
-
rules: {
|
|
473
|
-
"no-console": "off"
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// src/utils.ts
|
|
480
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
481
|
-
var import_local_pkg = require("local-pkg");
|
|
482
|
-
async function combine(...configs2) {
|
|
483
|
-
const resolved = await Promise.all(configs2);
|
|
484
|
-
return resolved.flat();
|
|
485
|
-
}
|
|
486
|
-
function renameRules(rules, map) {
|
|
487
|
-
return Object.fromEntries(
|
|
488
|
-
Object.entries(rules).map(([key, value]) => {
|
|
489
|
-
for (const [from, to] of Object.entries(map)) {
|
|
490
|
-
if (key.startsWith(`${from}/`)) {
|
|
491
|
-
return [to + key.slice(from.length), value];
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return [key, value];
|
|
495
|
-
})
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
function renamePluginInConfigs(configs2, map) {
|
|
499
|
-
return configs2.map((i) => {
|
|
500
|
-
const clone = { ...i };
|
|
501
|
-
if (clone.rules) {
|
|
502
|
-
clone.rules = renameRules(clone.rules, map);
|
|
503
|
-
}
|
|
504
|
-
if (clone.plugins) {
|
|
505
|
-
clone.plugins = Object.fromEntries(
|
|
506
|
-
Object.entries(clone.plugins).map(([key, value]) => {
|
|
507
|
-
if (key in map) {
|
|
508
|
-
return [map[key], value];
|
|
509
|
-
}
|
|
510
|
-
return [key, value];
|
|
511
|
-
})
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
return clone;
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
function toArray(value) {
|
|
518
|
-
return Array.isArray(value) ? value : [value];
|
|
519
|
-
}
|
|
520
|
-
async function interopDefault(m) {
|
|
521
|
-
const resolved = await m;
|
|
522
|
-
return resolved.default || resolved;
|
|
523
|
-
}
|
|
524
|
-
async function ensurePackages(packages) {
|
|
525
|
-
if (import_node_process.default.stdout.isTTY === false) {
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
const nonExistingPackages = packages.filter((i) => !(0, import_local_pkg.isPackageExists)(i));
|
|
529
|
-
if (nonExistingPackages.length === 0) {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
const { default: prompts } = await import("prompts");
|
|
533
|
-
const { result } = await prompts([
|
|
534
|
-
{
|
|
535
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
536
|
-
name: "result",
|
|
537
|
-
type: "confirm"
|
|
538
|
-
}
|
|
539
|
-
]);
|
|
540
|
-
if (result) {
|
|
541
|
-
await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
function isInEditorEnv() {
|
|
545
|
-
return !!((import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM) && !import_node_process.default.env.CI);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
];
|
|
546
872
|
}
|
|
547
873
|
|
|
548
874
|
// src/configs/jsdoc.ts
|
|
@@ -552,7 +878,7 @@ async function jsdoc(options = {}) {
|
|
|
552
878
|
} = options;
|
|
553
879
|
return [
|
|
554
880
|
{
|
|
555
|
-
name: "eslint
|
|
881
|
+
name: "eslint/jsdoc/rules",
|
|
556
882
|
plugins: {
|
|
557
883
|
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
558
884
|
},
|
|
@@ -597,7 +923,7 @@ async function jsonc(options = {}) {
|
|
|
597
923
|
]);
|
|
598
924
|
return [
|
|
599
925
|
{
|
|
600
|
-
name: "eslint
|
|
926
|
+
name: "eslint/jsonc/setup",
|
|
601
927
|
plugins: {
|
|
602
928
|
jsonc: pluginJsonc
|
|
603
929
|
}
|
|
@@ -607,7 +933,7 @@ async function jsonc(options = {}) {
|
|
|
607
933
|
languageOptions: {
|
|
608
934
|
parser: parserJsonc
|
|
609
935
|
},
|
|
610
|
-
name: "eslint
|
|
936
|
+
name: "eslint/jsonc/rules",
|
|
611
937
|
rules: {
|
|
612
938
|
"jsonc/no-bigint-literals": "error",
|
|
613
939
|
"jsonc/no-binary-expression": "error",
|
|
@@ -665,347 +991,110 @@ async function jsx() {
|
|
|
665
991
|
}
|
|
666
992
|
}
|
|
667
993
|
},
|
|
668
|
-
name: "eslint
|
|
994
|
+
name: "eslint/jsx/setup"
|
|
669
995
|
}
|
|
670
996
|
];
|
|
671
997
|
}
|
|
672
998
|
|
|
673
999
|
// src/configs/markdown.ts
|
|
674
|
-
var parserPlain = __toESM(require("eslint-parser-plain"), 1);
|
|
675
1000
|
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
1001
|
+
var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
|
|
676
1002
|
async function markdown(options = {}) {
|
|
677
1003
|
const {
|
|
678
1004
|
componentExts = [],
|
|
679
1005
|
files = [GLOB_MARKDOWN],
|
|
680
1006
|
overrides = {}
|
|
681
1007
|
} = options;
|
|
682
|
-
const markdown2 = await interopDefault(import("eslint
|
|
1008
|
+
const markdown2 = await interopDefault(import("@eslint/markdown"));
|
|
683
1009
|
return [
|
|
684
1010
|
{
|
|
685
|
-
name: "eslint
|
|
1011
|
+
name: "eslint/markdown/setup",
|
|
686
1012
|
plugins: {
|
|
687
1013
|
markdown: markdown2
|
|
688
1014
|
}
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
files,
|
|
692
|
-
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
693
|
-
name: "eslint
|
|
694
|
-
processor: (0, import_eslint_merge_processors.mergeProcessors)([
|
|
695
|
-
markdown2.processors.markdown,
|
|
696
|
-
import_eslint_merge_processors.processorPassThrough
|
|
697
|
-
])
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
files,
|
|
701
|
-
languageOptions: {
|
|
702
|
-
parser: parserPlain
|
|
703
|
-
},
|
|
704
|
-
name: "eslint:markdown:parser"
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
files: [
|
|
708
|
-
GLOB_MARKDOWN_CODE,
|
|
709
|
-
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
710
|
-
],
|
|
711
|
-
languageOptions: {
|
|
712
|
-
parserOptions: {
|
|
713
|
-
ecmaFeatures: {
|
|
714
|
-
impliedStrict: true
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
},
|
|
718
|
-
name: "eslint:markdown:disables",
|
|
719
|
-
rules: {
|
|
720
|
-
"import/newline-after-import": "off",
|
|
721
|
-
"no-alert": "off",
|
|
722
|
-
"no-console": "off",
|
|
723
|
-
"no-labels": "off",
|
|
724
|
-
"no-lone-blocks": "off",
|
|
725
|
-
"no-restricted-syntax": "off",
|
|
726
|
-
"no-undef": "off",
|
|
727
|
-
"no-unused-expressions": "off",
|
|
728
|
-
"no-unused-labels": "off",
|
|
729
|
-
"no-unused-vars": "off",
|
|
730
|
-
"node/prefer-global/process": "off",
|
|
731
|
-
"style/comma-dangle": "off",
|
|
732
|
-
"style/eol-last": "off",
|
|
733
|
-
"ts/consistent-type-imports": "off",
|
|
734
|
-
"ts/no-namespace": "off",
|
|
735
|
-
"ts/no-redeclare": "off",
|
|
736
|
-
"ts/no-require-imports": "off",
|
|
737
|
-
"ts/no-unused-expressions": "off",
|
|
738
|
-
"ts/no-unused-vars": "off",
|
|
739
|
-
"ts/no-use-before-define": "off",
|
|
740
|
-
"ts/no-var-requires": "off",
|
|
741
|
-
"unicode-bom": "off",
|
|
742
|
-
"unused-imports/no-unused-imports": "off",
|
|
743
|
-
"unused-imports/no-unused-vars": "off",
|
|
744
|
-
// Type aware rules
|
|
745
|
-
...{
|
|
746
|
-
"ts/await-thenable": "off",
|
|
747
|
-
"ts/dot-notation": "off",
|
|
748
|
-
"ts/no-floating-promises": "off",
|
|
749
|
-
"ts/no-for-in-array": "off",
|
|
750
|
-
"ts/no-implied-eval": "off",
|
|
751
|
-
"ts/no-misused-promises": "off",
|
|
752
|
-
"ts/no-unnecessary-type-assertion": "off",
|
|
753
|
-
"ts/no-unsafe-argument": "off",
|
|
754
|
-
"ts/no-unsafe-assignment": "off",
|
|
755
|
-
"ts/no-unsafe-call": "off",
|
|
756
|
-
"ts/no-unsafe-member-access": "off",
|
|
757
|
-
"ts/no-unsafe-return": "off",
|
|
758
|
-
"ts/restrict-plus-operands": "off",
|
|
759
|
-
"ts/restrict-template-expressions": "off",
|
|
760
|
-
"ts/unbound-method": "off"
|
|
761
|
-
},
|
|
762
|
-
...overrides
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
];
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
// src/configs/perfectionist.ts
|
|
769
|
-
async function perfectionist() {
|
|
770
|
-
return [
|
|
771
|
-
{
|
|
772
|
-
name: "eslint:perfectionist:setup",
|
|
773
|
-
plugins: {
|
|
774
|
-
perfectionist: import_eslint_plugin_perfectionist.default
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
];
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
// src/configs/formatters.ts
|
|
781
|
-
var parserPlain2 = __toESM(require("eslint-parser-plain"), 1);
|
|
782
|
-
|
|
783
|
-
// src/configs/stylistic.ts
|
|
784
|
-
var StylisticConfigDefaults = {
|
|
785
|
-
indent: 4,
|
|
786
|
-
jsx: true,
|
|
787
|
-
lessOpinionated: false,
|
|
788
|
-
quotes: "single",
|
|
789
|
-
semi: false
|
|
790
|
-
};
|
|
791
|
-
async function stylistic(options = {}) {
|
|
792
|
-
const {
|
|
793
|
-
overrides = {},
|
|
794
|
-
stylistic: stylistic2 = StylisticConfigDefaults
|
|
795
|
-
} = options;
|
|
796
|
-
const {
|
|
797
|
-
indent,
|
|
798
|
-
jsx: jsx2,
|
|
799
|
-
lessOpinionated,
|
|
800
|
-
quotes,
|
|
801
|
-
semi
|
|
802
|
-
} = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
|
|
803
|
-
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
804
|
-
const config = pluginStylistic.configs.customize({
|
|
805
|
-
flat: true,
|
|
806
|
-
indent,
|
|
807
|
-
jsx: jsx2,
|
|
808
|
-
pluginName: "style",
|
|
809
|
-
quotes,
|
|
810
|
-
semi
|
|
811
|
-
});
|
|
812
|
-
return [
|
|
813
|
-
{
|
|
814
|
-
name: "eslint:stylistic",
|
|
815
|
-
plugins: {
|
|
816
|
-
antfu: import_eslint_plugin_antfu.default,
|
|
817
|
-
style: pluginStylistic
|
|
818
|
-
},
|
|
819
|
-
rules: {
|
|
820
|
-
...config.rules,
|
|
821
|
-
"antfu/consistent-list-newline": "off",
|
|
822
|
-
...lessOpinionated ? {
|
|
823
|
-
curly: ["error", "all"]
|
|
824
|
-
} : {
|
|
825
|
-
"antfu/curly": "error",
|
|
826
|
-
"antfu/if-newline": "error",
|
|
827
|
-
"antfu/top-level-function": "error"
|
|
828
|
-
},
|
|
829
|
-
// 覆盖`stylistic`默认规则
|
|
830
|
-
"style/brace-style": ["error", "stroustrup"],
|
|
831
|
-
"style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
|
|
832
|
-
"style/multiline-ternary": ["error", "never"],
|
|
833
|
-
...overrides
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
];
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
// src/configs/formatters.ts
|
|
840
|
-
async function formatters(options = {}, stylistic2 = {}) {
|
|
841
|
-
const defaultIndent = 4;
|
|
842
|
-
await ensurePackages([
|
|
843
|
-
"eslint-plugin-format"
|
|
844
|
-
]);
|
|
845
|
-
if (options === true) {
|
|
846
|
-
options = {
|
|
847
|
-
css: false,
|
|
848
|
-
graphql: true,
|
|
849
|
-
html: true,
|
|
850
|
-
markdown: true
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
const {
|
|
854
|
-
indent,
|
|
855
|
-
quotes,
|
|
856
|
-
semi
|
|
857
|
-
} = {
|
|
858
|
-
...StylisticConfigDefaults,
|
|
859
|
-
...stylistic2
|
|
860
|
-
};
|
|
861
|
-
const prettierOptions = Object.assign(
|
|
862
|
-
{
|
|
863
|
-
endOfLine: "lf",
|
|
864
|
-
semi,
|
|
865
|
-
singleQuote: quotes === "single",
|
|
866
|
-
tabWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
867
|
-
trailingComma: "all",
|
|
868
|
-
useTabs: indent === "tab"
|
|
869
|
-
},
|
|
870
|
-
options.prettierOptions || {}
|
|
871
|
-
);
|
|
872
|
-
const dprintOptions = Object.assign(
|
|
873
|
-
{
|
|
874
|
-
indentWidth: typeof indent === "number" ? indent : defaultIndent,
|
|
875
|
-
quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
|
|
876
|
-
useTabs: indent === "tab"
|
|
877
|
-
},
|
|
878
|
-
options.dprintOptions || {}
|
|
879
|
-
);
|
|
880
|
-
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
881
|
-
const configs2 = [
|
|
882
|
-
{
|
|
883
|
-
name: "eslint:formatters:setup",
|
|
884
|
-
plugins: {
|
|
885
|
-
format: pluginFormat
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
];
|
|
889
|
-
if (options.css) {
|
|
890
|
-
configs2.push(
|
|
891
|
-
{
|
|
892
|
-
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
893
|
-
languageOptions: {
|
|
894
|
-
parser: parserPlain2
|
|
895
|
-
},
|
|
896
|
-
name: "eslint:formatter:css",
|
|
897
|
-
rules: {
|
|
898
|
-
"format/prettier": [
|
|
899
|
-
"error",
|
|
900
|
-
{
|
|
901
|
-
...prettierOptions,
|
|
902
|
-
parser: "css"
|
|
903
|
-
}
|
|
904
|
-
]
|
|
905
|
-
}
|
|
906
|
-
},
|
|
907
|
-
{
|
|
908
|
-
files: [GLOB_SCSS],
|
|
909
|
-
languageOptions: {
|
|
910
|
-
parser: parserPlain2
|
|
911
|
-
},
|
|
912
|
-
name: "eslint:formatter:scss",
|
|
913
|
-
rules: {
|
|
914
|
-
"format/prettier": [
|
|
915
|
-
"error",
|
|
916
|
-
{
|
|
917
|
-
...prettierOptions,
|
|
918
|
-
parser: "scss"
|
|
919
|
-
}
|
|
920
|
-
]
|
|
921
|
-
}
|
|
922
|
-
},
|
|
923
|
-
{
|
|
924
|
-
files: [GLOB_LESS],
|
|
925
|
-
languageOptions: {
|
|
926
|
-
parser: parserPlain2
|
|
927
|
-
},
|
|
928
|
-
name: "eslint:formatter:less",
|
|
929
|
-
rules: {
|
|
930
|
-
"format/prettier": [
|
|
931
|
-
"error",
|
|
932
|
-
{
|
|
933
|
-
...prettierOptions,
|
|
934
|
-
parser: "less"
|
|
935
|
-
}
|
|
936
|
-
]
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
if (options.html) {
|
|
942
|
-
configs2.push({
|
|
943
|
-
files: [GLOB_HTML],
|
|
944
|
-
languageOptions: {
|
|
945
|
-
parser: parserPlain2
|
|
946
|
-
},
|
|
947
|
-
name: "eslint:formatter:html",
|
|
948
|
-
rules: {
|
|
949
|
-
"format/prettier": [
|
|
950
|
-
"error",
|
|
951
|
-
{
|
|
952
|
-
...prettierOptions,
|
|
953
|
-
parser: "html"
|
|
954
|
-
}
|
|
955
|
-
]
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
if (options.markdown) {
|
|
960
|
-
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
961
|
-
configs2.push({
|
|
962
|
-
files: [GLOB_MARKDOWN],
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
files,
|
|
1018
|
+
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
1019
|
+
name: "eslint/markdown/processor",
|
|
1020
|
+
processor: (0, import_eslint_merge_processors.mergeProcessors)([
|
|
1021
|
+
markdown2.processors.markdown,
|
|
1022
|
+
import_eslint_merge_processors.processorPassThrough
|
|
1023
|
+
])
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
files,
|
|
963
1027
|
languageOptions: {
|
|
964
1028
|
parser: parserPlain2
|
|
965
1029
|
},
|
|
966
|
-
name: "eslint
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
embeddedLanguageFormatting: "off",
|
|
974
|
-
parser: "markdown"
|
|
975
|
-
} : {
|
|
976
|
-
...dprintOptions,
|
|
977
|
-
language: "markdown"
|
|
978
|
-
}
|
|
979
|
-
]
|
|
980
|
-
}
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
if (options.graphql) {
|
|
984
|
-
configs2.push({
|
|
985
|
-
files: [GLOB_GRAPHQL],
|
|
1030
|
+
name: "eslint/markdown/parser"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
files: [
|
|
1034
|
+
GLOB_MARKDOWN_CODE,
|
|
1035
|
+
...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
1036
|
+
],
|
|
986
1037
|
languageOptions: {
|
|
987
|
-
|
|
1038
|
+
parserOptions: {
|
|
1039
|
+
ecmaFeatures: {
|
|
1040
|
+
impliedStrict: true
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
988
1043
|
},
|
|
989
|
-
name: "eslint
|
|
1044
|
+
name: "eslint/markdown/disables",
|
|
990
1045
|
rules: {
|
|
991
|
-
"
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1046
|
+
"import/newline-after-import": "off",
|
|
1047
|
+
"no-alert": "off",
|
|
1048
|
+
"no-console": "off",
|
|
1049
|
+
"no-labels": "off",
|
|
1050
|
+
"no-lone-blocks": "off",
|
|
1051
|
+
"no-restricted-syntax": "off",
|
|
1052
|
+
"no-undef": "off",
|
|
1053
|
+
"no-unused-expressions": "off",
|
|
1054
|
+
"no-unused-labels": "off",
|
|
1055
|
+
"no-unused-vars": "off",
|
|
1056
|
+
"node/prefer-global/process": "off",
|
|
1057
|
+
"style/comma-dangle": "off",
|
|
1058
|
+
"style/eol-last": "off",
|
|
1059
|
+
"ts/consistent-type-imports": "off",
|
|
1060
|
+
"ts/no-namespace": "off",
|
|
1061
|
+
"ts/no-redeclare": "off",
|
|
1062
|
+
"ts/no-require-imports": "off",
|
|
1063
|
+
"ts/no-unused-expressions": "off",
|
|
1064
|
+
"ts/no-unused-vars": "off",
|
|
1065
|
+
"ts/no-use-before-define": "off",
|
|
1066
|
+
"unicode-bom": "off",
|
|
1067
|
+
"unused-imports/no-unused-imports": "off",
|
|
1068
|
+
"unused-imports/no-unused-vars": "off",
|
|
1069
|
+
// Type aware rules
|
|
1070
|
+
...{
|
|
1071
|
+
"ts/await-thenable": "off",
|
|
1072
|
+
"ts/dot-notation": "off",
|
|
1073
|
+
"ts/no-floating-promises": "off",
|
|
1074
|
+
"ts/no-for-in-array": "off",
|
|
1075
|
+
"ts/no-implied-eval": "off",
|
|
1076
|
+
"ts/no-misused-promises": "off",
|
|
1077
|
+
"ts/no-unnecessary-type-assertion": "off",
|
|
1078
|
+
"ts/no-unsafe-argument": "off",
|
|
1079
|
+
"ts/no-unsafe-assignment": "off",
|
|
1080
|
+
"ts/no-unsafe-call": "off",
|
|
1081
|
+
"ts/no-unsafe-member-access": "off",
|
|
1082
|
+
"ts/no-unsafe-return": "off",
|
|
1083
|
+
"ts/restrict-plus-operands": "off",
|
|
1084
|
+
"ts/restrict-template-expressions": "off",
|
|
1085
|
+
"ts/unbound-method": "off"
|
|
1086
|
+
},
|
|
1087
|
+
...overrides
|
|
998
1088
|
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
return configs2;
|
|
1089
|
+
}
|
|
1090
|
+
];
|
|
1002
1091
|
}
|
|
1003
1092
|
|
|
1004
1093
|
// src/configs/node.ts
|
|
1005
1094
|
async function node() {
|
|
1006
1095
|
return [
|
|
1007
1096
|
{
|
|
1008
|
-
name: "eslint
|
|
1097
|
+
name: "eslint/node/rules",
|
|
1009
1098
|
plugins: {
|
|
1010
1099
|
node: import_eslint_plugin_n.default
|
|
1011
1100
|
},
|
|
@@ -1023,6 +1112,39 @@ async function node() {
|
|
|
1023
1112
|
];
|
|
1024
1113
|
}
|
|
1025
1114
|
|
|
1115
|
+
// src/configs/perfectionist.ts
|
|
1116
|
+
async function perfectionist() {
|
|
1117
|
+
return [
|
|
1118
|
+
{
|
|
1119
|
+
name: "eslint/perfectionist/setup",
|
|
1120
|
+
plugins: {
|
|
1121
|
+
perfectionist: import_eslint_plugin_perfectionist.default
|
|
1122
|
+
},
|
|
1123
|
+
rules: {
|
|
1124
|
+
"perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
|
|
1125
|
+
"perfectionist/sort-imports": ["error", {
|
|
1126
|
+
groups: [
|
|
1127
|
+
"type",
|
|
1128
|
+
["parent-type", "sibling-type", "index-type"],
|
|
1129
|
+
"builtin",
|
|
1130
|
+
"external",
|
|
1131
|
+
["internal", "internal-type"],
|
|
1132
|
+
["parent", "sibling", "index"],
|
|
1133
|
+
"side-effect",
|
|
1134
|
+
"object",
|
|
1135
|
+
"unknown"
|
|
1136
|
+
],
|
|
1137
|
+
// newlinesBetween: 'ignore',
|
|
1138
|
+
order: "asc",
|
|
1139
|
+
type: "natural"
|
|
1140
|
+
}],
|
|
1141
|
+
"perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
|
|
1142
|
+
"perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
];
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1026
1148
|
// src/configs/react.ts
|
|
1027
1149
|
var import_local_pkg2 = require("local-pkg");
|
|
1028
1150
|
var ReactRefreshAllowConstantExportPackages = [
|
|
@@ -1061,7 +1183,7 @@ async function react(options = {}) {
|
|
|
1061
1183
|
const plugins = pluginReact.configs.all.plugins;
|
|
1062
1184
|
return [
|
|
1063
1185
|
{
|
|
1064
|
-
name: "eslint
|
|
1186
|
+
name: "eslint/react/setup",
|
|
1065
1187
|
plugins: {
|
|
1066
1188
|
"react": plugins["@eslint-react"],
|
|
1067
1189
|
"react-dom": plugins["@eslint-react/dom"],
|
|
@@ -1082,7 +1204,7 @@ async function react(options = {}) {
|
|
|
1082
1204
|
...isTypeAware ? { project: tsconfigPath } : {}
|
|
1083
1205
|
}
|
|
1084
1206
|
},
|
|
1085
|
-
name: "eslint
|
|
1207
|
+
name: "eslint/react/rules",
|
|
1086
1208
|
rules: {
|
|
1087
1209
|
// recommended rules from @eslint-react/dom
|
|
1088
1210
|
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
@@ -1186,7 +1308,7 @@ async function sortPackageJson() {
|
|
|
1186
1308
|
return [
|
|
1187
1309
|
{
|
|
1188
1310
|
files: ["**/package.json"],
|
|
1189
|
-
name: "eslint
|
|
1311
|
+
name: "eslint/sort/package-json",
|
|
1190
1312
|
rules: {
|
|
1191
1313
|
"jsonc/sort-array-values": [
|
|
1192
1314
|
"error",
|
|
@@ -1288,7 +1410,7 @@ function sortTsconfig() {
|
|
|
1288
1410
|
return [
|
|
1289
1411
|
{
|
|
1290
1412
|
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
1291
|
-
name: "eslint
|
|
1413
|
+
name: "eslint/sort/tsconfig",
|
|
1292
1414
|
rules: {
|
|
1293
1415
|
"jsonc/sort-keys": [
|
|
1294
1416
|
"error",
|
|
@@ -1421,13 +1543,13 @@ async function test(options = {}) {
|
|
|
1421
1543
|
pluginVitest,
|
|
1422
1544
|
pluginNoOnlyTests
|
|
1423
1545
|
] = await Promise.all([
|
|
1424
|
-
interopDefault(import("eslint-plugin
|
|
1546
|
+
interopDefault(import("@vitest/eslint-plugin")),
|
|
1425
1547
|
// @ts-expect-error missing types
|
|
1426
1548
|
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1427
1549
|
]);
|
|
1428
1550
|
return [
|
|
1429
1551
|
{
|
|
1430
|
-
name: "eslint
|
|
1552
|
+
name: "eslint/test/setup",
|
|
1431
1553
|
plugins: {
|
|
1432
1554
|
test: {
|
|
1433
1555
|
...pluginVitest,
|
|
@@ -1441,7 +1563,7 @@ async function test(options = {}) {
|
|
|
1441
1563
|
},
|
|
1442
1564
|
{
|
|
1443
1565
|
files,
|
|
1444
|
-
name: "eslint
|
|
1566
|
+
name: "eslint/test/rules",
|
|
1445
1567
|
rules: {
|
|
1446
1568
|
"node/prefer-global/process": "off",
|
|
1447
1569
|
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
@@ -1457,6 +1579,65 @@ async function test(options = {}) {
|
|
|
1457
1579
|
];
|
|
1458
1580
|
}
|
|
1459
1581
|
|
|
1582
|
+
// src/configs/toml.ts
|
|
1583
|
+
async function toml(options = {}) {
|
|
1584
|
+
const {
|
|
1585
|
+
files = [GLOB_TOML],
|
|
1586
|
+
overrides = {},
|
|
1587
|
+
stylistic: stylistic2 = true
|
|
1588
|
+
} = options;
|
|
1589
|
+
const {
|
|
1590
|
+
indent = 4
|
|
1591
|
+
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1592
|
+
const [
|
|
1593
|
+
pluginToml,
|
|
1594
|
+
parserToml
|
|
1595
|
+
] = await Promise.all([
|
|
1596
|
+
interopDefault(import("eslint-plugin-toml")),
|
|
1597
|
+
interopDefault(import("toml-eslint-parser"))
|
|
1598
|
+
]);
|
|
1599
|
+
return [
|
|
1600
|
+
{
|
|
1601
|
+
name: "eslint/toml/setup",
|
|
1602
|
+
plugins: {
|
|
1603
|
+
toml: pluginToml
|
|
1604
|
+
}
|
|
1605
|
+
},
|
|
1606
|
+
{
|
|
1607
|
+
files,
|
|
1608
|
+
languageOptions: {
|
|
1609
|
+
parser: parserToml
|
|
1610
|
+
},
|
|
1611
|
+
name: "eslint/toml/rules",
|
|
1612
|
+
rules: {
|
|
1613
|
+
"style/spaced-comment": "off",
|
|
1614
|
+
"toml/comma-style": "error",
|
|
1615
|
+
"toml/keys-order": "error",
|
|
1616
|
+
"toml/no-space-dots": "error",
|
|
1617
|
+
"toml/no-unreadable-number-separator": "error",
|
|
1618
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
1619
|
+
"toml/precision-of-integer": "error",
|
|
1620
|
+
"toml/tables-order": "error",
|
|
1621
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1622
|
+
...stylistic2 ? {
|
|
1623
|
+
"toml/array-bracket-newline": "error",
|
|
1624
|
+
"toml/array-bracket-spacing": "error",
|
|
1625
|
+
"toml/array-element-newline": "error",
|
|
1626
|
+
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1627
|
+
"toml/inline-table-curly-spacing": "error",
|
|
1628
|
+
"toml/key-spacing": "error",
|
|
1629
|
+
"toml/padding-line-between-pairs": "error",
|
|
1630
|
+
"toml/padding-line-between-tables": "error",
|
|
1631
|
+
"toml/quoted-keys": "error",
|
|
1632
|
+
"toml/spaced-comment": "error",
|
|
1633
|
+
"toml/table-bracket-spacing": "error"
|
|
1634
|
+
} : {},
|
|
1635
|
+
...overrides
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
];
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1460
1641
|
// src/configs/typescript.ts
|
|
1461
1642
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
1462
1643
|
async function typescript(options = {}) {
|
|
@@ -1470,6 +1651,9 @@ async function typescript(options = {}) {
|
|
|
1470
1651
|
GLOB_SRC,
|
|
1471
1652
|
...componentExts.map((ext) => `**/*.${ext}`)
|
|
1472
1653
|
];
|
|
1654
|
+
const ignoresTypeAware = options.ignoresTypeAware ?? [
|
|
1655
|
+
`${GLOB_MARKDOWN}/**`
|
|
1656
|
+
];
|
|
1473
1657
|
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
1474
1658
|
const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
|
|
1475
1659
|
const isTypeAware = !!tsconfigPath;
|
|
@@ -1522,13 +1706,13 @@ async function typescript(options = {}) {
|
|
|
1522
1706
|
...parserOptions
|
|
1523
1707
|
}
|
|
1524
1708
|
},
|
|
1525
|
-
name: `eslint
|
|
1709
|
+
name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
1526
1710
|
};
|
|
1527
1711
|
}
|
|
1528
1712
|
return [
|
|
1529
1713
|
{
|
|
1530
1714
|
// Install the plugins without globs, so they can be configured separately.
|
|
1531
|
-
name: "eslint
|
|
1715
|
+
name: "eslint/typescript/setup",
|
|
1532
1716
|
plugins: {
|
|
1533
1717
|
antfu: import_eslint_plugin_antfu.default,
|
|
1534
1718
|
ts: pluginTs
|
|
@@ -1536,14 +1720,14 @@ async function typescript(options = {}) {
|
|
|
1536
1720
|
},
|
|
1537
1721
|
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
1538
1722
|
...isTypeAware ? [
|
|
1539
|
-
makeParser(
|
|
1540
|
-
makeParser(
|
|
1723
|
+
makeParser(false, files),
|
|
1724
|
+
makeParser(true, filesTypeAware, ignoresTypeAware)
|
|
1541
1725
|
] : [
|
|
1542
1726
|
makeParser(false, files)
|
|
1543
1727
|
],
|
|
1544
1728
|
{
|
|
1545
1729
|
files,
|
|
1546
|
-
name: "eslint
|
|
1730
|
+
name: "eslint/typescript/rules",
|
|
1547
1731
|
rules: {
|
|
1548
1732
|
...renameRules(
|
|
1549
1733
|
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
@@ -1554,7 +1738,6 @@ async function typescript(options = {}) {
|
|
|
1554
1738
|
{ "@typescript-eslint": "ts" }
|
|
1555
1739
|
),
|
|
1556
1740
|
"no-dupe-class-members": "off",
|
|
1557
|
-
"no-loss-of-precision": "off",
|
|
1558
1741
|
"no-redeclare": "off",
|
|
1559
1742
|
"no-use-before-define": "off",
|
|
1560
1743
|
"no-useless-constructor": "off",
|
|
@@ -1572,7 +1755,6 @@ async function typescript(options = {}) {
|
|
|
1572
1755
|
"ts/no-extraneous-class": "off",
|
|
1573
1756
|
"ts/no-import-type-side-effects": "error",
|
|
1574
1757
|
"ts/no-invalid-void-type": "off",
|
|
1575
|
-
"ts/no-loss-of-precision": "error",
|
|
1576
1758
|
"ts/no-non-null-assertion": "off",
|
|
1577
1759
|
"ts/no-redeclare": "error",
|
|
1578
1760
|
"ts/no-require-imports": "error",
|
|
@@ -1594,75 +1776,42 @@ async function typescript(options = {}) {
|
|
|
1594
1776
|
},
|
|
1595
1777
|
...isTypeAware ? [{
|
|
1596
1778
|
files: filesTypeAware,
|
|
1597
|
-
|
|
1779
|
+
ignores: ignoresTypeAware,
|
|
1780
|
+
name: "eslint/typescript/rules-type-aware",
|
|
1598
1781
|
rules: {
|
|
1599
1782
|
...typeAwareRules,
|
|
1600
1783
|
...overrides
|
|
1601
1784
|
}
|
|
1602
|
-
}] : []
|
|
1603
|
-
{
|
|
1604
|
-
files: ["**/*.d.?([cm])ts"],
|
|
1605
|
-
name: "eslint:typescript:disables:dts",
|
|
1606
|
-
rules: {
|
|
1607
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
1608
|
-
"import/no-duplicates": "off",
|
|
1609
|
-
"no-restricted-syntax": "off",
|
|
1610
|
-
"unused-imports/no-unused-vars": "off"
|
|
1611
|
-
}
|
|
1612
|
-
},
|
|
1613
|
-
{
|
|
1614
|
-
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1615
|
-
name: "eslint:typescript:disables:test",
|
|
1616
|
-
rules: {
|
|
1617
|
-
"no-unused-expressions": "off"
|
|
1618
|
-
}
|
|
1619
|
-
},
|
|
1620
|
-
{
|
|
1621
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
1622
|
-
name: "eslint:typescript:disables:cjs",
|
|
1623
|
-
rules: {
|
|
1624
|
-
"ts/no-require-imports": "off",
|
|
1625
|
-
"ts/no-var-requires": "off"
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1785
|
+
}] : []
|
|
1628
1786
|
];
|
|
1629
1787
|
}
|
|
1630
1788
|
|
|
1631
1789
|
// src/configs/unicorn.ts
|
|
1632
|
-
async function unicorn() {
|
|
1790
|
+
async function unicorn(options = {}) {
|
|
1633
1791
|
return [
|
|
1634
1792
|
{
|
|
1635
|
-
name: "eslint
|
|
1793
|
+
name: "eslint/unicorn/rules",
|
|
1636
1794
|
plugins: {
|
|
1637
1795
|
unicorn: import_eslint_plugin_unicorn.default
|
|
1638
1796
|
},
|
|
1639
1797
|
rules: {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
"unicorn/prefer-node-protocol": "error",
|
|
1658
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1659
|
-
"unicorn/prefer-number-properties": "error",
|
|
1660
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
1661
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1662
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
1663
|
-
"unicorn/prefer-type-error": "error",
|
|
1664
|
-
// Use new when throwing error
|
|
1665
|
-
"unicorn/throw-new-error": "error"
|
|
1798
|
+
...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
|
|
1799
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
1800
|
+
"unicorn/error-message": "error",
|
|
1801
|
+
"unicorn/escape-case": "error",
|
|
1802
|
+
"unicorn/new-for-builtins": "error",
|
|
1803
|
+
"unicorn/no-instanceof-array": "error",
|
|
1804
|
+
"unicorn/no-new-array": "error",
|
|
1805
|
+
"unicorn/no-new-buffer": "error",
|
|
1806
|
+
"unicorn/number-literal-case": "error",
|
|
1807
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
1808
|
+
"unicorn/prefer-includes": "error",
|
|
1809
|
+
"unicorn/prefer-node-protocol": "error",
|
|
1810
|
+
"unicorn/prefer-number-properties": "error",
|
|
1811
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1812
|
+
"unicorn/prefer-type-error": "error",
|
|
1813
|
+
"unicorn/throw-new-error": "error"
|
|
1814
|
+
}
|
|
1666
1815
|
}
|
|
1667
1816
|
}
|
|
1668
1817
|
];
|
|
@@ -1685,7 +1834,7 @@ async function unocss(options = {}) {
|
|
|
1685
1834
|
]);
|
|
1686
1835
|
return [
|
|
1687
1836
|
{
|
|
1688
|
-
name: "eslint
|
|
1837
|
+
name: "eslint/unocss/rules",
|
|
1689
1838
|
plugins: {
|
|
1690
1839
|
unocss: pluginUnoCSS
|
|
1691
1840
|
},
|
|
@@ -1750,7 +1899,7 @@ async function vue(options = {}) {
|
|
|
1750
1899
|
watchEffect: "readonly"
|
|
1751
1900
|
}
|
|
1752
1901
|
},
|
|
1753
|
-
name: "eslint
|
|
1902
|
+
name: "eslint/vue/setup",
|
|
1754
1903
|
plugins: {
|
|
1755
1904
|
vue: pluginVue
|
|
1756
1905
|
}
|
|
@@ -1768,7 +1917,7 @@ async function vue(options = {}) {
|
|
|
1768
1917
|
sourceType: "module"
|
|
1769
1918
|
}
|
|
1770
1919
|
},
|
|
1771
|
-
name: "eslint
|
|
1920
|
+
name: "eslint/vue/rules",
|
|
1772
1921
|
processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
|
|
1773
1922
|
pluginVue.processors[".vue"],
|
|
1774
1923
|
processorVueBlocks({
|
|
@@ -1897,7 +2046,7 @@ async function yaml(options = {}) {
|
|
|
1897
2046
|
]);
|
|
1898
2047
|
return [
|
|
1899
2048
|
{
|
|
1900
|
-
name: "eslint
|
|
2049
|
+
name: "eslint/yaml/setup",
|
|
1901
2050
|
plugins: {
|
|
1902
2051
|
yaml: pluginYaml
|
|
1903
2052
|
}
|
|
@@ -1907,7 +2056,7 @@ async function yaml(options = {}) {
|
|
|
1907
2056
|
languageOptions: {
|
|
1908
2057
|
parser: parserYaml
|
|
1909
2058
|
},
|
|
1910
|
-
name: "eslint
|
|
2059
|
+
name: "eslint/yaml/rules",
|
|
1911
2060
|
rules: {
|
|
1912
2061
|
"style/spaced-comment": "off",
|
|
1913
2062
|
"yaml/block-mapping": "error",
|
|
@@ -1936,70 +2085,9 @@ async function yaml(options = {}) {
|
|
|
1936
2085
|
];
|
|
1937
2086
|
}
|
|
1938
2087
|
|
|
1939
|
-
// src/configs/toml.ts
|
|
1940
|
-
async function toml(options = {}) {
|
|
1941
|
-
const {
|
|
1942
|
-
files = [GLOB_TOML],
|
|
1943
|
-
overrides = {},
|
|
1944
|
-
stylistic: stylistic2 = true
|
|
1945
|
-
} = options;
|
|
1946
|
-
const {
|
|
1947
|
-
indent = 4
|
|
1948
|
-
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1949
|
-
const [
|
|
1950
|
-
pluginToml,
|
|
1951
|
-
parserToml
|
|
1952
|
-
] = await Promise.all([
|
|
1953
|
-
interopDefault(import("eslint-plugin-toml")),
|
|
1954
|
-
interopDefault(import("toml-eslint-parser"))
|
|
1955
|
-
]);
|
|
1956
|
-
return [
|
|
1957
|
-
{
|
|
1958
|
-
name: "eslint:toml:setup",
|
|
1959
|
-
plugins: {
|
|
1960
|
-
toml: pluginToml
|
|
1961
|
-
}
|
|
1962
|
-
},
|
|
1963
|
-
{
|
|
1964
|
-
files,
|
|
1965
|
-
languageOptions: {
|
|
1966
|
-
parser: parserToml
|
|
1967
|
-
},
|
|
1968
|
-
name: "eslint:toml:rules",
|
|
1969
|
-
rules: {
|
|
1970
|
-
"style/spaced-comment": "off",
|
|
1971
|
-
"toml/comma-style": "error",
|
|
1972
|
-
"toml/keys-order": "error",
|
|
1973
|
-
"toml/no-space-dots": "error",
|
|
1974
|
-
"toml/no-unreadable-number-separator": "error",
|
|
1975
|
-
"toml/precision-of-fractional-seconds": "error",
|
|
1976
|
-
"toml/precision-of-integer": "error",
|
|
1977
|
-
"toml/tables-order": "error",
|
|
1978
|
-
"toml/vue-custom-block/no-parsing-error": "error",
|
|
1979
|
-
...stylistic2 ? {
|
|
1980
|
-
"toml/array-bracket-newline": "error",
|
|
1981
|
-
"toml/array-bracket-spacing": "error",
|
|
1982
|
-
"toml/array-element-newline": "error",
|
|
1983
|
-
"toml/indent": ["error", indent === "tab" ? 4 : indent],
|
|
1984
|
-
"toml/inline-table-curly-spacing": "error",
|
|
1985
|
-
"toml/key-spacing": "error",
|
|
1986
|
-
"toml/padding-line-between-pairs": "error",
|
|
1987
|
-
"toml/padding-line-between-tables": "error",
|
|
1988
|
-
"toml/quoted-keys": "error",
|
|
1989
|
-
"toml/spaced-comment": "error",
|
|
1990
|
-
"toml/table-bracket-spacing": "error"
|
|
1991
|
-
} : {},
|
|
1992
|
-
...overrides
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
];
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
2088
|
// src/factory.ts
|
|
1999
2089
|
var flatConfigProps = [
|
|
2000
2090
|
"name",
|
|
2001
|
-
"files",
|
|
2002
|
-
"ignores",
|
|
2003
2091
|
"languageOptions",
|
|
2004
2092
|
"linterOptions",
|
|
2005
2093
|
"processor",
|
|
@@ -2034,15 +2122,21 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2034
2122
|
autoRenamePlugins = true,
|
|
2035
2123
|
componentExts = [],
|
|
2036
2124
|
gitignore: enableGitignore = true,
|
|
2037
|
-
isInEditor = isInEditorEnv(),
|
|
2038
2125
|
jsx: enableJsx = true,
|
|
2039
2126
|
overrides = {},
|
|
2040
2127
|
react: enableReact = ReactPackages.some((i) => (0, import_local_pkg4.isPackageExists)(i)),
|
|
2041
2128
|
regexp: enableRegexp = true,
|
|
2042
2129
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2130
|
+
unicorn: enableUnicorn = true,
|
|
2043
2131
|
unocss: enableUnoCSS = false,
|
|
2044
2132
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2045
2133
|
} = options;
|
|
2134
|
+
let isInEditor = options.isInEditor;
|
|
2135
|
+
if (isInEditor == null) {
|
|
2136
|
+
isInEditor = isInEditorEnv();
|
|
2137
|
+
if (isInEditor)
|
|
2138
|
+
console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
|
|
2139
|
+
}
|
|
2046
2140
|
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2047
2141
|
const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
|
|
2048
2142
|
if (stylisticOptions) {
|
|
@@ -2053,9 +2147,15 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2053
2147
|
const configs2 = [];
|
|
2054
2148
|
if (enableGitignore) {
|
|
2055
2149
|
if (typeof enableGitignore !== "boolean") {
|
|
2056
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(
|
|
2150
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2151
|
+
name: "eslint/gitignore",
|
|
2152
|
+
...enableGitignore
|
|
2153
|
+
})]));
|
|
2057
2154
|
} else {
|
|
2058
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2155
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2156
|
+
name: "eslint/gitignore",
|
|
2157
|
+
strict: false
|
|
2158
|
+
})]));
|
|
2059
2159
|
}
|
|
2060
2160
|
}
|
|
2061
2161
|
configs2.push(
|
|
@@ -2074,10 +2174,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2074
2174
|
imports({
|
|
2075
2175
|
stylistic: stylisticOptions
|
|
2076
2176
|
}),
|
|
2077
|
-
unicorn(),
|
|
2078
2177
|
// Optional plugins (installed but not enabled by default)
|
|
2079
2178
|
perfectionist()
|
|
2080
2179
|
);
|
|
2180
|
+
if (enableUnicorn) {
|
|
2181
|
+
configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2182
|
+
}
|
|
2081
2183
|
if (enableVue) {
|
|
2082
2184
|
componentExts.push("vue");
|
|
2083
2185
|
}
|
|
@@ -2170,6 +2272,12 @@ function lincy(options = {}, ...userConfigs) {
|
|
|
2170
2272
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2171
2273
|
));
|
|
2172
2274
|
}
|
|
2275
|
+
configs2.push(
|
|
2276
|
+
disables()
|
|
2277
|
+
);
|
|
2278
|
+
if ("files" in options) {
|
|
2279
|
+
throw new Error("[@lincy/eslint-config] \u7B2C\u4E00\u4E2A\u53C2\u6570\u4E0D\u5E94\u5305\u542B\u201Cfiles\u201D\u5C5E\u6027\uFF0C\u56E0\u4E3A\u9009\u9879\u5E94\u8BE5\u662F\u5168\u5C40\u7684\u3002\u8BF7\u5C06\u5176\u653E\u5728\u7B2C\u4E8C\u4E2A\u6216\u66F4\u540E\u9762\u7684\u914D\u7F6E\u4E2D\u3002");
|
|
2280
|
+
}
|
|
2173
2281
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2174
2282
|
if (key in options) {
|
|
2175
2283
|
acc[key] = options[key];
|
|
@@ -2214,22 +2322,27 @@ var src_default = lincy;
|
|
|
2214
2322
|
GLOB_SRC_EXT,
|
|
2215
2323
|
GLOB_STYLE,
|
|
2216
2324
|
GLOB_SVELTE,
|
|
2325
|
+
GLOB_SVG,
|
|
2217
2326
|
GLOB_TESTS,
|
|
2218
2327
|
GLOB_TOML,
|
|
2219
2328
|
GLOB_TS,
|
|
2220
2329
|
GLOB_TSX,
|
|
2221
2330
|
GLOB_VUE,
|
|
2331
|
+
GLOB_XML,
|
|
2222
2332
|
GLOB_YAML,
|
|
2223
2333
|
StylisticConfigDefaults,
|
|
2224
2334
|
combine,
|
|
2225
2335
|
comments,
|
|
2226
2336
|
defaultPluginRenaming,
|
|
2337
|
+
disables,
|
|
2227
2338
|
ensurePackages,
|
|
2228
2339
|
formatters,
|
|
2229
2340
|
ignores,
|
|
2230
2341
|
imports,
|
|
2231
2342
|
interopDefault,
|
|
2232
2343
|
isInEditorEnv,
|
|
2344
|
+
isInGitHooksOrLintStaged,
|
|
2345
|
+
isPackageInScope,
|
|
2233
2346
|
javascript,
|
|
2234
2347
|
jsdoc,
|
|
2235
2348
|
jsonc,
|
|
@@ -2237,6 +2350,7 @@ var src_default = lincy;
|
|
|
2237
2350
|
lincy,
|
|
2238
2351
|
markdown,
|
|
2239
2352
|
node,
|
|
2353
|
+
parserPlain,
|
|
2240
2354
|
perfectionist,
|
|
2241
2355
|
react,
|
|
2242
2356
|
regexp,
|