@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/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
1
  // src/factory.ts
2
- import { isPackageExists as isPackageExists3 } from "local-pkg";
3
2
  import { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
4
4
 
5
5
  // src/plugins.ts
6
- import { default as default2 } from "eslint-plugin-antfu";
7
- import { default as default3 } from "eslint-plugin-eslint-comments";
6
+ import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
7
+ import { default as default3 } from "eslint-plugin-antfu";
8
8
  import * as pluginImport from "eslint-plugin-import-x";
9
9
  import { default as default4 } from "eslint-plugin-n";
10
- import { default as default5 } from "eslint-plugin-unicorn";
11
- import { default as default6 } from "eslint-plugin-unused-imports";
12
- import { default as default7 } from "eslint-plugin-perfectionist";
10
+ import { default as default5 } from "eslint-plugin-perfectionist";
11
+ import { default as default6 } from "eslint-plugin-unicorn";
12
+ import { default as default7 } from "eslint-plugin-unused-imports";
13
13
 
14
14
  // src/configs/comments.ts
15
15
  async function comments() {
16
16
  return [
17
17
  {
18
- name: "eslint:comments",
18
+ name: "eslint/comments/rules",
19
19
  plugins: {
20
- "eslint-comments": default3
20
+ "eslint-comments": default2
21
21
  },
22
22
  rules: {
23
23
  "eslint-comments/no-aggregating-enable": "error",
@@ -50,6 +50,8 @@ var GLOB_SVELTE = "**/*.svelte";
50
50
  var GLOB_VUE = "**/*.vue";
51
51
  var GLOB_YAML = "**/*.y?(a)ml";
52
52
  var GLOB_TOML = "**/*.toml";
53
+ var GLOB_XML = "**/*.xml";
54
+ var GLOB_SVG = "**/*.svg";
53
55
  var GLOB_HTML = "**/*.htm?(l)";
54
56
  var GLOB_GRAPHQL = "**/*.{g,graph}ql";
55
57
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
@@ -100,6 +102,408 @@ var GLOB_EXCLUDE = [
100
102
  "**/components.d.ts"
101
103
  ];
102
104
 
105
+ // src/configs/disables.ts
106
+ async function disables() {
107
+ return [
108
+ {
109
+ files: [`scripts/${GLOB_SRC}`],
110
+ name: "eslint/disables/scripts",
111
+ rules: {
112
+ "no-console": "off",
113
+ "ts/explicit-function-return-type": "off"
114
+ }
115
+ },
116
+ {
117
+ files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
118
+ name: "eslint/disables/cli",
119
+ rules: {
120
+ "no-console": "off"
121
+ }
122
+ },
123
+ {
124
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
125
+ name: "eslint/disables/bin",
126
+ rules: {
127
+ "antfu/no-import-dist": "off",
128
+ "antfu/no-import-node-modules-by-path": "off"
129
+ }
130
+ },
131
+ {
132
+ files: ["**/*.d.?([cm])ts"],
133
+ name: "eslint/disables/dts",
134
+ rules: {
135
+ "eslint-comments/no-unlimited-disable": "off",
136
+ "import/no-duplicates": "off",
137
+ "no-restricted-syntax": "off",
138
+ "unused-imports/no-unused-vars": "off"
139
+ }
140
+ },
141
+ {
142
+ files: ["**/*.{test,spec}.([tj])s?(x)"],
143
+ name: "eslint/disables/test",
144
+ rules: {
145
+ "no-unused-expressions": "off"
146
+ }
147
+ },
148
+ {
149
+ files: ["**/*.js", "**/*.cjs"],
150
+ name: "eslint/disables/cjs",
151
+ rules: {
152
+ "ts/no-require-imports": "off"
153
+ }
154
+ }
155
+ ];
156
+ }
157
+
158
+ // src/utils.ts
159
+ import process from "node:process";
160
+ import { fileURLToPath } from "node:url";
161
+ import { isPackageExists } from "local-pkg";
162
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
163
+ var isCwdInScope = isPackageExists("@antfu/eslint-config");
164
+ var parserPlain = {
165
+ meta: {
166
+ name: "parser-plain"
167
+ },
168
+ parseForESLint: (code) => ({
169
+ ast: {
170
+ body: [],
171
+ comments: [],
172
+ loc: { end: code.length, start: 0 },
173
+ range: [0, code.length],
174
+ tokens: [],
175
+ type: "Program"
176
+ },
177
+ scopeManager: null,
178
+ services: { isPlain: true },
179
+ visitorKeys: {
180
+ Program: []
181
+ }
182
+ })
183
+ };
184
+ async function combine(...configs2) {
185
+ const resolved = await Promise.all(configs2);
186
+ return resolved.flat();
187
+ }
188
+ function renameRules(rules, map) {
189
+ return Object.fromEntries(
190
+ Object.entries(rules).map(([key, value]) => {
191
+ for (const [from, to] of Object.entries(map)) {
192
+ if (key.startsWith(`${from}/`)) {
193
+ return [to + key.slice(from.length), value];
194
+ }
195
+ }
196
+ return [key, value];
197
+ })
198
+ );
199
+ }
200
+ function renamePluginInConfigs(configs2, map) {
201
+ return configs2.map((i) => {
202
+ const clone = { ...i };
203
+ if (clone.rules) {
204
+ clone.rules = renameRules(clone.rules, map);
205
+ }
206
+ if (clone.plugins) {
207
+ clone.plugins = Object.fromEntries(
208
+ Object.entries(clone.plugins).map(([key, value]) => {
209
+ if (key in map) {
210
+ return [map[key], value];
211
+ }
212
+ return [key, value];
213
+ })
214
+ );
215
+ }
216
+ return clone;
217
+ });
218
+ }
219
+ function toArray(value) {
220
+ return Array.isArray(value) ? value : [value];
221
+ }
222
+ async function interopDefault(m) {
223
+ const resolved = await m;
224
+ return resolved.default || resolved;
225
+ }
226
+ function isPackageInScope(name) {
227
+ return isPackageExists(name, { paths: [scopeUrl] });
228
+ }
229
+ async function ensurePackages(packages) {
230
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
231
+ return;
232
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
233
+ if (nonExistingPackages.length === 0)
234
+ return;
235
+ const p = await import("@clack/prompts");
236
+ const result = await p.confirm({
237
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
238
+ });
239
+ if (result)
240
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
241
+ }
242
+ function isInEditorEnv() {
243
+ if (process.env.CI)
244
+ return false;
245
+ if (isInGitHooksOrLintStaged())
246
+ return false;
247
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
248
+ }
249
+ function isInGitHooksOrLintStaged() {
250
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
251
+ }
252
+
253
+ // src/configs/stylistic.ts
254
+ var StylisticConfigDefaults = {
255
+ indent: 4,
256
+ jsx: true,
257
+ lessOpinionated: false,
258
+ quotes: "single",
259
+ semi: false
260
+ };
261
+ async function stylistic(options = {}) {
262
+ const {
263
+ overrides = {},
264
+ stylistic: stylistic2 = StylisticConfigDefaults
265
+ } = options;
266
+ const {
267
+ indent,
268
+ jsx: jsx2,
269
+ lessOpinionated,
270
+ quotes,
271
+ semi
272
+ } = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
273
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
274
+ const config = pluginStylistic.configs.customize({
275
+ flat: true,
276
+ indent,
277
+ jsx: jsx2,
278
+ pluginName: "style",
279
+ quotes,
280
+ semi
281
+ });
282
+ return [
283
+ {
284
+ name: "eslint/stylistic/rules",
285
+ plugins: {
286
+ antfu: default3,
287
+ style: pluginStylistic
288
+ },
289
+ rules: {
290
+ ...config.rules,
291
+ "antfu/consistent-chaining": "error",
292
+ "antfu/consistent-list-newline": "off",
293
+ ...lessOpinionated ? {
294
+ curly: ["error", "all"]
295
+ } : {
296
+ "antfu/curly": "error",
297
+ "antfu/if-newline": "error",
298
+ "antfu/top-level-function": "error"
299
+ },
300
+ // 覆盖`stylistic`默认规则
301
+ "style/brace-style": ["error", "stroustrup"],
302
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
303
+ "style/multiline-ternary": ["error", "never"],
304
+ ...overrides
305
+ }
306
+ }
307
+ ];
308
+ }
309
+
310
+ // src/configs/formatters.ts
311
+ async function formatters(options = {}, stylistic2 = {}) {
312
+ const defaultIndent = 4;
313
+ if (options === true) {
314
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
315
+ options = {
316
+ css: false,
317
+ graphql: true,
318
+ html: true,
319
+ markdown: true,
320
+ svg: isPrettierPluginXmlInScope,
321
+ xml: isPrettierPluginXmlInScope
322
+ };
323
+ }
324
+ await ensurePackages([
325
+ "eslint-plugin-format",
326
+ options.xml || options.svg ? "@prettier/plugin-xml" : void 0
327
+ ]);
328
+ const {
329
+ indent,
330
+ quotes,
331
+ semi
332
+ } = {
333
+ ...StylisticConfigDefaults,
334
+ ...stylistic2
335
+ };
336
+ const prettierOptions = Object.assign(
337
+ {
338
+ endOfLine: "lf",
339
+ printWidth: 200,
340
+ semi,
341
+ singleQuote: quotes === "single",
342
+ tabWidth: typeof indent === "number" ? indent : defaultIndent,
343
+ trailingComma: "all",
344
+ useTabs: indent === "tab"
345
+ },
346
+ options.prettierOptions || {}
347
+ );
348
+ const prettierXmlOptions = {
349
+ xmlQuoteAttributes: "double",
350
+ xmlSelfClosingSpace: true,
351
+ xmlSortAttributesByKey: false,
352
+ xmlWhitespaceSensitivity: "ignore"
353
+ };
354
+ const dprintOptions = Object.assign(
355
+ {
356
+ indentWidth: typeof indent === "number" ? indent : defaultIndent,
357
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
358
+ useTabs: indent === "tab"
359
+ },
360
+ options.dprintOptions || {}
361
+ );
362
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
363
+ const configs2 = [
364
+ {
365
+ name: "eslint/formatters/setup",
366
+ plugins: {
367
+ format: pluginFormat
368
+ }
369
+ }
370
+ ];
371
+ if (options.css) {
372
+ configs2.push(
373
+ {
374
+ files: [GLOB_CSS, GLOB_POSTCSS],
375
+ languageOptions: {
376
+ parser: parserPlain
377
+ },
378
+ name: "eslint/formatters/css",
379
+ rules: {
380
+ "format/prettier": [
381
+ "error",
382
+ {
383
+ ...prettierOptions,
384
+ parser: "css"
385
+ }
386
+ ]
387
+ }
388
+ },
389
+ {
390
+ files: [GLOB_SCSS],
391
+ languageOptions: {
392
+ parser: parserPlain
393
+ },
394
+ name: "eslint/formatters/scss",
395
+ rules: {
396
+ "format/prettier": [
397
+ "error",
398
+ {
399
+ ...prettierOptions,
400
+ parser: "scss"
401
+ }
402
+ ]
403
+ }
404
+ },
405
+ {
406
+ files: [GLOB_LESS],
407
+ languageOptions: {
408
+ parser: parserPlain
409
+ },
410
+ name: "eslint/formatters/less",
411
+ rules: {
412
+ "format/prettier": [
413
+ "error",
414
+ {
415
+ ...prettierOptions,
416
+ parser: "less"
417
+ }
418
+ ]
419
+ }
420
+ }
421
+ );
422
+ }
423
+ if (options.html) {
424
+ configs2.push({
425
+ files: [GLOB_HTML],
426
+ languageOptions: {
427
+ parser: parserPlain
428
+ },
429
+ name: "eslint/formatters/html",
430
+ rules: {
431
+ "format/prettier": [
432
+ "error",
433
+ {
434
+ ...prettierOptions,
435
+ parser: "html"
436
+ }
437
+ ]
438
+ }
439
+ });
440
+ }
441
+ if (options.svg) {
442
+ configs2.push({
443
+ files: [GLOB_SVG],
444
+ languageOptions: {
445
+ parser: parserPlain
446
+ },
447
+ name: "eslint/formatters/svg",
448
+ rules: {
449
+ "format/prettier": [
450
+ "error",
451
+ {
452
+ ...prettierXmlOptions,
453
+ ...prettierOptions,
454
+ parser: "xml",
455
+ plugins: [
456
+ "@prettier/plugin-xml"
457
+ ]
458
+ }
459
+ ]
460
+ }
461
+ });
462
+ }
463
+ if (options.markdown) {
464
+ const formater = options.markdown === true ? "prettier" : options.markdown;
465
+ configs2.push({
466
+ files: [GLOB_MARKDOWN],
467
+ languageOptions: {
468
+ parser: parserPlain
469
+ },
470
+ name: "eslint/formatters/markdown",
471
+ rules: {
472
+ [`format/${formater}`]: [
473
+ "error",
474
+ formater === "prettier" ? {
475
+ ...prettierOptions,
476
+ embeddedLanguageFormatting: "off",
477
+ parser: "markdown"
478
+ } : {
479
+ ...dprintOptions,
480
+ language: "markdown"
481
+ }
482
+ ]
483
+ }
484
+ });
485
+ }
486
+ if (options.graphql) {
487
+ configs2.push({
488
+ files: [GLOB_GRAPHQL],
489
+ languageOptions: {
490
+ parser: parserPlain
491
+ },
492
+ name: "eslint/formatters/graphql",
493
+ rules: {
494
+ "format/prettier": [
495
+ "error",
496
+ {
497
+ ...prettierOptions,
498
+ parser: "graphql"
499
+ }
500
+ ]
501
+ }
502
+ });
503
+ }
504
+ return configs2;
505
+ }
506
+
103
507
  // src/configs/ignores.ts
104
508
  async function ignores(options = {}) {
105
509
  const {
@@ -111,7 +515,7 @@ async function ignores(options = {}) {
111
515
  ...GLOB_EXCLUDE,
112
516
  ...ignores2
113
517
  ],
114
- name: "eslint:ignores"
518
+ name: "eslint/ignores"
115
519
  }
116
520
  ];
117
521
  }
@@ -123,9 +527,9 @@ async function imports(options = {}) {
123
527
  } = options;
124
528
  return [
125
529
  {
126
- name: "eslint:imports:rules",
530
+ name: "eslint/imports/rules",
127
531
  plugins: {
128
- antfu: default2,
532
+ antfu: default3,
129
533
  import: pluginImport
130
534
  },
131
535
  rules: {
@@ -138,19 +542,10 @@ async function imports(options = {}) {
138
542
  "import/no-named-default": "error",
139
543
  "import/no-self-import": "error",
140
544
  "import/no-webpack-loader-syntax": "error",
141
- "import/order": "error",
142
545
  ...stylistic2 ? {
143
546
  "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
144
547
  } : {}
145
548
  }
146
- },
147
- {
148
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
149
- name: "eslint:imports:disables:bin",
150
- rules: {
151
- "antfu/no-import-dist": "off",
152
- "antfu/no-import-node-modules-by-path": "off"
153
- }
154
549
  }
155
550
  ];
156
551
  }
@@ -186,13 +581,13 @@ async function javascript(options = {}) {
186
581
  linterOptions: {
187
582
  reportUnusedDisableDirectives: true
188
583
  },
189
- name: "eslint:javascript:setup"
584
+ name: "eslint/javascript/setup"
190
585
  },
191
586
  {
192
- name: "eslint:javascript:rules",
587
+ name: "eslint/javascript/rules",
193
588
  plugins: {
194
- "antfu": default2,
195
- "unused-imports": default6
589
+ "antfu": default3,
590
+ "unused-imports": default7
196
591
  },
197
592
  rules: {
198
593
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
@@ -268,9 +663,6 @@ async function javascript(options = {}) {
268
663
  ],
269
664
  "no-restricted-syntax": [
270
665
  "error",
271
- "DebuggerStatement",
272
- "LabeledStatement",
273
- "WithStatement",
274
666
  "TSEnumDeclaration[const=true]",
275
667
  "TSExportAssignment"
276
668
  ],
@@ -368,86 +760,10 @@ async function javascript(options = {}) {
368
760
  "valid-typeof": ["error", { requireStringLiterals: true }],
369
761
  "vars-on-top": "error",
370
762
  "yoda": ["error", "never"],
371
- ...overrides
372
- }
373
- },
374
- {
375
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
376
- name: "eslint:scripts:disables",
377
- rules: {
378
- "no-console": "off"
379
- }
380
- }
381
- ];
382
- }
383
-
384
- // src/utils.ts
385
- import process from "node:process";
386
- import { isPackageExists } from "local-pkg";
387
- async function combine(...configs2) {
388
- const resolved = await Promise.all(configs2);
389
- return resolved.flat();
390
- }
391
- function renameRules(rules, map) {
392
- return Object.fromEntries(
393
- Object.entries(rules).map(([key, value]) => {
394
- for (const [from, to] of Object.entries(map)) {
395
- if (key.startsWith(`${from}/`)) {
396
- return [to + key.slice(from.length), value];
397
- }
398
- }
399
- return [key, value];
400
- })
401
- );
402
- }
403
- function renamePluginInConfigs(configs2, map) {
404
- return configs2.map((i) => {
405
- const clone = { ...i };
406
- if (clone.rules) {
407
- clone.rules = renameRules(clone.rules, map);
408
- }
409
- if (clone.plugins) {
410
- clone.plugins = Object.fromEntries(
411
- Object.entries(clone.plugins).map(([key, value]) => {
412
- if (key in map) {
413
- return [map[key], value];
414
- }
415
- return [key, value];
416
- })
417
- );
418
- }
419
- return clone;
420
- });
421
- }
422
- function toArray(value) {
423
- return Array.isArray(value) ? value : [value];
424
- }
425
- async function interopDefault(m) {
426
- const resolved = await m;
427
- return resolved.default || resolved;
428
- }
429
- async function ensurePackages(packages) {
430
- if (process.stdout.isTTY === false) {
431
- return;
432
- }
433
- const nonExistingPackages = packages.filter((i) => !isPackageExists(i));
434
- if (nonExistingPackages.length === 0) {
435
- return;
436
- }
437
- const { default: prompts } = await import("prompts");
438
- const { result } = await prompts([
439
- {
440
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
441
- name: "result",
442
- type: "confirm"
443
- }
444
- ]);
445
- if (result) {
446
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
447
- }
448
- }
449
- function isInEditorEnv() {
450
- return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
763
+ ...overrides
764
+ }
765
+ }
766
+ ];
451
767
  }
452
768
 
453
769
  // src/configs/jsdoc.ts
@@ -457,7 +773,7 @@ async function jsdoc(options = {}) {
457
773
  } = options;
458
774
  return [
459
775
  {
460
- name: "eslint:jsdoc:rules",
776
+ name: "eslint/jsdoc/rules",
461
777
  plugins: {
462
778
  jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
463
779
  },
@@ -502,7 +818,7 @@ async function jsonc(options = {}) {
502
818
  ]);
503
819
  return [
504
820
  {
505
- name: "eslint:jsonc:setup",
821
+ name: "eslint/jsonc/setup",
506
822
  plugins: {
507
823
  jsonc: pluginJsonc
508
824
  }
@@ -512,7 +828,7 @@ async function jsonc(options = {}) {
512
828
  languageOptions: {
513
829
  parser: parserJsonc
514
830
  },
515
- name: "eslint:jsonc:rules",
831
+ name: "eslint/jsonc/rules",
516
832
  rules: {
517
833
  "jsonc/no-bigint-literals": "error",
518
834
  "jsonc/no-binary-expression": "error",
@@ -570,347 +886,110 @@ async function jsx() {
570
886
  }
571
887
  }
572
888
  },
573
- name: "eslint:jsx:setup"
889
+ name: "eslint/jsx/setup"
574
890
  }
575
891
  ];
576
892
  }
577
893
 
578
894
  // src/configs/markdown.ts
579
- import * as parserPlain from "eslint-parser-plain";
580
895
  import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
896
+ import * as parserPlain2 from "eslint-parser-plain";
581
897
  async function markdown(options = {}) {
582
898
  const {
583
899
  componentExts = [],
584
900
  files = [GLOB_MARKDOWN],
585
901
  overrides = {}
586
902
  } = options;
587
- const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
588
- return [
589
- {
590
- name: "eslint:markdown:setup",
591
- plugins: {
592
- markdown: markdown2
593
- }
594
- },
595
- {
596
- files,
597
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
598
- name: "eslint:markdown:processor",
599
- processor: mergeProcessors([
600
- markdown2.processors.markdown,
601
- processorPassThrough
602
- ])
603
- },
604
- {
605
- files,
606
- languageOptions: {
607
- parser: parserPlain
608
- },
609
- name: "eslint:markdown:parser"
610
- },
611
- {
612
- files: [
613
- GLOB_MARKDOWN_CODE,
614
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
615
- ],
616
- languageOptions: {
617
- parserOptions: {
618
- ecmaFeatures: {
619
- impliedStrict: true
620
- }
621
- }
622
- },
623
- name: "eslint:markdown:disables",
624
- rules: {
625
- "import/newline-after-import": "off",
626
- "no-alert": "off",
627
- "no-console": "off",
628
- "no-labels": "off",
629
- "no-lone-blocks": "off",
630
- "no-restricted-syntax": "off",
631
- "no-undef": "off",
632
- "no-unused-expressions": "off",
633
- "no-unused-labels": "off",
634
- "no-unused-vars": "off",
635
- "node/prefer-global/process": "off",
636
- "style/comma-dangle": "off",
637
- "style/eol-last": "off",
638
- "ts/consistent-type-imports": "off",
639
- "ts/no-namespace": "off",
640
- "ts/no-redeclare": "off",
641
- "ts/no-require-imports": "off",
642
- "ts/no-unused-expressions": "off",
643
- "ts/no-unused-vars": "off",
644
- "ts/no-use-before-define": "off",
645
- "ts/no-var-requires": "off",
646
- "unicode-bom": "off",
647
- "unused-imports/no-unused-imports": "off",
648
- "unused-imports/no-unused-vars": "off",
649
- // Type aware rules
650
- ...{
651
- "ts/await-thenable": "off",
652
- "ts/dot-notation": "off",
653
- "ts/no-floating-promises": "off",
654
- "ts/no-for-in-array": "off",
655
- "ts/no-implied-eval": "off",
656
- "ts/no-misused-promises": "off",
657
- "ts/no-unnecessary-type-assertion": "off",
658
- "ts/no-unsafe-argument": "off",
659
- "ts/no-unsafe-assignment": "off",
660
- "ts/no-unsafe-call": "off",
661
- "ts/no-unsafe-member-access": "off",
662
- "ts/no-unsafe-return": "off",
663
- "ts/restrict-plus-operands": "off",
664
- "ts/restrict-template-expressions": "off",
665
- "ts/unbound-method": "off"
666
- },
667
- ...overrides
668
- }
669
- }
670
- ];
671
- }
672
-
673
- // src/configs/perfectionist.ts
674
- async function perfectionist() {
675
- return [
676
- {
677
- name: "eslint:perfectionist:setup",
678
- plugins: {
679
- perfectionist: default7
680
- }
681
- }
682
- ];
683
- }
684
-
685
- // src/configs/formatters.ts
686
- import * as parserPlain2 from "eslint-parser-plain";
687
-
688
- // src/configs/stylistic.ts
689
- var StylisticConfigDefaults = {
690
- indent: 4,
691
- jsx: true,
692
- lessOpinionated: false,
693
- quotes: "single",
694
- semi: false
695
- };
696
- async function stylistic(options = {}) {
697
- const {
698
- overrides = {},
699
- stylistic: stylistic2 = StylisticConfigDefaults
700
- } = options;
701
- const {
702
- indent,
703
- jsx: jsx2,
704
- lessOpinionated,
705
- quotes,
706
- semi
707
- } = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
708
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
709
- const config = pluginStylistic.configs.customize({
710
- flat: true,
711
- indent,
712
- jsx: jsx2,
713
- pluginName: "style",
714
- quotes,
715
- semi
716
- });
903
+ const markdown2 = await interopDefault(import("@eslint/markdown"));
717
904
  return [
718
905
  {
719
- name: "eslint:stylistic",
720
- plugins: {
721
- antfu: default2,
722
- style: pluginStylistic
723
- },
724
- rules: {
725
- ...config.rules,
726
- "antfu/consistent-list-newline": "off",
727
- ...lessOpinionated ? {
728
- curly: ["error", "all"]
729
- } : {
730
- "antfu/curly": "error",
731
- "antfu/if-newline": "error",
732
- "antfu/top-level-function": "error"
733
- },
734
- // 覆盖`stylistic`默认规则
735
- "style/brace-style": ["error", "stroustrup"],
736
- "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
737
- "style/multiline-ternary": ["error", "never"],
738
- ...overrides
739
- }
740
- }
741
- ];
742
- }
743
-
744
- // src/configs/formatters.ts
745
- async function formatters(options = {}, stylistic2 = {}) {
746
- const defaultIndent = 4;
747
- await ensurePackages([
748
- "eslint-plugin-format"
749
- ]);
750
- if (options === true) {
751
- options = {
752
- css: false,
753
- graphql: true,
754
- html: true,
755
- markdown: true
756
- };
757
- }
758
- const {
759
- indent,
760
- quotes,
761
- semi
762
- } = {
763
- ...StylisticConfigDefaults,
764
- ...stylistic2
765
- };
766
- const prettierOptions = Object.assign(
767
- {
768
- endOfLine: "lf",
769
- semi,
770
- singleQuote: quotes === "single",
771
- tabWidth: typeof indent === "number" ? indent : defaultIndent,
772
- trailingComma: "all",
773
- useTabs: indent === "tab"
774
- },
775
- options.prettierOptions || {}
776
- );
777
- const dprintOptions = Object.assign(
778
- {
779
- indentWidth: typeof indent === "number" ? indent : defaultIndent,
780
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
781
- useTabs: indent === "tab"
782
- },
783
- options.dprintOptions || {}
784
- );
785
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
786
- const configs2 = [
787
- {
788
- name: "eslint:formatters:setup",
906
+ name: "eslint/markdown/setup",
789
907
  plugins: {
790
- format: pluginFormat
791
- }
792
- }
793
- ];
794
- if (options.css) {
795
- configs2.push(
796
- {
797
- files: [GLOB_CSS, GLOB_POSTCSS],
798
- languageOptions: {
799
- parser: parserPlain2
800
- },
801
- name: "eslint:formatter:css",
802
- rules: {
803
- "format/prettier": [
804
- "error",
805
- {
806
- ...prettierOptions,
807
- parser: "css"
808
- }
809
- ]
810
- }
811
- },
812
- {
813
- files: [GLOB_SCSS],
814
- languageOptions: {
815
- parser: parserPlain2
816
- },
817
- name: "eslint:formatter:scss",
818
- rules: {
819
- "format/prettier": [
820
- "error",
821
- {
822
- ...prettierOptions,
823
- parser: "scss"
824
- }
825
- ]
826
- }
827
- },
828
- {
829
- files: [GLOB_LESS],
830
- languageOptions: {
831
- parser: parserPlain2
832
- },
833
- name: "eslint:formatter:less",
834
- rules: {
835
- "format/prettier": [
836
- "error",
837
- {
838
- ...prettierOptions,
839
- parser: "less"
840
- }
841
- ]
842
- }
843
- }
844
- );
845
- }
846
- if (options.html) {
847
- configs2.push({
848
- files: [GLOB_HTML],
849
- languageOptions: {
850
- parser: parserPlain2
851
- },
852
- name: "eslint:formatter:html",
853
- rules: {
854
- "format/prettier": [
855
- "error",
856
- {
857
- ...prettierOptions,
858
- parser: "html"
859
- }
860
- ]
908
+ markdown: markdown2
861
909
  }
862
- });
863
- }
864
- if (options.markdown) {
865
- const formater = options.markdown === true ? "prettier" : options.markdown;
866
- configs2.push({
867
- files: [GLOB_MARKDOWN],
910
+ },
911
+ {
912
+ files,
913
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
914
+ name: "eslint/markdown/processor",
915
+ processor: mergeProcessors([
916
+ markdown2.processors.markdown,
917
+ processorPassThrough
918
+ ])
919
+ },
920
+ {
921
+ files,
868
922
  languageOptions: {
869
923
  parser: parserPlain2
870
924
  },
871
- name: "eslint:formatter:markdown",
872
- rules: {
873
- [`format/${formater}`]: [
874
- "error",
875
- formater === "prettier" ? {
876
- printWidth: 200,
877
- ...prettierOptions,
878
- embeddedLanguageFormatting: "off",
879
- parser: "markdown"
880
- } : {
881
- ...dprintOptions,
882
- language: "markdown"
883
- }
884
- ]
885
- }
886
- });
887
- }
888
- if (options.graphql) {
889
- configs2.push({
890
- files: [GLOB_GRAPHQL],
925
+ name: "eslint/markdown/parser"
926
+ },
927
+ {
928
+ files: [
929
+ GLOB_MARKDOWN_CODE,
930
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
931
+ ],
891
932
  languageOptions: {
892
- parser: parserPlain2
933
+ parserOptions: {
934
+ ecmaFeatures: {
935
+ impliedStrict: true
936
+ }
937
+ }
893
938
  },
894
- name: "eslint:formatter:graphql",
939
+ name: "eslint/markdown/disables",
895
940
  rules: {
896
- "format/prettier": [
897
- "error",
898
- {
899
- ...prettierOptions,
900
- parser: "graphql"
901
- }
902
- ]
941
+ "import/newline-after-import": "off",
942
+ "no-alert": "off",
943
+ "no-console": "off",
944
+ "no-labels": "off",
945
+ "no-lone-blocks": "off",
946
+ "no-restricted-syntax": "off",
947
+ "no-undef": "off",
948
+ "no-unused-expressions": "off",
949
+ "no-unused-labels": "off",
950
+ "no-unused-vars": "off",
951
+ "node/prefer-global/process": "off",
952
+ "style/comma-dangle": "off",
953
+ "style/eol-last": "off",
954
+ "ts/consistent-type-imports": "off",
955
+ "ts/no-namespace": "off",
956
+ "ts/no-redeclare": "off",
957
+ "ts/no-require-imports": "off",
958
+ "ts/no-unused-expressions": "off",
959
+ "ts/no-unused-vars": "off",
960
+ "ts/no-use-before-define": "off",
961
+ "unicode-bom": "off",
962
+ "unused-imports/no-unused-imports": "off",
963
+ "unused-imports/no-unused-vars": "off",
964
+ // Type aware rules
965
+ ...{
966
+ "ts/await-thenable": "off",
967
+ "ts/dot-notation": "off",
968
+ "ts/no-floating-promises": "off",
969
+ "ts/no-for-in-array": "off",
970
+ "ts/no-implied-eval": "off",
971
+ "ts/no-misused-promises": "off",
972
+ "ts/no-unnecessary-type-assertion": "off",
973
+ "ts/no-unsafe-argument": "off",
974
+ "ts/no-unsafe-assignment": "off",
975
+ "ts/no-unsafe-call": "off",
976
+ "ts/no-unsafe-member-access": "off",
977
+ "ts/no-unsafe-return": "off",
978
+ "ts/restrict-plus-operands": "off",
979
+ "ts/restrict-template-expressions": "off",
980
+ "ts/unbound-method": "off"
981
+ },
982
+ ...overrides
903
983
  }
904
- });
905
- }
906
- return configs2;
984
+ }
985
+ ];
907
986
  }
908
987
 
909
988
  // src/configs/node.ts
910
989
  async function node() {
911
990
  return [
912
991
  {
913
- name: "eslint:node:rules",
992
+ name: "eslint/node/rules",
914
993
  plugins: {
915
994
  node: default4
916
995
  },
@@ -928,6 +1007,39 @@ async function node() {
928
1007
  ];
929
1008
  }
930
1009
 
1010
+ // src/configs/perfectionist.ts
1011
+ async function perfectionist() {
1012
+ return [
1013
+ {
1014
+ name: "eslint/perfectionist/setup",
1015
+ plugins: {
1016
+ perfectionist: default5
1017
+ },
1018
+ rules: {
1019
+ "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1020
+ "perfectionist/sort-imports": ["error", {
1021
+ groups: [
1022
+ "type",
1023
+ ["parent-type", "sibling-type", "index-type"],
1024
+ "builtin",
1025
+ "external",
1026
+ ["internal", "internal-type"],
1027
+ ["parent", "sibling", "index"],
1028
+ "side-effect",
1029
+ "object",
1030
+ "unknown"
1031
+ ],
1032
+ // newlinesBetween: 'ignore',
1033
+ order: "asc",
1034
+ type: "natural"
1035
+ }],
1036
+ "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1037
+ "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
1038
+ }
1039
+ }
1040
+ ];
1041
+ }
1042
+
931
1043
  // src/configs/react.ts
932
1044
  import { isPackageExists as isPackageExists2 } from "local-pkg";
933
1045
  var ReactRefreshAllowConstantExportPackages = [
@@ -966,7 +1078,7 @@ async function react(options = {}) {
966
1078
  const plugins = pluginReact.configs.all.plugins;
967
1079
  return [
968
1080
  {
969
- name: "eslint:react:setup",
1081
+ name: "eslint/react/setup",
970
1082
  plugins: {
971
1083
  "react": plugins["@eslint-react"],
972
1084
  "react-dom": plugins["@eslint-react/dom"],
@@ -987,7 +1099,7 @@ async function react(options = {}) {
987
1099
  ...isTypeAware ? { project: tsconfigPath } : {}
988
1100
  }
989
1101
  },
990
- name: "eslint:react:rules",
1102
+ name: "eslint/react/rules",
991
1103
  rules: {
992
1104
  // recommended rules from @eslint-react/dom
993
1105
  "react-dom/no-children-in-void-dom-elements": "warn",
@@ -1091,7 +1203,7 @@ async function sortPackageJson() {
1091
1203
  return [
1092
1204
  {
1093
1205
  files: ["**/package.json"],
1094
- name: "eslint:sort-package-json",
1206
+ name: "eslint/sort/package-json",
1095
1207
  rules: {
1096
1208
  "jsonc/sort-array-values": [
1097
1209
  "error",
@@ -1193,7 +1305,7 @@ function sortTsconfig() {
1193
1305
  return [
1194
1306
  {
1195
1307
  files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1196
- name: "eslint:sort-tsconfig",
1308
+ name: "eslint/sort/tsconfig",
1197
1309
  rules: {
1198
1310
  "jsonc/sort-keys": [
1199
1311
  "error",
@@ -1326,13 +1438,13 @@ async function test(options = {}) {
1326
1438
  pluginVitest,
1327
1439
  pluginNoOnlyTests
1328
1440
  ] = await Promise.all([
1329
- interopDefault(import("eslint-plugin-vitest")),
1441
+ interopDefault(import("@vitest/eslint-plugin")),
1330
1442
  // @ts-expect-error missing types
1331
1443
  interopDefault(import("eslint-plugin-no-only-tests"))
1332
1444
  ]);
1333
1445
  return [
1334
1446
  {
1335
- name: "eslint:test:setup",
1447
+ name: "eslint/test/setup",
1336
1448
  plugins: {
1337
1449
  test: {
1338
1450
  ...pluginVitest,
@@ -1346,7 +1458,7 @@ async function test(options = {}) {
1346
1458
  },
1347
1459
  {
1348
1460
  files,
1349
- name: "eslint:test:rules",
1461
+ name: "eslint/test/rules",
1350
1462
  rules: {
1351
1463
  "node/prefer-global/process": "off",
1352
1464
  "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
@@ -1362,6 +1474,65 @@ async function test(options = {}) {
1362
1474
  ];
1363
1475
  }
1364
1476
 
1477
+ // src/configs/toml.ts
1478
+ async function toml(options = {}) {
1479
+ const {
1480
+ files = [GLOB_TOML],
1481
+ overrides = {},
1482
+ stylistic: stylistic2 = true
1483
+ } = options;
1484
+ const {
1485
+ indent = 4
1486
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1487
+ const [
1488
+ pluginToml,
1489
+ parserToml
1490
+ ] = await Promise.all([
1491
+ interopDefault(import("eslint-plugin-toml")),
1492
+ interopDefault(import("toml-eslint-parser"))
1493
+ ]);
1494
+ return [
1495
+ {
1496
+ name: "eslint/toml/setup",
1497
+ plugins: {
1498
+ toml: pluginToml
1499
+ }
1500
+ },
1501
+ {
1502
+ files,
1503
+ languageOptions: {
1504
+ parser: parserToml
1505
+ },
1506
+ name: "eslint/toml/rules",
1507
+ rules: {
1508
+ "style/spaced-comment": "off",
1509
+ "toml/comma-style": "error",
1510
+ "toml/keys-order": "error",
1511
+ "toml/no-space-dots": "error",
1512
+ "toml/no-unreadable-number-separator": "error",
1513
+ "toml/precision-of-fractional-seconds": "error",
1514
+ "toml/precision-of-integer": "error",
1515
+ "toml/tables-order": "error",
1516
+ "toml/vue-custom-block/no-parsing-error": "error",
1517
+ ...stylistic2 ? {
1518
+ "toml/array-bracket-newline": "error",
1519
+ "toml/array-bracket-spacing": "error",
1520
+ "toml/array-element-newline": "error",
1521
+ "toml/indent": ["error", indent === "tab" ? 4 : indent],
1522
+ "toml/inline-table-curly-spacing": "error",
1523
+ "toml/key-spacing": "error",
1524
+ "toml/padding-line-between-pairs": "error",
1525
+ "toml/padding-line-between-tables": "error",
1526
+ "toml/quoted-keys": "error",
1527
+ "toml/spaced-comment": "error",
1528
+ "toml/table-bracket-spacing": "error"
1529
+ } : {},
1530
+ ...overrides
1531
+ }
1532
+ }
1533
+ ];
1534
+ }
1535
+
1365
1536
  // src/configs/typescript.ts
1366
1537
  import process2 from "node:process";
1367
1538
  async function typescript(options = {}) {
@@ -1375,6 +1546,9 @@ async function typescript(options = {}) {
1375
1546
  GLOB_SRC,
1376
1547
  ...componentExts.map((ext) => `**/*.${ext}`)
1377
1548
  ];
1549
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1550
+ `${GLOB_MARKDOWN}/**`
1551
+ ];
1378
1552
  const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1379
1553
  const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1380
1554
  const isTypeAware = !!tsconfigPath;
@@ -1427,28 +1601,28 @@ async function typescript(options = {}) {
1427
1601
  ...parserOptions
1428
1602
  }
1429
1603
  },
1430
- name: `eslint:typescript:${typeAware ? "type-aware-parser" : "parser"}`
1604
+ name: `eslint/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1431
1605
  };
1432
1606
  }
1433
1607
  return [
1434
1608
  {
1435
1609
  // Install the plugins without globs, so they can be configured separately.
1436
- name: "eslint:typescript:setup",
1610
+ name: "eslint/typescript/setup",
1437
1611
  plugins: {
1438
- antfu: default2,
1612
+ antfu: default3,
1439
1613
  ts: pluginTs
1440
1614
  }
1441
1615
  },
1442
1616
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
1443
1617
  ...isTypeAware ? [
1444
- makeParser(true, filesTypeAware),
1445
- makeParser(false, files, filesTypeAware)
1618
+ makeParser(false, files),
1619
+ makeParser(true, filesTypeAware, ignoresTypeAware)
1446
1620
  ] : [
1447
1621
  makeParser(false, files)
1448
1622
  ],
1449
1623
  {
1450
1624
  files,
1451
- name: "eslint:typescript:rules",
1625
+ name: "eslint/typescript/rules",
1452
1626
  rules: {
1453
1627
  ...renameRules(
1454
1628
  pluginTs.configs["eslint-recommended"].overrides[0].rules,
@@ -1459,7 +1633,6 @@ async function typescript(options = {}) {
1459
1633
  { "@typescript-eslint": "ts" }
1460
1634
  ),
1461
1635
  "no-dupe-class-members": "off",
1462
- "no-loss-of-precision": "off",
1463
1636
  "no-redeclare": "off",
1464
1637
  "no-use-before-define": "off",
1465
1638
  "no-useless-constructor": "off",
@@ -1477,7 +1650,6 @@ async function typescript(options = {}) {
1477
1650
  "ts/no-extraneous-class": "off",
1478
1651
  "ts/no-import-type-side-effects": "error",
1479
1652
  "ts/no-invalid-void-type": "off",
1480
- "ts/no-loss-of-precision": "error",
1481
1653
  "ts/no-non-null-assertion": "off",
1482
1654
  "ts/no-redeclare": "error",
1483
1655
  "ts/no-require-imports": "error",
@@ -1499,75 +1671,42 @@ async function typescript(options = {}) {
1499
1671
  },
1500
1672
  ...isTypeAware ? [{
1501
1673
  files: filesTypeAware,
1502
- name: "eslint:typescript:rules-type-aware",
1674
+ ignores: ignoresTypeAware,
1675
+ name: "eslint/typescript/rules-type-aware",
1503
1676
  rules: {
1504
1677
  ...typeAwareRules,
1505
1678
  ...overrides
1506
1679
  }
1507
- }] : [],
1508
- {
1509
- files: ["**/*.d.?([cm])ts"],
1510
- name: "eslint:typescript:disables:dts",
1511
- rules: {
1512
- "eslint-comments/no-unlimited-disable": "off",
1513
- "import/no-duplicates": "off",
1514
- "no-restricted-syntax": "off",
1515
- "unused-imports/no-unused-vars": "off"
1516
- }
1517
- },
1518
- {
1519
- files: ["**/*.{test,spec}.ts?(x)"],
1520
- name: "eslint:typescript:disables:test",
1521
- rules: {
1522
- "no-unused-expressions": "off"
1523
- }
1524
- },
1525
- {
1526
- files: ["**/*.js", "**/*.cjs"],
1527
- name: "eslint:typescript:disables:cjs",
1528
- rules: {
1529
- "ts/no-require-imports": "off",
1530
- "ts/no-var-requires": "off"
1531
- }
1532
- }
1680
+ }] : []
1533
1681
  ];
1534
1682
  }
1535
1683
 
1536
1684
  // src/configs/unicorn.ts
1537
- async function unicorn() {
1685
+ async function unicorn(options = {}) {
1538
1686
  return [
1539
1687
  {
1540
- name: "eslint:unicorn",
1688
+ name: "eslint/unicorn/rules",
1541
1689
  plugins: {
1542
- unicorn: default5
1690
+ unicorn: default6
1543
1691
  },
1544
1692
  rules: {
1545
- // Pass error message when throwing errors
1546
- "unicorn/error-message": "error",
1547
- // Uppercase regex escapes
1548
- "unicorn/escape-case": "error",
1549
- // Array.isArray instead of instanceof
1550
- "unicorn/no-instanceof-array": "error",
1551
- // Ban `new Array` as `Array` constructor's params are ambiguous
1552
- "unicorn/no-new-array": "error",
1553
- // Prevent deprecated `new Buffer()`
1554
- "unicorn/no-new-buffer": "error",
1555
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1556
- "unicorn/number-literal-case": "error",
1557
- // textContent instead of innerText
1558
- "unicorn/prefer-dom-node-text-content": "error",
1559
- // includes over indexOf when checking for existence
1560
- "unicorn/prefer-includes": "error",
1561
- // Prefer using the node: protocol
1562
- "unicorn/prefer-node-protocol": "error",
1563
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1564
- "unicorn/prefer-number-properties": "error",
1565
- // String methods startsWith/endsWith instead of more complicated stuff
1566
- "unicorn/prefer-string-starts-ends-with": "error",
1567
- // Enforce throwing type error when throwing error while checking typeof
1568
- "unicorn/prefer-type-error": "error",
1569
- // Use new when throwing error
1570
- "unicorn/throw-new-error": "error"
1693
+ ...options.allRecommended ? default6.configs["flat/recommended"].rules : {
1694
+ "unicorn/consistent-empty-array-spread": "error",
1695
+ "unicorn/error-message": "error",
1696
+ "unicorn/escape-case": "error",
1697
+ "unicorn/new-for-builtins": "error",
1698
+ "unicorn/no-instanceof-array": "error",
1699
+ "unicorn/no-new-array": "error",
1700
+ "unicorn/no-new-buffer": "error",
1701
+ "unicorn/number-literal-case": "error",
1702
+ "unicorn/prefer-dom-node-text-content": "error",
1703
+ "unicorn/prefer-includes": "error",
1704
+ "unicorn/prefer-node-protocol": "error",
1705
+ "unicorn/prefer-number-properties": "error",
1706
+ "unicorn/prefer-string-starts-ends-with": "error",
1707
+ "unicorn/prefer-type-error": "error",
1708
+ "unicorn/throw-new-error": "error"
1709
+ }
1571
1710
  }
1572
1711
  }
1573
1712
  ];
@@ -1590,7 +1729,7 @@ async function unocss(options = {}) {
1590
1729
  ]);
1591
1730
  return [
1592
1731
  {
1593
- name: "eslint:unocss",
1732
+ name: "eslint/unocss/rules",
1594
1733
  plugins: {
1595
1734
  unocss: pluginUnoCSS
1596
1735
  },
@@ -1655,7 +1794,7 @@ async function vue(options = {}) {
1655
1794
  watchEffect: "readonly"
1656
1795
  }
1657
1796
  },
1658
- name: "eslint:vue:setup",
1797
+ name: "eslint/vue/setup",
1659
1798
  plugins: {
1660
1799
  vue: pluginVue
1661
1800
  }
@@ -1673,7 +1812,7 @@ async function vue(options = {}) {
1673
1812
  sourceType: "module"
1674
1813
  }
1675
1814
  },
1676
- name: "eslint:vue:rules",
1815
+ name: "eslint/vue/rules",
1677
1816
  processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
1678
1817
  pluginVue.processors[".vue"],
1679
1818
  processorVueBlocks({
@@ -1802,7 +1941,7 @@ async function yaml(options = {}) {
1802
1941
  ]);
1803
1942
  return [
1804
1943
  {
1805
- name: "eslint:yaml:setup",
1944
+ name: "eslint/yaml/setup",
1806
1945
  plugins: {
1807
1946
  yaml: pluginYaml
1808
1947
  }
@@ -1812,7 +1951,7 @@ async function yaml(options = {}) {
1812
1951
  languageOptions: {
1813
1952
  parser: parserYaml
1814
1953
  },
1815
- name: "eslint:yaml:rules",
1954
+ name: "eslint/yaml/rules",
1816
1955
  rules: {
1817
1956
  "style/spaced-comment": "off",
1818
1957
  "yaml/block-mapping": "error",
@@ -1841,70 +1980,9 @@ async function yaml(options = {}) {
1841
1980
  ];
1842
1981
  }
1843
1982
 
1844
- // src/configs/toml.ts
1845
- async function toml(options = {}) {
1846
- const {
1847
- files = [GLOB_TOML],
1848
- overrides = {},
1849
- stylistic: stylistic2 = true
1850
- } = options;
1851
- const {
1852
- indent = 4
1853
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1854
- const [
1855
- pluginToml,
1856
- parserToml
1857
- ] = await Promise.all([
1858
- interopDefault(import("eslint-plugin-toml")),
1859
- interopDefault(import("toml-eslint-parser"))
1860
- ]);
1861
- return [
1862
- {
1863
- name: "eslint:toml:setup",
1864
- plugins: {
1865
- toml: pluginToml
1866
- }
1867
- },
1868
- {
1869
- files,
1870
- languageOptions: {
1871
- parser: parserToml
1872
- },
1873
- name: "eslint:toml:rules",
1874
- rules: {
1875
- "style/spaced-comment": "off",
1876
- "toml/comma-style": "error",
1877
- "toml/keys-order": "error",
1878
- "toml/no-space-dots": "error",
1879
- "toml/no-unreadable-number-separator": "error",
1880
- "toml/precision-of-fractional-seconds": "error",
1881
- "toml/precision-of-integer": "error",
1882
- "toml/tables-order": "error",
1883
- "toml/vue-custom-block/no-parsing-error": "error",
1884
- ...stylistic2 ? {
1885
- "toml/array-bracket-newline": "error",
1886
- "toml/array-bracket-spacing": "error",
1887
- "toml/array-element-newline": "error",
1888
- "toml/indent": ["error", indent === "tab" ? 4 : indent],
1889
- "toml/inline-table-curly-spacing": "error",
1890
- "toml/key-spacing": "error",
1891
- "toml/padding-line-between-pairs": "error",
1892
- "toml/padding-line-between-tables": "error",
1893
- "toml/quoted-keys": "error",
1894
- "toml/spaced-comment": "error",
1895
- "toml/table-bracket-spacing": "error"
1896
- } : {},
1897
- ...overrides
1898
- }
1899
- }
1900
- ];
1901
- }
1902
-
1903
1983
  // src/factory.ts
1904
1984
  var flatConfigProps = [
1905
1985
  "name",
1906
- "files",
1907
- "ignores",
1908
1986
  "languageOptions",
1909
1987
  "linterOptions",
1910
1988
  "processor",
@@ -1939,15 +2017,21 @@ function lincy(options = {}, ...userConfigs) {
1939
2017
  autoRenamePlugins = true,
1940
2018
  componentExts = [],
1941
2019
  gitignore: enableGitignore = true,
1942
- isInEditor = isInEditorEnv(),
1943
2020
  jsx: enableJsx = true,
1944
2021
  overrides = {},
1945
2022
  react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1946
2023
  regexp: enableRegexp = true,
1947
2024
  typescript: enableTypeScript = isPackageExists3("typescript"),
2025
+ unicorn: enableUnicorn = true,
1948
2026
  unocss: enableUnoCSS = false,
1949
2027
  vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1950
2028
  } = options;
2029
+ let isInEditor = options.isInEditor;
2030
+ if (isInEditor == null) {
2031
+ isInEditor = isInEditorEnv();
2032
+ if (isInEditor)
2033
+ console.log("[@lincy/eslint-config] Detected running in editor, some rules are disabled.");
2034
+ }
1951
2035
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1952
2036
  const tsconfigPath = typeof enableTypeScript !== "boolean" && "tsconfigPath" in enableTypeScript ? enableTypeScript.tsconfigPath : void 0;
1953
2037
  if (stylisticOptions) {
@@ -1958,9 +2042,15 @@ function lincy(options = {}, ...userConfigs) {
1958
2042
  const configs2 = [];
1959
2043
  if (enableGitignore) {
1960
2044
  if (typeof enableGitignore !== "boolean") {
1961
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2045
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2046
+ name: "eslint/gitignore",
2047
+ ...enableGitignore
2048
+ })]));
1962
2049
  } else {
1963
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
2050
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2051
+ name: "eslint/gitignore",
2052
+ strict: false
2053
+ })]));
1964
2054
  }
1965
2055
  }
1966
2056
  configs2.push(
@@ -1979,10 +2069,12 @@ function lincy(options = {}, ...userConfigs) {
1979
2069
  imports({
1980
2070
  stylistic: stylisticOptions
1981
2071
  }),
1982
- unicorn(),
1983
2072
  // Optional plugins (installed but not enabled by default)
1984
2073
  perfectionist()
1985
2074
  );
2075
+ if (enableUnicorn) {
2076
+ configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2077
+ }
1986
2078
  if (enableVue) {
1987
2079
  componentExts.push("vue");
1988
2080
  }
@@ -2075,6 +2167,12 @@ function lincy(options = {}, ...userConfigs) {
2075
2167
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2076
2168
  ));
2077
2169
  }
2170
+ configs2.push(
2171
+ disables()
2172
+ );
2173
+ if ("files" in options) {
2174
+ 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");
2175
+ }
2078
2176
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
2079
2177
  if (key in options) {
2080
2178
  acc[key] = options[key];
@@ -2118,23 +2216,28 @@ export {
2118
2216
  GLOB_SRC_EXT,
2119
2217
  GLOB_STYLE,
2120
2218
  GLOB_SVELTE,
2219
+ GLOB_SVG,
2121
2220
  GLOB_TESTS,
2122
2221
  GLOB_TOML,
2123
2222
  GLOB_TS,
2124
2223
  GLOB_TSX,
2125
2224
  GLOB_VUE,
2225
+ GLOB_XML,
2126
2226
  GLOB_YAML,
2127
2227
  StylisticConfigDefaults,
2128
2228
  combine,
2129
2229
  comments,
2130
2230
  src_default as default,
2131
2231
  defaultPluginRenaming,
2232
+ disables,
2132
2233
  ensurePackages,
2133
2234
  formatters,
2134
2235
  ignores,
2135
2236
  imports,
2136
2237
  interopDefault,
2137
2238
  isInEditorEnv,
2239
+ isInGitHooksOrLintStaged,
2240
+ isPackageInScope,
2138
2241
  javascript,
2139
2242
  jsdoc,
2140
2243
  jsonc,
@@ -2142,6 +2245,7 @@ export {
2142
2245
  lincy,
2143
2246
  markdown,
2144
2247
  node,
2248
+ parserPlain,
2145
2249
  perfectionist,
2146
2250
  react,
2147
2251
  regexp,