@lincy/eslint-config 5.0.0 → 5.1.1

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,15 +1,15 @@
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-community/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() {
@@ -17,7 +17,7 @@ async function comments() {
17
17
  {
18
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",
@@ -102,157 +102,550 @@ var GLOB_EXCLUDE = [
102
102
  "**/components.d.ts"
103
103
  ];
104
104
 
105
- // src/configs/ignores.ts
106
- async function ignores(options = {}) {
107
- const {
108
- ignores: ignores2 = []
109
- } = options;
105
+ // src/configs/disables.ts
106
+ async function disables() {
110
107
  return [
111
108
  {
112
- ignores: [
113
- ...GLOB_EXCLUDE,
114
- ...ignores2
115
- ],
116
- name: "eslint/ignores"
117
- }
118
- ];
119
- }
120
-
121
- // src/configs/imports.ts
122
- async function imports(options = {}) {
123
- const {
124
- stylistic: stylistic2 = true
125
- } = options;
126
- return [
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
+ },
127
116
  {
128
- name: "eslint/imports/rules",
129
- plugins: {
130
- antfu: default2,
131
- import: pluginImport
132
- },
117
+ files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
118
+ name: "eslint/disables/cli",
133
119
  rules: {
134
- "antfu/import-dedupe": "error",
135
- "antfu/no-import-dist": "error",
136
- "antfu/no-import-node-modules-by-path": "error",
137
- "import/first": "error",
138
- "import/no-duplicates": "error",
139
- "import/no-mutable-exports": "error",
140
- "import/no-named-default": "error",
141
- "import/no-self-import": "error",
142
- "import/no-webpack-loader-syntax": "error",
143
- "import/order": "error",
144
- ...stylistic2 ? {
145
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
146
- } : {}
120
+ "no-console": "off"
147
121
  }
148
122
  },
149
123
  {
150
124
  files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
151
- name: "eslint/imports/disables/bin",
125
+ name: "eslint/disables/bin",
152
126
  rules: {
153
127
  "antfu/no-import-dist": "off",
154
128
  "antfu/no-import-node-modules-by-path": "off"
155
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
+ }
156
154
  }
157
155
  ];
158
156
  }
159
157
 
160
- // src/configs/javascript.ts
161
- import globals from "globals";
162
- async function javascript(options = {}) {
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 = {}) {
163
262
  const {
164
- isInEditor = false,
165
- overrides = {}
263
+ overrides = {},
264
+ stylistic: stylistic2 = StylisticConfigDefaults
166
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
+ });
167
282
  return [
168
283
  {
169
- languageOptions: {
170
- ecmaVersion: 2022,
171
- globals: {
172
- ...globals.browser,
173
- ...globals.es2021,
174
- ...globals.node,
175
- document: "readonly",
176
- navigator: "readonly",
177
- window: "readonly"
178
- },
179
- parserOptions: {
180
- ecmaFeatures: {
181
- jsx: true
182
- },
183
- ecmaVersion: 2022,
184
- sourceType: "module"
185
- },
186
- sourceType: "module"
187
- },
188
- linterOptions: {
189
- reportUnusedDisableDirectives: true
190
- },
191
- name: "eslint/javascript/setup"
192
- },
193
- {
194
- name: "eslint/javascript/rules",
284
+ name: "eslint/stylistic/rules",
195
285
  plugins: {
196
- "antfu": default2,
197
- "unused-imports": default6
286
+ antfu: default3,
287
+ style: pluginStylistic
198
288
  },
199
289
  rules: {
200
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
201
- "array-callback-return": "error",
202
- "block-scoped-var": "error",
203
- "constructor-super": "error",
204
- "default-case-last": "error",
205
- "dot-notation": ["error", { allowKeywords: true }],
206
- "eqeqeq": ["error", "smart"],
207
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
208
- "no-alert": "error",
209
- "no-array-constructor": "error",
210
- "no-async-promise-executor": "error",
211
- "no-caller": "error",
212
- "no-case-declarations": "error",
213
- "no-class-assign": "error",
214
- "no-compare-neg-zero": "error",
215
- "no-cond-assign": ["error", "always"],
216
- // 'no-console': ['error', { allow: ['warn', 'error'] }],
217
- "no-console": "off",
218
- "no-const-assign": "error",
219
- "no-control-regex": "error",
220
- "no-debugger": "error",
221
- "no-delete-var": "error",
222
- "no-dupe-args": "error",
223
- "no-dupe-class-members": "error",
224
- "no-dupe-keys": "error",
225
- "no-duplicate-case": "error",
226
- "no-empty": ["error", { allowEmptyCatch: true }],
227
- "no-empty-character-class": "error",
228
- "no-empty-pattern": "error",
229
- "no-eval": "error",
230
- "no-ex-assign": "error",
231
- "no-extend-native": "error",
232
- "no-extra-bind": "error",
233
- "no-extra-boolean-cast": "error",
234
- "no-fallthrough": "error",
235
- "no-func-assign": "error",
236
- "no-global-assign": "error",
237
- "no-implied-eval": "error",
238
- "no-import-assign": "error",
239
- "no-invalid-regexp": "error",
240
- "no-irregular-whitespace": "error",
241
- "no-iterator": "error",
242
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
243
- "no-lone-blocks": "error",
244
- "no-loss-of-precision": "error",
245
- "no-misleading-character-class": "error",
246
- "no-multi-str": "error",
247
- "no-new": "error",
248
- "no-new-func": "error",
249
- "no-new-native-nonconstructor": "error",
250
- "no-new-wrappers": "error",
251
- "no-obj-calls": "error",
252
- "no-octal": "error",
253
- "no-octal-escape": "error",
254
- "no-proto": "error",
255
- "no-prototype-builtins": "error",
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
+
507
+ // src/configs/ignores.ts
508
+ async function ignores(options = {}) {
509
+ const {
510
+ ignores: ignores2 = []
511
+ } = options;
512
+ return [
513
+ {
514
+ ignores: [
515
+ ...GLOB_EXCLUDE,
516
+ ...ignores2
517
+ ],
518
+ name: "eslint/ignores"
519
+ }
520
+ ];
521
+ }
522
+
523
+ // src/configs/imports.ts
524
+ async function imports(options = {}) {
525
+ const {
526
+ stylistic: stylistic2 = true
527
+ } = options;
528
+ return [
529
+ {
530
+ name: "eslint/imports/rules",
531
+ plugins: {
532
+ antfu: default3,
533
+ import: pluginImport
534
+ },
535
+ rules: {
536
+ "antfu/import-dedupe": "error",
537
+ "antfu/no-import-dist": "error",
538
+ "antfu/no-import-node-modules-by-path": "error",
539
+ "import/first": "error",
540
+ "import/no-duplicates": "error",
541
+ "import/no-mutable-exports": "error",
542
+ "import/no-named-default": "error",
543
+ "import/no-self-import": "error",
544
+ "import/no-webpack-loader-syntax": "error",
545
+ ...stylistic2 ? {
546
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
547
+ } : {}
548
+ }
549
+ }
550
+ ];
551
+ }
552
+
553
+ // src/configs/javascript.ts
554
+ import globals from "globals";
555
+ async function javascript(options = {}) {
556
+ const {
557
+ isInEditor = false,
558
+ overrides = {}
559
+ } = options;
560
+ return [
561
+ {
562
+ languageOptions: {
563
+ ecmaVersion: 2022,
564
+ globals: {
565
+ ...globals.browser,
566
+ ...globals.es2021,
567
+ ...globals.node,
568
+ document: "readonly",
569
+ navigator: "readonly",
570
+ window: "readonly"
571
+ },
572
+ parserOptions: {
573
+ ecmaFeatures: {
574
+ jsx: true
575
+ },
576
+ ecmaVersion: 2022,
577
+ sourceType: "module"
578
+ },
579
+ sourceType: "module"
580
+ },
581
+ linterOptions: {
582
+ reportUnusedDisableDirectives: true
583
+ },
584
+ name: "eslint/javascript/setup"
585
+ },
586
+ {
587
+ name: "eslint/javascript/rules",
588
+ plugins: {
589
+ "antfu": default3,
590
+ "unused-imports": default7
591
+ },
592
+ rules: {
593
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
594
+ "array-callback-return": "error",
595
+ "block-scoped-var": "error",
596
+ "constructor-super": "error",
597
+ "default-case-last": "error",
598
+ "dot-notation": ["error", { allowKeywords: true }],
599
+ "eqeqeq": ["error", "smart"],
600
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
601
+ "no-alert": "error",
602
+ "no-array-constructor": "error",
603
+ "no-async-promise-executor": "error",
604
+ "no-caller": "error",
605
+ "no-case-declarations": "error",
606
+ "no-class-assign": "error",
607
+ "no-compare-neg-zero": "error",
608
+ "no-cond-assign": ["error", "always"],
609
+ // 'no-console': ['error', { allow: ['warn', 'error'] }],
610
+ "no-console": "off",
611
+ "no-const-assign": "error",
612
+ "no-control-regex": "error",
613
+ "no-debugger": "error",
614
+ "no-delete-var": "error",
615
+ "no-dupe-args": "error",
616
+ "no-dupe-class-members": "error",
617
+ "no-dupe-keys": "error",
618
+ "no-duplicate-case": "error",
619
+ "no-empty": ["error", { allowEmptyCatch: true }],
620
+ "no-empty-character-class": "error",
621
+ "no-empty-pattern": "error",
622
+ "no-eval": "error",
623
+ "no-ex-assign": "error",
624
+ "no-extend-native": "error",
625
+ "no-extra-bind": "error",
626
+ "no-extra-boolean-cast": "error",
627
+ "no-fallthrough": "error",
628
+ "no-func-assign": "error",
629
+ "no-global-assign": "error",
630
+ "no-implied-eval": "error",
631
+ "no-import-assign": "error",
632
+ "no-invalid-regexp": "error",
633
+ "no-irregular-whitespace": "error",
634
+ "no-iterator": "error",
635
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
636
+ "no-lone-blocks": "error",
637
+ "no-loss-of-precision": "error",
638
+ "no-misleading-character-class": "error",
639
+ "no-multi-str": "error",
640
+ "no-new": "error",
641
+ "no-new-func": "error",
642
+ "no-new-native-nonconstructor": "error",
643
+ "no-new-wrappers": "error",
644
+ "no-obj-calls": "error",
645
+ "no-octal": "error",
646
+ "no-octal-escape": "error",
647
+ "no-proto": "error",
648
+ "no-prototype-builtins": "error",
256
649
  "no-redeclare": ["error", { builtinGlobals: false }],
257
650
  "no-regex-spaces": "error",
258
651
  "no-restricted-globals": [
@@ -340,16 +733,6 @@ async function javascript(options = {}) {
340
733
  "prefer-rest-params": "error",
341
734
  "prefer-spread": "error",
342
735
  "prefer-template": "error",
343
- "sort-imports": [
344
- "error",
345
- {
346
- allowSeparatedGroups: false,
347
- ignoreCase: false,
348
- ignoreDeclarationSort: true,
349
- ignoreMemberSort: false,
350
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
351
- }
352
- ],
353
736
  "symbol-description": "error",
354
737
  "unicode-bom": ["error", "never"],
355
738
  "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
@@ -369,92 +752,10 @@ async function javascript(options = {}) {
369
752
  "yoda": ["error", "never"],
370
753
  ...overrides
371
754
  }
372
- },
373
- {
374
- files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
375
- name: "eslint/scripts/disables",
376
- rules: {
377
- "no-console": "off"
378
- }
379
755
  }
380
756
  ];
381
757
  }
382
758
 
383
- // src/utils.ts
384
- import process from "node:process";
385
- import { fileURLToPath } from "node:url";
386
- import { isPackageExists } from "local-pkg";
387
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
388
- var isCwdInScope = isPackageExists("@antfu/eslint-config");
389
- async function combine(...configs2) {
390
- const resolved = await Promise.all(configs2);
391
- return resolved.flat();
392
- }
393
- function renameRules(rules, map) {
394
- return Object.fromEntries(
395
- Object.entries(rules).map(([key, value]) => {
396
- for (const [from, to] of Object.entries(map)) {
397
- if (key.startsWith(`${from}/`)) {
398
- return [to + key.slice(from.length), value];
399
- }
400
- }
401
- return [key, value];
402
- })
403
- );
404
- }
405
- function renamePluginInConfigs(configs2, map) {
406
- return configs2.map((i) => {
407
- const clone = { ...i };
408
- if (clone.rules) {
409
- clone.rules = renameRules(clone.rules, map);
410
- }
411
- if (clone.plugins) {
412
- clone.plugins = Object.fromEntries(
413
- Object.entries(clone.plugins).map(([key, value]) => {
414
- if (key in map) {
415
- return [map[key], value];
416
- }
417
- return [key, value];
418
- })
419
- );
420
- }
421
- return clone;
422
- });
423
- }
424
- function toArray(value) {
425
- return Array.isArray(value) ? value : [value];
426
- }
427
- async function interopDefault(m) {
428
- const resolved = await m;
429
- return resolved.default || resolved;
430
- }
431
- function isPackageInScope(name) {
432
- return isPackageExists(name, { paths: [scopeUrl] });
433
- }
434
- async function ensurePackages(packages) {
435
- if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
436
- return;
437
- const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
438
- if (nonExistingPackages.length === 0)
439
- return;
440
- const p = await import("@clack/prompts");
441
- const result = await p.confirm({
442
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
443
- });
444
- if (result)
445
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
446
- }
447
- function isInEditorEnv() {
448
- if (process.env.CI)
449
- return false;
450
- if (isInGitHooksOrLintStaged())
451
- return false;
452
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
453
- }
454
- function isInGitHooksOrLintStaged() {
455
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
456
- }
457
-
458
759
  // src/configs/jsdoc.ts
459
760
  async function jsdoc(options = {}) {
460
761
  const {
@@ -530,417 +831,148 @@ async function jsonc(options = {}) {
530
831
  "jsonc/no-multi-str": "error",
531
832
  "jsonc/no-nan": "error",
532
833
  "jsonc/no-number-props": "error",
533
- "jsonc/no-numeric-separators": "error",
534
- "jsonc/no-octal": "error",
535
- "jsonc/no-octal-escape": "error",
536
- "jsonc/no-octal-numeric-literals": "error",
537
- "jsonc/no-parenthesized": "error",
538
- "jsonc/no-plus-sign": "error",
539
- "jsonc/no-regexp-literals": "error",
540
- "jsonc/no-sparse-arrays": "error",
541
- "jsonc/no-template-literals": "error",
542
- "jsonc/no-undefined-value": "error",
543
- "jsonc/no-unicode-codepoint-escapes": "error",
544
- "jsonc/no-useless-escape": "error",
545
- "jsonc/space-unary-ops": "error",
546
- "jsonc/valid-json-number": "error",
547
- "jsonc/vue-custom-block/no-parsing-error": "error",
548
- ...stylistic2 ? {
549
- "jsonc/array-bracket-spacing": ["error", "never"],
550
- "jsonc/comma-dangle": ["error", "never"],
551
- "jsonc/comma-style": ["error", "last"],
552
- "jsonc/indent": ["error", 2],
553
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
554
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
555
- "jsonc/object-curly-spacing": ["error", "always"],
556
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
557
- "jsonc/quote-props": "error",
558
- "jsonc/quotes": "error"
559
- } : {},
560
- ...overrides
561
- }
562
- }
563
- ];
564
- }
565
-
566
- // src/configs/jsx.ts
567
- async function jsx() {
568
- return [
569
- {
570
- files: [GLOB_JSX, GLOB_TSX],
571
- languageOptions: {
572
- parserOptions: {
573
- ecmaFeatures: {
574
- jsx: true
575
- }
576
- }
577
- },
578
- name: "eslint/jsx/setup"
579
- }
580
- ];
581
- }
582
-
583
- // src/configs/markdown.ts
584
- import * as parserPlain from "eslint-parser-plain";
585
- import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
586
- async function markdown(options = {}) {
587
- const {
588
- componentExts = [],
589
- files = [GLOB_MARKDOWN],
590
- overrides = {}
591
- } = options;
592
- const markdown2 = await interopDefault(import("eslint-plugin-markdown"));
593
- return [
594
- {
595
- name: "eslint/markdown/setup",
596
- plugins: {
597
- markdown: markdown2
598
- }
599
- },
600
- {
601
- files,
602
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
603
- name: "eslint/markdown/processor",
604
- processor: mergeProcessors([
605
- markdown2.processors.markdown,
606
- processorPassThrough
607
- ])
608
- },
609
- {
610
- files,
611
- languageOptions: {
612
- parser: parserPlain
613
- },
614
- name: "eslint/markdown/parser"
615
- },
616
- {
617
- files: [
618
- GLOB_MARKDOWN_CODE,
619
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
620
- ],
621
- languageOptions: {
622
- parserOptions: {
623
- ecmaFeatures: {
624
- impliedStrict: true
625
- }
626
- }
627
- },
628
- name: "eslint/markdown/disables",
629
- rules: {
630
- "import/newline-after-import": "off",
631
- "no-alert": "off",
632
- "no-console": "off",
633
- "no-labels": "off",
634
- "no-lone-blocks": "off",
635
- "no-restricted-syntax": "off",
636
- "no-undef": "off",
637
- "no-unused-expressions": "off",
638
- "no-unused-labels": "off",
639
- "no-unused-vars": "off",
640
- "node/prefer-global/process": "off",
641
- "style/comma-dangle": "off",
642
- "style/eol-last": "off",
643
- "ts/consistent-type-imports": "off",
644
- "ts/no-namespace": "off",
645
- "ts/no-redeclare": "off",
646
- "ts/no-require-imports": "off",
647
- "ts/no-unused-expressions": "off",
648
- "ts/no-unused-vars": "off",
649
- "ts/no-use-before-define": "off",
650
- "ts/no-var-requires": "off",
651
- "unicode-bom": "off",
652
- "unused-imports/no-unused-imports": "off",
653
- "unused-imports/no-unused-vars": "off",
654
- // Type aware rules
655
- ...{
656
- "ts/await-thenable": "off",
657
- "ts/dot-notation": "off",
658
- "ts/no-floating-promises": "off",
659
- "ts/no-for-in-array": "off",
660
- "ts/no-implied-eval": "off",
661
- "ts/no-misused-promises": "off",
662
- "ts/no-unnecessary-type-assertion": "off",
663
- "ts/no-unsafe-argument": "off",
664
- "ts/no-unsafe-assignment": "off",
665
- "ts/no-unsafe-call": "off",
666
- "ts/no-unsafe-member-access": "off",
667
- "ts/no-unsafe-return": "off",
668
- "ts/restrict-plus-operands": "off",
669
- "ts/restrict-template-expressions": "off",
670
- "ts/unbound-method": "off"
671
- },
834
+ "jsonc/no-numeric-separators": "error",
835
+ "jsonc/no-octal": "error",
836
+ "jsonc/no-octal-escape": "error",
837
+ "jsonc/no-octal-numeric-literals": "error",
838
+ "jsonc/no-parenthesized": "error",
839
+ "jsonc/no-plus-sign": "error",
840
+ "jsonc/no-regexp-literals": "error",
841
+ "jsonc/no-sparse-arrays": "error",
842
+ "jsonc/no-template-literals": "error",
843
+ "jsonc/no-undefined-value": "error",
844
+ "jsonc/no-unicode-codepoint-escapes": "error",
845
+ "jsonc/no-useless-escape": "error",
846
+ "jsonc/space-unary-ops": "error",
847
+ "jsonc/valid-json-number": "error",
848
+ "jsonc/vue-custom-block/no-parsing-error": "error",
849
+ ...stylistic2 ? {
850
+ "jsonc/array-bracket-spacing": ["error", "never"],
851
+ "jsonc/comma-dangle": ["error", "never"],
852
+ "jsonc/comma-style": ["error", "last"],
853
+ "jsonc/indent": ["error", 2],
854
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
855
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
856
+ "jsonc/object-curly-spacing": ["error", "always"],
857
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
858
+ "jsonc/quote-props": "error",
859
+ "jsonc/quotes": "error"
860
+ } : {},
672
861
  ...overrides
673
862
  }
674
863
  }
675
864
  ];
676
865
  }
677
866
 
678
- // src/configs/perfectionist.ts
679
- async function perfectionist() {
867
+ // src/configs/jsx.ts
868
+ async function jsx() {
680
869
  return [
681
870
  {
682
- name: "eslint/perfectionist/setup",
683
- plugins: {
684
- perfectionist: default7
685
- }
871
+ files: [GLOB_JSX, GLOB_TSX],
872
+ languageOptions: {
873
+ parserOptions: {
874
+ ecmaFeatures: {
875
+ jsx: true
876
+ }
877
+ }
878
+ },
879
+ name: "eslint/jsx/setup"
686
880
  }
687
881
  ];
688
882
  }
689
883
 
690
- // src/configs/formatters.ts
884
+ // src/configs/markdown.ts
885
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
691
886
  import * as parserPlain2 from "eslint-parser-plain";
692
-
693
- // src/configs/stylistic.ts
694
- var StylisticConfigDefaults = {
695
- indent: 4,
696
- jsx: true,
697
- lessOpinionated: false,
698
- quotes: "single",
699
- semi: false
700
- };
701
- async function stylistic(options = {}) {
887
+ async function markdown(options = {}) {
702
888
  const {
703
- overrides = {},
704
- stylistic: stylistic2 = StylisticConfigDefaults
889
+ componentExts = [],
890
+ files = [GLOB_MARKDOWN],
891
+ overrides = {}
705
892
  } = options;
706
- const {
707
- indent,
708
- jsx: jsx2,
709
- lessOpinionated,
710
- quotes,
711
- semi
712
- } = typeof stylistic2 === "boolean" ? StylisticConfigDefaults : { ...StylisticConfigDefaults, ...stylistic2 };
713
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
714
- const config = pluginStylistic.configs.customize({
715
- flat: true,
716
- indent,
717
- jsx: jsx2,
718
- pluginName: "style",
719
- quotes,
720
- semi
721
- });
893
+ const markdown2 = await interopDefault(import("@eslint/markdown"));
722
894
  return [
723
895
  {
724
- name: "eslint/stylistic/rules",
725
- plugins: {
726
- antfu: default2,
727
- style: pluginStylistic
728
- },
729
- rules: {
730
- ...config.rules,
731
- "antfu/consistent-list-newline": "off",
732
- ...lessOpinionated ? {
733
- curly: ["error", "all"]
734
- } : {
735
- "antfu/curly": "error",
736
- "antfu/if-newline": "error",
737
- "antfu/top-level-function": "error"
738
- },
739
- // 覆盖`stylistic`默认规则
740
- "style/brace-style": ["error", "stroustrup"],
741
- "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
742
- "style/multiline-ternary": ["error", "never"],
743
- ...overrides
744
- }
745
- }
746
- ];
747
- }
748
-
749
- // src/configs/formatters.ts
750
- async function formatters(options = {}, stylistic2 = {}) {
751
- const defaultIndent = 4;
752
- if (options === true) {
753
- const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
754
- options = {
755
- css: false,
756
- graphql: true,
757
- html: true,
758
- markdown: true,
759
- svg: isPrettierPluginXmlInScope,
760
- xml: isPrettierPluginXmlInScope
761
- };
762
- }
763
- await ensurePackages([
764
- "eslint-plugin-format",
765
- options.xml || options.svg ? "@prettier/plugin-xml" : void 0
766
- ]);
767
- const {
768
- indent,
769
- quotes,
770
- semi
771
- } = {
772
- ...StylisticConfigDefaults,
773
- ...stylistic2
774
- };
775
- const prettierOptions = Object.assign(
776
- {
777
- endOfLine: "lf",
778
- printWidth: 200,
779
- semi,
780
- singleQuote: quotes === "single",
781
- tabWidth: typeof indent === "number" ? indent : defaultIndent,
782
- trailingComma: "all",
783
- useTabs: indent === "tab"
784
- },
785
- options.prettierOptions || {}
786
- );
787
- const prettierXmlOptions = {
788
- xmlQuoteAttributes: "double",
789
- xmlSelfClosingSpace: true,
790
- xmlSortAttributesByKey: false,
791
- xmlWhitespaceSensitivity: "ignore"
792
- };
793
- const dprintOptions = Object.assign(
794
- {
795
- indentWidth: typeof indent === "number" ? indent : defaultIndent,
796
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
797
- useTabs: indent === "tab"
798
- },
799
- options.dprintOptions || {}
800
- );
801
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
802
- const configs2 = [
803
- {
804
- name: "eslint/formatters/setup",
896
+ name: "eslint/markdown/setup",
805
897
  plugins: {
806
- format: pluginFormat
807
- }
808
- }
809
- ];
810
- if (options.css) {
811
- configs2.push(
812
- {
813
- files: [GLOB_CSS, GLOB_POSTCSS],
814
- languageOptions: {
815
- parser: parserPlain2
816
- },
817
- name: "eslint/formatters/css",
818
- rules: {
819
- "format/prettier": [
820
- "error",
821
- {
822
- ...prettierOptions,
823
- parser: "css"
824
- }
825
- ]
826
- }
827
- },
828
- {
829
- files: [GLOB_SCSS],
830
- languageOptions: {
831
- parser: parserPlain2
832
- },
833
- name: "eslint/formatters/scss",
834
- rules: {
835
- "format/prettier": [
836
- "error",
837
- {
838
- ...prettierOptions,
839
- parser: "scss"
840
- }
841
- ]
842
- }
843
- },
844
- {
845
- files: [GLOB_LESS],
846
- languageOptions: {
847
- parser: parserPlain2
848
- },
849
- name: "eslint/formatters/less",
850
- rules: {
851
- "format/prettier": [
852
- "error",
853
- {
854
- ...prettierOptions,
855
- parser: "less"
856
- }
857
- ]
858
- }
859
- }
860
- );
861
- }
862
- if (options.html) {
863
- configs2.push({
864
- files: [GLOB_HTML],
865
- languageOptions: {
866
- parser: parserPlain2
867
- },
868
- name: "eslint/formatters/html",
869
- rules: {
870
- "format/prettier": [
871
- "error",
872
- {
873
- ...prettierOptions,
874
- parser: "html"
875
- }
876
- ]
877
- }
878
- });
879
- }
880
- if (options.svg) {
881
- configs2.push({
882
- files: [GLOB_SVG],
883
- languageOptions: {
884
- parser: parserPlain2
885
- },
886
- name: "eslint/formatters/svg",
887
- rules: {
888
- "format/prettier": [
889
- "error",
890
- {
891
- ...prettierXmlOptions,
892
- ...prettierOptions,
893
- parser: "xml",
894
- plugins: [
895
- "@prettier/plugin-xml"
896
- ]
897
- }
898
- ]
899
- }
900
- });
901
- }
902
- if (options.markdown) {
903
- const formater = options.markdown === true ? "prettier" : options.markdown;
904
- configs2.push({
905
- files: [GLOB_MARKDOWN],
898
+ markdown: markdown2
899
+ }
900
+ },
901
+ {
902
+ files,
903
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
904
+ name: "eslint/markdown/processor",
905
+ processor: mergeProcessors([
906
+ markdown2.processors.markdown,
907
+ processorPassThrough
908
+ ])
909
+ },
910
+ {
911
+ files,
906
912
  languageOptions: {
907
913
  parser: parserPlain2
908
914
  },
909
- name: "eslint/formatters/markdown",
910
- rules: {
911
- [`format/${formater}`]: [
912
- "error",
913
- formater === "prettier" ? {
914
- ...prettierOptions,
915
- embeddedLanguageFormatting: "off",
916
- parser: "markdown"
917
- } : {
918
- ...dprintOptions,
919
- language: "markdown"
920
- }
921
- ]
922
- }
923
- });
924
- }
925
- if (options.graphql) {
926
- configs2.push({
927
- files: [GLOB_GRAPHQL],
915
+ name: "eslint/markdown/parser"
916
+ },
917
+ {
918
+ files: [
919
+ GLOB_MARKDOWN_CODE,
920
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
921
+ ],
928
922
  languageOptions: {
929
- parser: parserPlain2
923
+ parserOptions: {
924
+ ecmaFeatures: {
925
+ impliedStrict: true
926
+ }
927
+ }
930
928
  },
931
- name: "eslint/formatters/graphql",
929
+ name: "eslint/markdown/disables",
932
930
  rules: {
933
- "format/prettier": [
934
- "error",
935
- {
936
- ...prettierOptions,
937
- parser: "graphql"
938
- }
939
- ]
931
+ "import/newline-after-import": "off",
932
+ "no-alert": "off",
933
+ "no-console": "off",
934
+ "no-labels": "off",
935
+ "no-lone-blocks": "off",
936
+ "no-restricted-syntax": "off",
937
+ "no-undef": "off",
938
+ "no-unused-expressions": "off",
939
+ "no-unused-labels": "off",
940
+ "no-unused-vars": "off",
941
+ "node/prefer-global/process": "off",
942
+ "style/comma-dangle": "off",
943
+ "style/eol-last": "off",
944
+ "ts/consistent-type-imports": "off",
945
+ "ts/no-namespace": "off",
946
+ "ts/no-redeclare": "off",
947
+ "ts/no-require-imports": "off",
948
+ "ts/no-unused-expressions": "off",
949
+ "ts/no-unused-vars": "off",
950
+ "ts/no-use-before-define": "off",
951
+ "unicode-bom": "off",
952
+ "unused-imports/no-unused-imports": "off",
953
+ "unused-imports/no-unused-vars": "off",
954
+ // Type aware rules
955
+ ...{
956
+ "ts/await-thenable": "off",
957
+ "ts/dot-notation": "off",
958
+ "ts/no-floating-promises": "off",
959
+ "ts/no-for-in-array": "off",
960
+ "ts/no-implied-eval": "off",
961
+ "ts/no-misused-promises": "off",
962
+ "ts/no-unnecessary-type-assertion": "off",
963
+ "ts/no-unsafe-argument": "off",
964
+ "ts/no-unsafe-assignment": "off",
965
+ "ts/no-unsafe-call": "off",
966
+ "ts/no-unsafe-member-access": "off",
967
+ "ts/no-unsafe-return": "off",
968
+ "ts/restrict-plus-operands": "off",
969
+ "ts/restrict-template-expressions": "off",
970
+ "ts/unbound-method": "off"
971
+ },
972
+ ...overrides
940
973
  }
941
- });
942
- }
943
- return configs2;
974
+ }
975
+ ];
944
976
  }
945
977
 
946
978
  // src/configs/node.ts
@@ -965,6 +997,39 @@ async function node() {
965
997
  ];
966
998
  }
967
999
 
1000
+ // src/configs/perfectionist.ts
1001
+ async function perfectionist() {
1002
+ return [
1003
+ {
1004
+ name: "eslint/perfectionist/setup",
1005
+ plugins: {
1006
+ perfectionist: default5
1007
+ },
1008
+ rules: {
1009
+ "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1010
+ "perfectionist/sort-imports": ["error", {
1011
+ groups: [
1012
+ "type",
1013
+ ["parent-type", "sibling-type", "index-type"],
1014
+ "builtin",
1015
+ "external",
1016
+ ["internal", "internal-type"],
1017
+ ["parent", "sibling", "index"],
1018
+ "side-effect",
1019
+ "object",
1020
+ "unknown"
1021
+ ],
1022
+ // newlinesBetween: 'ignore',
1023
+ order: "asc",
1024
+ type: "natural"
1025
+ }],
1026
+ "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1027
+ "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
1028
+ }
1029
+ }
1030
+ ];
1031
+ }
1032
+
968
1033
  // src/configs/react.ts
969
1034
  import { isPackageExists as isPackageExists2 } from "local-pkg";
970
1035
  var ReactRefreshAllowConstantExportPackages = [
@@ -1399,6 +1464,65 @@ async function test(options = {}) {
1399
1464
  ];
1400
1465
  }
1401
1466
 
1467
+ // src/configs/toml.ts
1468
+ async function toml(options = {}) {
1469
+ const {
1470
+ files = [GLOB_TOML],
1471
+ overrides = {},
1472
+ stylistic: stylistic2 = true
1473
+ } = options;
1474
+ const {
1475
+ indent = 4
1476
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1477
+ const [
1478
+ pluginToml,
1479
+ parserToml
1480
+ ] = await Promise.all([
1481
+ interopDefault(import("eslint-plugin-toml")),
1482
+ interopDefault(import("toml-eslint-parser"))
1483
+ ]);
1484
+ return [
1485
+ {
1486
+ name: "eslint/toml/setup",
1487
+ plugins: {
1488
+ toml: pluginToml
1489
+ }
1490
+ },
1491
+ {
1492
+ files,
1493
+ languageOptions: {
1494
+ parser: parserToml
1495
+ },
1496
+ name: "eslint/toml/rules",
1497
+ rules: {
1498
+ "style/spaced-comment": "off",
1499
+ "toml/comma-style": "error",
1500
+ "toml/keys-order": "error",
1501
+ "toml/no-space-dots": "error",
1502
+ "toml/no-unreadable-number-separator": "error",
1503
+ "toml/precision-of-fractional-seconds": "error",
1504
+ "toml/precision-of-integer": "error",
1505
+ "toml/tables-order": "error",
1506
+ "toml/vue-custom-block/no-parsing-error": "error",
1507
+ ...stylistic2 ? {
1508
+ "toml/array-bracket-newline": "error",
1509
+ "toml/array-bracket-spacing": "error",
1510
+ "toml/array-element-newline": "error",
1511
+ "toml/indent": ["error", indent === "tab" ? 4 : indent],
1512
+ "toml/inline-table-curly-spacing": "error",
1513
+ "toml/key-spacing": "error",
1514
+ "toml/padding-line-between-pairs": "error",
1515
+ "toml/padding-line-between-tables": "error",
1516
+ "toml/quoted-keys": "error",
1517
+ "toml/spaced-comment": "error",
1518
+ "toml/table-bracket-spacing": "error"
1519
+ } : {},
1520
+ ...overrides
1521
+ }
1522
+ }
1523
+ ];
1524
+ }
1525
+
1402
1526
  // src/configs/typescript.ts
1403
1527
  import process2 from "node:process";
1404
1528
  async function typescript(options = {}) {
@@ -1475,7 +1599,7 @@ async function typescript(options = {}) {
1475
1599
  // Install the plugins without globs, so they can be configured separately.
1476
1600
  name: "eslint/typescript/setup",
1477
1601
  plugins: {
1478
- antfu: default2,
1602
+ antfu: default3,
1479
1603
  ts: pluginTs
1480
1604
  }
1481
1605
  },
@@ -1499,7 +1623,6 @@ async function typescript(options = {}) {
1499
1623
  { "@typescript-eslint": "ts" }
1500
1624
  ),
1501
1625
  "no-dupe-class-members": "off",
1502
- "no-loss-of-precision": "off",
1503
1626
  "no-redeclare": "off",
1504
1627
  "no-use-before-define": "off",
1505
1628
  "no-useless-constructor": "off",
@@ -1517,7 +1640,6 @@ async function typescript(options = {}) {
1517
1640
  "ts/no-extraneous-class": "off",
1518
1641
  "ts/no-import-type-side-effects": "error",
1519
1642
  "ts/no-invalid-void-type": "off",
1520
- "ts/no-loss-of-precision": "error",
1521
1643
  "ts/no-non-null-assertion": "off",
1522
1644
  "ts/no-redeclare": "error",
1523
1645
  "ts/no-require-imports": "error",
@@ -1545,32 +1667,7 @@ async function typescript(options = {}) {
1545
1667
  ...typeAwareRules,
1546
1668
  ...overrides
1547
1669
  }
1548
- }] : [],
1549
- {
1550
- files: ["**/*.d.?([cm])ts"],
1551
- name: "eslint/typescript/disables/dts",
1552
- rules: {
1553
- "eslint-comments/no-unlimited-disable": "off",
1554
- "import/no-duplicates": "off",
1555
- "no-restricted-syntax": "off",
1556
- "unused-imports/no-unused-vars": "off"
1557
- }
1558
- },
1559
- {
1560
- files: ["**/*.{test,spec}.ts?(x)"],
1561
- name: "eslint/typescript/disables/test",
1562
- rules: {
1563
- "no-unused-expressions": "off"
1564
- }
1565
- },
1566
- {
1567
- files: ["**/*.js", "**/*.cjs"],
1568
- name: "eslint/typescript/disables/cjs",
1569
- rules: {
1570
- "ts/no-require-imports": "off",
1571
- "ts/no-var-requires": "off"
1572
- }
1573
- }
1670
+ }] : []
1574
1671
  ];
1575
1672
  }
1576
1673
 
@@ -1580,12 +1677,11 @@ async function unicorn(options = {}) {
1580
1677
  {
1581
1678
  name: "eslint/unicorn/rules",
1582
1679
  plugins: {
1583
- unicorn: default5
1680
+ unicorn: default6
1584
1681
  },
1585
1682
  rules: {
1586
- ...options.allRecommended ? default5.configs["flat/recommended"].rules : {
1683
+ ...options.allRecommended ? default6.configs["flat/recommended"].rules : {
1587
1684
  "unicorn/consistent-empty-array-spread": "error",
1588
- "unicorn/consistent-function-scoping": "error",
1589
1685
  "unicorn/error-message": "error",
1590
1686
  "unicorn/escape-case": "error",
1591
1687
  "unicorn/new-for-builtins": "error",
@@ -1874,65 +1970,6 @@ async function yaml(options = {}) {
1874
1970
  ];
1875
1971
  }
1876
1972
 
1877
- // src/configs/toml.ts
1878
- async function toml(options = {}) {
1879
- const {
1880
- files = [GLOB_TOML],
1881
- overrides = {},
1882
- stylistic: stylistic2 = true
1883
- } = options;
1884
- const {
1885
- indent = 4
1886
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1887
- const [
1888
- pluginToml,
1889
- parserToml
1890
- ] = await Promise.all([
1891
- interopDefault(import("eslint-plugin-toml")),
1892
- interopDefault(import("toml-eslint-parser"))
1893
- ]);
1894
- return [
1895
- {
1896
- name: "eslint/toml/setup",
1897
- plugins: {
1898
- toml: pluginToml
1899
- }
1900
- },
1901
- {
1902
- files,
1903
- languageOptions: {
1904
- parser: parserToml
1905
- },
1906
- name: "eslint/toml/rules",
1907
- rules: {
1908
- "style/spaced-comment": "off",
1909
- "toml/comma-style": "error",
1910
- "toml/keys-order": "error",
1911
- "toml/no-space-dots": "error",
1912
- "toml/no-unreadable-number-separator": "error",
1913
- "toml/precision-of-fractional-seconds": "error",
1914
- "toml/precision-of-integer": "error",
1915
- "toml/tables-order": "error",
1916
- "toml/vue-custom-block/no-parsing-error": "error",
1917
- ...stylistic2 ? {
1918
- "toml/array-bracket-newline": "error",
1919
- "toml/array-bracket-spacing": "error",
1920
- "toml/array-element-newline": "error",
1921
- "toml/indent": ["error", indent === "tab" ? 4 : indent],
1922
- "toml/inline-table-curly-spacing": "error",
1923
- "toml/key-spacing": "error",
1924
- "toml/padding-line-between-pairs": "error",
1925
- "toml/padding-line-between-tables": "error",
1926
- "toml/quoted-keys": "error",
1927
- "toml/spaced-comment": "error",
1928
- "toml/table-bracket-spacing": "error"
1929
- } : {},
1930
- ...overrides
1931
- }
1932
- }
1933
- ];
1934
- }
1935
-
1936
1973
  // src/factory.ts
1937
1974
  var flatConfigProps = [
1938
1975
  "name",
@@ -2120,6 +2157,9 @@ function lincy(options = {}, ...userConfigs) {
2120
2157
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2121
2158
  ));
2122
2159
  }
2160
+ configs2.push(
2161
+ disables()
2162
+ );
2123
2163
  if ("files" in options) {
2124
2164
  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");
2125
2165
  }
@@ -2179,6 +2219,7 @@ export {
2179
2219
  comments,
2180
2220
  src_default as default,
2181
2221
  defaultPluginRenaming,
2222
+ disables,
2182
2223
  ensurePackages,
2183
2224
  formatters,
2184
2225
  ignores,
@@ -2194,6 +2235,7 @@ export {
2194
2235
  lincy,
2195
2236
  markdown,
2196
2237
  node,
2238
+ parserPlain,
2197
2239
  perfectionist,
2198
2240
  react,
2199
2241
  regexp,