@whoj/eslint-config 1.5.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2729 @@
1
+ import {
2
+ init_esm_shims
3
+ } from "./chunk-MKNYKNDN.js";
4
+
5
+ // src/index.ts
6
+ init_esm_shims();
7
+
8
+ // src/factory.ts
9
+ init_esm_shims();
10
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
11
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
12
+
13
+ // src/configs/index.ts
14
+ init_esm_shims();
15
+
16
+ // src/configs/astro.ts
17
+ init_esm_shims();
18
+
19
+ // src/globs.ts
20
+ init_esm_shims();
21
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
22
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
23
+ var GLOB_JS = "**/*.?([cm])js";
24
+ var GLOB_JSX = "**/*.?([cm])jsx";
25
+ var GLOB_TS = "**/*.?([cm])ts";
26
+ var GLOB_TSX = "**/*.?([cm])tsx";
27
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
28
+ var GLOB_CSS = "**/*.css";
29
+ var GLOB_POSTCSS = "**/*.{p,post}css";
30
+ var GLOB_LESS = "**/*.less";
31
+ var GLOB_SCSS = "**/*.scss";
32
+ var GLOB_JSON = "**/*.json";
33
+ var GLOB_JSON5 = "**/*.json5";
34
+ var GLOB_JSONC = "**/*.jsonc";
35
+ var GLOB_MARKDOWN = "**/*.md";
36
+ var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
37
+ var GLOB_SVELTE = "**/*.svelte";
38
+ var GLOB_VUE = "**/*.vue";
39
+ var GLOB_YAML = "**/*.y?(a)ml";
40
+ var GLOB_TOML = "**/*.toml";
41
+ var GLOB_XML = "**/*.xml";
42
+ var GLOB_SVG = "**/*.svg";
43
+ var GLOB_HTML = "**/*.htm?(l)";
44
+ var GLOB_ASTRO = "**/*.astro";
45
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
46
+ var GLOB_GRAPHQL = "**/*.{g,graph}ql";
47
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
48
+ var GLOB_TESTS = [
49
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
50
+ `**/*.spec.${GLOB_SRC_EXT}`,
51
+ `**/*.test.${GLOB_SRC_EXT}`,
52
+ `**/*.bench.${GLOB_SRC_EXT}`,
53
+ `**/*.benchmark.${GLOB_SRC_EXT}`
54
+ ];
55
+ var GLOB_ALL_SRC = [
56
+ GLOB_SRC,
57
+ GLOB_STYLE,
58
+ GLOB_JSON,
59
+ GLOB_JSON5,
60
+ GLOB_MARKDOWN,
61
+ GLOB_SVELTE,
62
+ GLOB_VUE,
63
+ GLOB_YAML,
64
+ GLOB_XML,
65
+ GLOB_HTML
66
+ ];
67
+ var GLOB_EXCLUDE = [
68
+ "**/node_modules",
69
+ "**/dist",
70
+ "**/package-lock.json",
71
+ "**/yarn.lock",
72
+ "**/pnpm-lock.yaml",
73
+ "**/bun.lockb",
74
+ "**/output",
75
+ "**/coverage",
76
+ "**/temp",
77
+ "**/.temp",
78
+ "**/tmp",
79
+ "**/.tmp",
80
+ "**/.history",
81
+ "**/.vitepress/cache",
82
+ "**/.nuxt",
83
+ "**/.next",
84
+ "**/.svelte-kit",
85
+ "**/.vercel",
86
+ "**/.changeset",
87
+ "**/.idea",
88
+ "**/.cache",
89
+ "**/.output",
90
+ "**/.vite-inspect",
91
+ "**/.yarn",
92
+ "**/vite.config.*.timestamp-*",
93
+ "**/CHANGELOG*.md",
94
+ "**/*.min.*",
95
+ "**/LICENSE*",
96
+ "**/__snapshots__",
97
+ "**/auto-import?(s).d.ts",
98
+ "**/components.d.ts"
99
+ ];
100
+
101
+ // src/utils.ts
102
+ init_esm_shims();
103
+ import process from "node:process";
104
+ import { fileURLToPath } from "node:url";
105
+ import { isPackageExists } from "local-pkg";
106
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
107
+ var isCwdInScope = isPackageExists("@whoj/eslint-config");
108
+ var parserPlain = {
109
+ meta: {
110
+ name: "parser-plain"
111
+ },
112
+ parseForESLint: (code) => ({
113
+ ast: {
114
+ body: [],
115
+ comments: [],
116
+ loc: { end: code.length, start: 0 },
117
+ range: [0, code.length],
118
+ tokens: [],
119
+ type: "Program"
120
+ },
121
+ scopeManager: null,
122
+ services: { isPlain: true },
123
+ visitorKeys: {
124
+ Program: []
125
+ }
126
+ })
127
+ };
128
+ async function combine(...configs2) {
129
+ const resolved = await Promise.all(configs2);
130
+ return resolved.flat();
131
+ }
132
+ function renameRules(rules, map) {
133
+ return Object.fromEntries(
134
+ Object.entries(rules).map(([key, value]) => {
135
+ for (const [from, to] of Object.entries(map)) {
136
+ if (key.startsWith(`${from}/`))
137
+ return [to + key.slice(from.length), value];
138
+ }
139
+ return [key, value];
140
+ })
141
+ );
142
+ }
143
+ function renamePluginInConfigs(configs2, map) {
144
+ return configs2.map((i) => {
145
+ const clone = { ...i };
146
+ if (clone.rules)
147
+ clone.rules = renameRules(clone.rules, map);
148
+ if (clone.plugins) {
149
+ clone.plugins = Object.fromEntries(
150
+ Object.entries(clone.plugins).map(([key, value]) => {
151
+ if (key in map)
152
+ return [map[key], value];
153
+ return [key, value];
154
+ })
155
+ );
156
+ }
157
+ return clone;
158
+ });
159
+ }
160
+ function toArray(value) {
161
+ return Array.isArray(value) ? value : [value];
162
+ }
163
+ async function interopDefault(m) {
164
+ const resolved = await m;
165
+ return resolved.default || resolved;
166
+ }
167
+ function isPackageInScope(name) {
168
+ return isPackageExists(name, { paths: [scopeUrl] });
169
+ }
170
+ async function ensurePackages(packages) {
171
+ if (process.env.CI || !process.stdout.isTTY || !isCwdInScope)
172
+ return;
173
+ const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
174
+ if (nonExistingPackages.length === 0)
175
+ return;
176
+ const p = await import("@clack/prompts");
177
+ const result = await p.confirm({
178
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
179
+ });
180
+ if (result)
181
+ await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
182
+ }
183
+ function isInEditorEnv() {
184
+ if (process.env.CI)
185
+ return false;
186
+ if (isInGitHooksOrLintStaged())
187
+ return false;
188
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
189
+ }
190
+ function isInGitHooksOrLintStaged() {
191
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
192
+ }
193
+
194
+ // src/configs/astro.ts
195
+ async function astro(options = {}) {
196
+ const {
197
+ files = [GLOB_ASTRO],
198
+ overrides = {},
199
+ stylistic: stylistic2 = true
200
+ } = options;
201
+ const [
202
+ pluginAstro,
203
+ parserAstro,
204
+ parserTs
205
+ ] = await Promise.all([
206
+ interopDefault(import("./lib-FENTQ4WJ.js")),
207
+ interopDefault(import("./lib-WKUBBNE4.js")),
208
+ interopDefault(import("@typescript-eslint/parser"))
209
+ ]);
210
+ return [
211
+ {
212
+ name: "antfu/astro/setup",
213
+ plugins: {
214
+ astro: pluginAstro
215
+ }
216
+ },
217
+ {
218
+ files,
219
+ languageOptions: {
220
+ globals: pluginAstro.environments.astro.globals,
221
+ parser: parserAstro,
222
+ parserOptions: {
223
+ extraFileExtensions: [".astro"],
224
+ parser: parserTs
225
+ },
226
+ sourceType: "module"
227
+ },
228
+ name: "antfu/astro/rules",
229
+ processor: "astro/client-side-ts",
230
+ rules: {
231
+ // Astro uses top level await for e.g. data fetching
232
+ // https://docs.astro.build/en/guides/data-fetching/#fetch-in-astro
233
+ "antfu/no-top-level-await": "off",
234
+ // use recommended rules
235
+ "astro/missing-client-only-directive-value": "error",
236
+ "astro/no-conflict-set-directives": "error",
237
+ "astro/no-deprecated-astro-canonicalurl": "error",
238
+ "astro/no-deprecated-astro-fetchcontent": "error",
239
+ "astro/no-deprecated-astro-resolve": "error",
240
+ "astro/no-deprecated-getentrybyslug": "error",
241
+ "astro/no-set-html-directive": "off",
242
+ "astro/no-unused-define-vars-in-style": "error",
243
+ "astro/semi": "off",
244
+ "astro/valid-compile": "error",
245
+ ...stylistic2 ? {
246
+ "style/indent": "off",
247
+ "style/jsx-closing-tag-location": "off",
248
+ "style/jsx-one-expression-per-line": "off",
249
+ "style/no-multiple-empty-lines": "off"
250
+ } : {},
251
+ ...overrides
252
+ }
253
+ }
254
+ ];
255
+ }
256
+
257
+ // src/configs/command.ts
258
+ init_esm_shims();
259
+ import createCommand from "eslint-plugin-command/config";
260
+ async function command() {
261
+ return [
262
+ {
263
+ ...createCommand(),
264
+ name: "antfu/command/rules"
265
+ }
266
+ ];
267
+ }
268
+
269
+ // src/configs/comments.ts
270
+ init_esm_shims();
271
+
272
+ // src/plugins.ts
273
+ init_esm_shims();
274
+ import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
275
+ import { default as default3 } from "eslint-plugin-antfu";
276
+ import * as pluginImport from "eslint-plugin-import-x";
277
+ import { default as default4 } from "eslint-plugin-n";
278
+ import { default as default5 } from "eslint-plugin-perfectionist";
279
+ import { default as default6 } from "eslint-plugin-unicorn";
280
+ import { default as default7 } from "eslint-plugin-unused-imports";
281
+
282
+ // src/configs/comments.ts
283
+ async function comments() {
284
+ return [
285
+ {
286
+ name: "antfu/eslint-comments/rules",
287
+ plugins: {
288
+ "eslint-comments": default2
289
+ },
290
+ rules: {
291
+ "eslint-comments/no-aggregating-enable": "error",
292
+ "eslint-comments/no-duplicate-disable": "error",
293
+ "eslint-comments/no-unlimited-disable": "error",
294
+ "eslint-comments/no-unused-enable": "error"
295
+ }
296
+ }
297
+ ];
298
+ }
299
+
300
+ // src/configs/disables.ts
301
+ init_esm_shims();
302
+ async function disables() {
303
+ return [
304
+ {
305
+ files: [`**/scripts/${GLOB_SRC}`],
306
+ name: "antfu/disables/scripts",
307
+ rules: {
308
+ "antfu/no-top-level-await": "off",
309
+ "no-console": "off",
310
+ "ts/explicit-function-return-type": "off"
311
+ }
312
+ },
313
+ {
314
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
315
+ name: "antfu/disables/cli",
316
+ rules: {
317
+ "antfu/no-top-level-await": "off",
318
+ "no-console": "off"
319
+ }
320
+ },
321
+ {
322
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
323
+ name: "antfu/disables/bin",
324
+ rules: {
325
+ "antfu/no-import-dist": "off",
326
+ "antfu/no-import-node-modules-by-path": "off"
327
+ }
328
+ },
329
+ {
330
+ files: ["**/*.d.?([cm])ts"],
331
+ name: "antfu/disables/dts",
332
+ rules: {
333
+ "eslint-comments/no-unlimited-disable": "off",
334
+ "import/no-duplicates": "off",
335
+ "no-restricted-syntax": "off",
336
+ "unused-imports/no-unused-vars": "off"
337
+ }
338
+ },
339
+ {
340
+ files: ["**/*.js", "**/*.cjs"],
341
+ name: "antfu/disables/cjs",
342
+ rules: {
343
+ "ts/no-require-imports": "off"
344
+ }
345
+ },
346
+ {
347
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
348
+ name: "antfu/disables/config-files",
349
+ rules: {
350
+ "antfu/no-top-level-await": "off",
351
+ "no-console": "off",
352
+ "ts/explicit-function-return-type": "off"
353
+ }
354
+ }
355
+ ];
356
+ }
357
+
358
+ // src/configs/formatters.ts
359
+ init_esm_shims();
360
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
361
+
362
+ // src/configs/stylistic.ts
363
+ init_esm_shims();
364
+ var StylisticConfigDefaults = {
365
+ indent: 2,
366
+ jsx: true,
367
+ quotes: "single",
368
+ semi: false
369
+ };
370
+ async function stylistic(options = {}) {
371
+ const {
372
+ indent,
373
+ jsx: jsx2,
374
+ lessOpinionated = false,
375
+ overrides = {},
376
+ quotes,
377
+ semi
378
+ } = {
379
+ ...StylisticConfigDefaults,
380
+ ...options
381
+ };
382
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
383
+ const config = pluginStylistic.configs.customize({
384
+ flat: true,
385
+ indent,
386
+ jsx: jsx2,
387
+ pluginName: "style",
388
+ quotes,
389
+ semi
390
+ });
391
+ return [
392
+ {
393
+ name: "antfu/stylistic/rules",
394
+ plugins: {
395
+ antfu: default3,
396
+ style: pluginStylistic
397
+ },
398
+ rules: {
399
+ ...config.rules,
400
+ "antfu/consistent-chaining": "error",
401
+ "antfu/consistent-list-newline": "error",
402
+ ...lessOpinionated ? {
403
+ curly: ["error", "all"]
404
+ } : {
405
+ "antfu/curly": "error",
406
+ "antfu/if-newline": "error",
407
+ "antfu/top-level-function": "error"
408
+ },
409
+ ...overrides
410
+ }
411
+ }
412
+ ];
413
+ }
414
+
415
+ // src/configs/formatters.ts
416
+ function mergePrettierOptions(options, overrides = {}) {
417
+ return {
418
+ ...options,
419
+ ...overrides,
420
+ plugins: [
421
+ ...overrides.plugins || [],
422
+ ...options.plugins || []
423
+ ]
424
+ };
425
+ }
426
+ async function formatters(options = {}, stylistic2 = {}) {
427
+ if (options === true) {
428
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
429
+ options = {
430
+ astro: isPackageInScope("prettier-plugin-astro"),
431
+ css: true,
432
+ graphql: true,
433
+ html: true,
434
+ markdown: true,
435
+ slidev: isPackageExists2("@slidev/cli"),
436
+ svg: isPrettierPluginXmlInScope,
437
+ xml: isPrettierPluginXmlInScope
438
+ };
439
+ }
440
+ await ensurePackages([
441
+ "eslint-plugin-format",
442
+ options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
443
+ options.astro ? "prettier-plugin-astro" : void 0,
444
+ options.xml || options.svg ? "@prettier/plugin-xml" : void 0
445
+ ]);
446
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
447
+ throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
448
+ const {
449
+ indent,
450
+ quotes,
451
+ semi
452
+ } = {
453
+ ...StylisticConfigDefaults,
454
+ ...stylistic2
455
+ };
456
+ const prettierOptions = Object.assign(
457
+ {
458
+ endOfLine: "auto",
459
+ printWidth: 120,
460
+ semi,
461
+ singleQuote: quotes === "single",
462
+ tabWidth: typeof indent === "number" ? indent : 2,
463
+ trailingComma: "all",
464
+ useTabs: indent === "tab"
465
+ },
466
+ options.prettierOptions || {}
467
+ );
468
+ const prettierXmlOptions = {
469
+ xmlQuoteAttributes: "double",
470
+ xmlSelfClosingSpace: true,
471
+ xmlSortAttributesByKey: false,
472
+ xmlWhitespaceSensitivity: "ignore"
473
+ };
474
+ const dprintOptions = Object.assign(
475
+ {
476
+ indentWidth: typeof indent === "number" ? indent : 2,
477
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
478
+ useTabs: indent === "tab"
479
+ },
480
+ options.dprintOptions || {}
481
+ );
482
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
483
+ const configs2 = [
484
+ {
485
+ name: "antfu/formatter/setup",
486
+ plugins: {
487
+ format: pluginFormat
488
+ }
489
+ }
490
+ ];
491
+ if (options.css) {
492
+ configs2.push(
493
+ {
494
+ files: [GLOB_CSS, GLOB_POSTCSS],
495
+ languageOptions: {
496
+ parser: parserPlain
497
+ },
498
+ name: "antfu/formatter/css",
499
+ rules: {
500
+ "format/prettier": [
501
+ "error",
502
+ mergePrettierOptions(prettierOptions, {
503
+ parser: "css"
504
+ })
505
+ ]
506
+ }
507
+ },
508
+ {
509
+ files: [GLOB_SCSS],
510
+ languageOptions: {
511
+ parser: parserPlain
512
+ },
513
+ name: "antfu/formatter/scss",
514
+ rules: {
515
+ "format/prettier": [
516
+ "error",
517
+ mergePrettierOptions(prettierOptions, {
518
+ parser: "scss"
519
+ })
520
+ ]
521
+ }
522
+ },
523
+ {
524
+ files: [GLOB_LESS],
525
+ languageOptions: {
526
+ parser: parserPlain
527
+ },
528
+ name: "antfu/formatter/less",
529
+ rules: {
530
+ "format/prettier": [
531
+ "error",
532
+ mergePrettierOptions(prettierOptions, {
533
+ parser: "less"
534
+ })
535
+ ]
536
+ }
537
+ }
538
+ );
539
+ }
540
+ if (options.html) {
541
+ configs2.push({
542
+ files: [GLOB_HTML],
543
+ languageOptions: {
544
+ parser: parserPlain
545
+ },
546
+ name: "antfu/formatter/html",
547
+ rules: {
548
+ "format/prettier": [
549
+ "error",
550
+ mergePrettierOptions(prettierOptions, {
551
+ parser: "html"
552
+ })
553
+ ]
554
+ }
555
+ });
556
+ }
557
+ if (options.xml) {
558
+ configs2.push({
559
+ files: [GLOB_XML],
560
+ languageOptions: {
561
+ parser: parserPlain
562
+ },
563
+ name: "antfu/formatter/xml",
564
+ rules: {
565
+ "format/prettier": [
566
+ "error",
567
+ mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
568
+ parser: "xml",
569
+ plugins: [
570
+ "@prettier/plugin-xml"
571
+ ]
572
+ })
573
+ ]
574
+ }
575
+ });
576
+ }
577
+ if (options.svg) {
578
+ configs2.push({
579
+ files: [GLOB_SVG],
580
+ languageOptions: {
581
+ parser: parserPlain
582
+ },
583
+ name: "antfu/formatter/svg",
584
+ rules: {
585
+ "format/prettier": [
586
+ "error",
587
+ mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
588
+ parser: "xml",
589
+ plugins: [
590
+ "@prettier/plugin-xml"
591
+ ]
592
+ })
593
+ ]
594
+ }
595
+ });
596
+ }
597
+ if (options.markdown) {
598
+ const formater = options.markdown === true ? "prettier" : options.markdown;
599
+ const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
600
+ configs2.push({
601
+ files: [GLOB_MARKDOWN],
602
+ ignores: GLOB_SLIDEV,
603
+ languageOptions: {
604
+ parser: parserPlain
605
+ },
606
+ name: "antfu/formatter/markdown",
607
+ rules: {
608
+ [`format/${formater}`]: [
609
+ "error",
610
+ formater === "prettier" ? mergePrettierOptions(prettierOptions, {
611
+ embeddedLanguageFormatting: "off",
612
+ parser: "markdown"
613
+ }) : {
614
+ ...dprintOptions,
615
+ language: "markdown"
616
+ }
617
+ ]
618
+ }
619
+ });
620
+ if (options.slidev) {
621
+ configs2.push({
622
+ files: GLOB_SLIDEV,
623
+ languageOptions: {
624
+ parser: parserPlain
625
+ },
626
+ name: "antfu/formatter/slidev",
627
+ rules: {
628
+ "format/prettier": [
629
+ "error",
630
+ mergePrettierOptions(prettierOptions, {
631
+ embeddedLanguageFormatting: "off",
632
+ parser: "slidev",
633
+ plugins: [
634
+ "prettier-plugin-slidev"
635
+ ]
636
+ })
637
+ ]
638
+ }
639
+ });
640
+ }
641
+ }
642
+ if (options.astro) {
643
+ configs2.push({
644
+ files: [GLOB_ASTRO],
645
+ languageOptions: {
646
+ parser: parserPlain
647
+ },
648
+ name: "antfu/formatter/astro",
649
+ rules: {
650
+ "format/prettier": [
651
+ "error",
652
+ mergePrettierOptions(prettierOptions, {
653
+ parser: "astro",
654
+ plugins: [
655
+ "prettier-plugin-astro"
656
+ ]
657
+ })
658
+ ]
659
+ }
660
+ });
661
+ configs2.push({
662
+ files: [GLOB_ASTRO, GLOB_ASTRO_TS],
663
+ name: "antfu/formatter/astro/disables",
664
+ rules: {
665
+ "style/arrow-parens": "off",
666
+ "style/block-spacing": "off",
667
+ "style/comma-dangle": "off",
668
+ "style/indent": "off",
669
+ "style/no-multi-spaces": "off",
670
+ "style/quotes": "off",
671
+ "style/semi": "off"
672
+ }
673
+ });
674
+ }
675
+ if (options.graphql) {
676
+ configs2.push({
677
+ files: [GLOB_GRAPHQL],
678
+ languageOptions: {
679
+ parser: parserPlain
680
+ },
681
+ name: "antfu/formatter/graphql",
682
+ rules: {
683
+ "format/prettier": [
684
+ "error",
685
+ mergePrettierOptions(prettierOptions, {
686
+ parser: "graphql"
687
+ })
688
+ ]
689
+ }
690
+ });
691
+ }
692
+ return configs2;
693
+ }
694
+
695
+ // src/configs/ignores.ts
696
+ init_esm_shims();
697
+ async function ignores(userIgnores = []) {
698
+ return [
699
+ {
700
+ ignores: [
701
+ ...GLOB_EXCLUDE,
702
+ ...userIgnores
703
+ ],
704
+ name: "antfu/ignores"
705
+ }
706
+ ];
707
+ }
708
+
709
+ // src/configs/imports.ts
710
+ init_esm_shims();
711
+ async function imports(options = {}) {
712
+ const {
713
+ stylistic: stylistic2 = true
714
+ } = options;
715
+ return [
716
+ {
717
+ name: "antfu/imports/rules",
718
+ plugins: {
719
+ antfu: default3,
720
+ import: pluginImport
721
+ },
722
+ rules: {
723
+ "antfu/import-dedupe": "error",
724
+ "antfu/no-import-dist": "error",
725
+ "antfu/no-import-node-modules-by-path": "error",
726
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
727
+ "import/first": "error",
728
+ "import/no-duplicates": "error",
729
+ "import/no-mutable-exports": "error",
730
+ "import/no-named-default": "error",
731
+ "import/no-self-import": "error",
732
+ "import/no-webpack-loader-syntax": "error",
733
+ ...stylistic2 ? {
734
+ "import/newline-after-import": ["error", { count: 1 }]
735
+ } : {}
736
+ }
737
+ }
738
+ ];
739
+ }
740
+
741
+ // src/configs/javascript.ts
742
+ init_esm_shims();
743
+ import globals from "globals";
744
+ async function javascript(options = {}) {
745
+ const {
746
+ isInEditor = false,
747
+ overrides = {}
748
+ } = options;
749
+ return [
750
+ {
751
+ languageOptions: {
752
+ ecmaVersion: 2022,
753
+ globals: {
754
+ ...globals.browser,
755
+ ...globals.es2021,
756
+ ...globals.node,
757
+ document: "readonly",
758
+ navigator: "readonly",
759
+ window: "readonly"
760
+ },
761
+ parserOptions: {
762
+ ecmaFeatures: {
763
+ jsx: true
764
+ },
765
+ ecmaVersion: 2022,
766
+ sourceType: "module"
767
+ },
768
+ sourceType: "module"
769
+ },
770
+ linterOptions: {
771
+ reportUnusedDisableDirectives: true
772
+ },
773
+ name: "antfu/javascript/setup"
774
+ },
775
+ {
776
+ name: "antfu/javascript/rules",
777
+ plugins: {
778
+ "antfu": default3,
779
+ "unused-imports": default7
780
+ },
781
+ rules: {
782
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
783
+ "antfu/no-top-level-await": "error",
784
+ "array-callback-return": "error",
785
+ "block-scoped-var": "error",
786
+ "constructor-super": "error",
787
+ "default-case-last": "error",
788
+ "dot-notation": ["error", { allowKeywords: true }],
789
+ "eqeqeq": ["error", "smart"],
790
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
791
+ "no-alert": "error",
792
+ "no-array-constructor": "error",
793
+ "no-async-promise-executor": "error",
794
+ "no-caller": "error",
795
+ "no-case-declarations": "error",
796
+ "no-class-assign": "error",
797
+ "no-compare-neg-zero": "error",
798
+ "no-cond-assign": ["error", "always"],
799
+ "no-console": ["error", { allow: ["warn", "error"] }],
800
+ "no-const-assign": "error",
801
+ "no-control-regex": "error",
802
+ "no-debugger": "error",
803
+ "no-delete-var": "error",
804
+ "no-dupe-args": "error",
805
+ "no-dupe-class-members": "error",
806
+ "no-dupe-keys": "error",
807
+ "no-duplicate-case": "error",
808
+ "no-empty": ["error", { allowEmptyCatch: true }],
809
+ "no-empty-character-class": "error",
810
+ "no-empty-pattern": "error",
811
+ "no-eval": "error",
812
+ "no-ex-assign": "error",
813
+ "no-extend-native": "error",
814
+ "no-extra-bind": "error",
815
+ "no-extra-boolean-cast": "error",
816
+ "no-fallthrough": "error",
817
+ "no-func-assign": "error",
818
+ "no-global-assign": "error",
819
+ "no-implied-eval": "error",
820
+ "no-import-assign": "error",
821
+ "no-invalid-regexp": "error",
822
+ "no-irregular-whitespace": "error",
823
+ "no-iterator": "error",
824
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
825
+ "no-lone-blocks": "error",
826
+ "no-loss-of-precision": "error",
827
+ "no-misleading-character-class": "error",
828
+ "no-multi-str": "error",
829
+ "no-new": "error",
830
+ "no-new-func": "error",
831
+ "no-new-native-nonconstructor": "error",
832
+ "no-new-wrappers": "error",
833
+ "no-obj-calls": "error",
834
+ "no-octal": "error",
835
+ "no-octal-escape": "error",
836
+ "no-proto": "error",
837
+ "no-prototype-builtins": "error",
838
+ "no-redeclare": ["error", { builtinGlobals: false }],
839
+ "no-regex-spaces": "error",
840
+ "no-restricted-globals": [
841
+ "error",
842
+ { message: "Use `globalThis` instead.", name: "global" },
843
+ { message: "Use `globalThis` instead.", name: "self" }
844
+ ],
845
+ "no-restricted-properties": [
846
+ "error",
847
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
848
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
849
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
850
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
851
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
852
+ ],
853
+ "no-restricted-syntax": [
854
+ "error",
855
+ "TSEnumDeclaration[const=true]",
856
+ "TSExportAssignment"
857
+ ],
858
+ "no-self-assign": ["error", { props: true }],
859
+ "no-self-compare": "error",
860
+ "no-sequences": "error",
861
+ "no-shadow-restricted-names": "error",
862
+ "no-sparse-arrays": "error",
863
+ "no-template-curly-in-string": "error",
864
+ "no-this-before-super": "error",
865
+ "no-throw-literal": "error",
866
+ "no-undef": "error",
867
+ "no-undef-init": "error",
868
+ "no-unexpected-multiline": "error",
869
+ "no-unmodified-loop-condition": "error",
870
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
871
+ "no-unreachable": "error",
872
+ "no-unreachable-loop": "error",
873
+ "no-unsafe-finally": "error",
874
+ "no-unsafe-negation": "error",
875
+ "no-unused-expressions": ["error", {
876
+ allowShortCircuit: true,
877
+ allowTaggedTemplates: true,
878
+ allowTernary: true
879
+ }],
880
+ "no-unused-vars": ["error", {
881
+ args: "none",
882
+ caughtErrors: "none",
883
+ ignoreRestSiblings: true,
884
+ vars: "all"
885
+ }],
886
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
887
+ "no-useless-backreference": "error",
888
+ "no-useless-call": "error",
889
+ "no-useless-catch": "error",
890
+ "no-useless-computed-key": "error",
891
+ "no-useless-constructor": "error",
892
+ "no-useless-rename": "error",
893
+ "no-useless-return": "error",
894
+ "no-var": "error",
895
+ "no-with": "error",
896
+ "object-shorthand": [
897
+ "error",
898
+ "always",
899
+ {
900
+ avoidQuotes: true,
901
+ ignoreConstructors: false
902
+ }
903
+ ],
904
+ "one-var": ["error", { initialized: "never" }],
905
+ "prefer-arrow-callback": [
906
+ "error",
907
+ {
908
+ allowNamedFunctions: false,
909
+ allowUnboundThis: true
910
+ }
911
+ ],
912
+ "prefer-const": [
913
+ isInEditor ? "warn" : "error",
914
+ {
915
+ destructuring: "all",
916
+ ignoreReadBeforeAssign: true
917
+ }
918
+ ],
919
+ "prefer-exponentiation-operator": "error",
920
+ "prefer-promise-reject-errors": "error",
921
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
922
+ "prefer-rest-params": "error",
923
+ "prefer-spread": "error",
924
+ "prefer-template": "error",
925
+ "symbol-description": "error",
926
+ "unicode-bom": ["error", "never"],
927
+ "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
928
+ "unused-imports/no-unused-vars": [
929
+ "error",
930
+ {
931
+ args: "after-used",
932
+ argsIgnorePattern: "^_",
933
+ ignoreRestSiblings: true,
934
+ vars: "all",
935
+ varsIgnorePattern: "^_"
936
+ }
937
+ ],
938
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
939
+ "valid-typeof": ["error", { requireStringLiterals: true }],
940
+ "vars-on-top": "error",
941
+ "yoda": ["error", "never"],
942
+ ...overrides
943
+ }
944
+ }
945
+ ];
946
+ }
947
+
948
+ // src/configs/jsdoc.ts
949
+ init_esm_shims();
950
+ async function jsdoc(options = {}) {
951
+ const {
952
+ stylistic: stylistic2 = true
953
+ } = options;
954
+ return [
955
+ {
956
+ name: "antfu/jsdoc/rules",
957
+ plugins: {
958
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
959
+ },
960
+ rules: {
961
+ "jsdoc/check-access": "warn",
962
+ "jsdoc/check-param-names": "warn",
963
+ "jsdoc/check-property-names": "warn",
964
+ "jsdoc/check-types": "warn",
965
+ "jsdoc/empty-tags": "warn",
966
+ "jsdoc/implements-on-classes": "warn",
967
+ "jsdoc/no-defaults": "warn",
968
+ "jsdoc/no-multi-asterisks": "warn",
969
+ "jsdoc/require-param-name": "warn",
970
+ "jsdoc/require-property": "warn",
971
+ "jsdoc/require-property-description": "warn",
972
+ "jsdoc/require-property-name": "warn",
973
+ "jsdoc/require-returns-check": "warn",
974
+ "jsdoc/require-returns-description": "warn",
975
+ "jsdoc/require-yields-check": "warn",
976
+ ...stylistic2 ? {
977
+ "jsdoc/check-alignment": "warn",
978
+ "jsdoc/multiline-blocks": "warn"
979
+ } : {}
980
+ }
981
+ }
982
+ ];
983
+ }
984
+
985
+ // src/configs/jsonc.ts
986
+ init_esm_shims();
987
+ async function jsonc(options = {}) {
988
+ const {
989
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
990
+ overrides = {},
991
+ stylistic: stylistic2 = true
992
+ } = options;
993
+ const {
994
+ indent = 2
995
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
996
+ const [
997
+ pluginJsonc,
998
+ parserJsonc
999
+ ] = await Promise.all([
1000
+ interopDefault(import("eslint-plugin-jsonc")),
1001
+ interopDefault(import("jsonc-eslint-parser"))
1002
+ ]);
1003
+ return [
1004
+ {
1005
+ name: "antfu/jsonc/setup",
1006
+ plugins: {
1007
+ jsonc: pluginJsonc
1008
+ }
1009
+ },
1010
+ {
1011
+ files,
1012
+ languageOptions: {
1013
+ parser: parserJsonc
1014
+ },
1015
+ name: "antfu/jsonc/rules",
1016
+ rules: {
1017
+ "jsonc/no-bigint-literals": "error",
1018
+ "jsonc/no-binary-expression": "error",
1019
+ "jsonc/no-binary-numeric-literals": "error",
1020
+ "jsonc/no-dupe-keys": "error",
1021
+ "jsonc/no-escape-sequence-in-identifier": "error",
1022
+ "jsonc/no-floating-decimal": "error",
1023
+ "jsonc/no-hexadecimal-numeric-literals": "error",
1024
+ "jsonc/no-infinity": "error",
1025
+ "jsonc/no-multi-str": "error",
1026
+ "jsonc/no-nan": "error",
1027
+ "jsonc/no-number-props": "error",
1028
+ "jsonc/no-numeric-separators": "error",
1029
+ "jsonc/no-octal": "error",
1030
+ "jsonc/no-octal-escape": "error",
1031
+ "jsonc/no-octal-numeric-literals": "error",
1032
+ "jsonc/no-parenthesized": "error",
1033
+ "jsonc/no-plus-sign": "error",
1034
+ "jsonc/no-regexp-literals": "error",
1035
+ "jsonc/no-sparse-arrays": "error",
1036
+ "jsonc/no-template-literals": "error",
1037
+ "jsonc/no-undefined-value": "error",
1038
+ "jsonc/no-unicode-codepoint-escapes": "error",
1039
+ "jsonc/no-useless-escape": "error",
1040
+ "jsonc/space-unary-ops": "error",
1041
+ "jsonc/valid-json-number": "error",
1042
+ "jsonc/vue-custom-block/no-parsing-error": "error",
1043
+ ...stylistic2 ? {
1044
+ "jsonc/array-bracket-spacing": ["error", "never"],
1045
+ "jsonc/comma-dangle": ["error", "never"],
1046
+ "jsonc/comma-style": ["error", "last"],
1047
+ "jsonc/indent": ["error", indent],
1048
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1049
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
1050
+ "jsonc/object-curly-spacing": ["error", "always"],
1051
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1052
+ "jsonc/quote-props": "error",
1053
+ "jsonc/quotes": "error"
1054
+ } : {},
1055
+ ...overrides
1056
+ }
1057
+ }
1058
+ ];
1059
+ }
1060
+
1061
+ // src/configs/jsx.ts
1062
+ init_esm_shims();
1063
+ async function jsx() {
1064
+ return [
1065
+ {
1066
+ files: [GLOB_JSX, GLOB_TSX],
1067
+ languageOptions: {
1068
+ parserOptions: {
1069
+ ecmaFeatures: {
1070
+ jsx: true
1071
+ }
1072
+ }
1073
+ },
1074
+ name: "antfu/jsx/setup"
1075
+ }
1076
+ ];
1077
+ }
1078
+
1079
+ // src/configs/markdown.ts
1080
+ init_esm_shims();
1081
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
1082
+ async function markdown(options = {}) {
1083
+ const {
1084
+ componentExts = [],
1085
+ files = [GLOB_MARKDOWN],
1086
+ overrides = {}
1087
+ } = options;
1088
+ const markdown2 = await interopDefault(import("@eslint/markdown"));
1089
+ return [
1090
+ {
1091
+ name: "antfu/markdown/setup",
1092
+ plugins: {
1093
+ markdown: markdown2
1094
+ }
1095
+ },
1096
+ {
1097
+ files,
1098
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1099
+ name: "antfu/markdown/processor",
1100
+ // `eslint-plugin-markdown` only creates virtual files for code blocks,
1101
+ // but not the markdown file itself. We use `eslint-merge-processors` to
1102
+ // add a pass-through processor for the markdown file itself.
1103
+ processor: mergeProcessors([
1104
+ markdown2.processors.markdown,
1105
+ processorPassThrough
1106
+ ])
1107
+ },
1108
+ {
1109
+ files,
1110
+ languageOptions: {
1111
+ parser: parserPlain
1112
+ },
1113
+ name: "antfu/markdown/parser"
1114
+ },
1115
+ {
1116
+ files: [
1117
+ GLOB_MARKDOWN_CODE,
1118
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1119
+ ],
1120
+ languageOptions: {
1121
+ parserOptions: {
1122
+ ecmaFeatures: {
1123
+ impliedStrict: true
1124
+ }
1125
+ }
1126
+ },
1127
+ name: "antfu/markdown/disables",
1128
+ rules: {
1129
+ "antfu/no-top-level-await": "off",
1130
+ "import/newline-after-import": "off",
1131
+ "no-alert": "off",
1132
+ "no-console": "off",
1133
+ "no-labels": "off",
1134
+ "no-lone-blocks": "off",
1135
+ "no-restricted-syntax": "off",
1136
+ "no-undef": "off",
1137
+ "no-unused-expressions": "off",
1138
+ "no-unused-labels": "off",
1139
+ "no-unused-vars": "off",
1140
+ "node/prefer-global/process": "off",
1141
+ "style/comma-dangle": "off",
1142
+ "style/eol-last": "off",
1143
+ "ts/consistent-type-imports": "off",
1144
+ "ts/explicit-function-return-type": "off",
1145
+ "ts/no-namespace": "off",
1146
+ "ts/no-redeclare": "off",
1147
+ "ts/no-require-imports": "off",
1148
+ "ts/no-unused-expressions": "off",
1149
+ "ts/no-unused-vars": "off",
1150
+ "ts/no-use-before-define": "off",
1151
+ "unicode-bom": "off",
1152
+ "unused-imports/no-unused-imports": "off",
1153
+ "unused-imports/no-unused-vars": "off",
1154
+ ...overrides
1155
+ }
1156
+ }
1157
+ ];
1158
+ }
1159
+
1160
+ // src/configs/node.ts
1161
+ init_esm_shims();
1162
+ async function node() {
1163
+ return [
1164
+ {
1165
+ name: "antfu/node/rules",
1166
+ plugins: {
1167
+ node: default4
1168
+ },
1169
+ rules: {
1170
+ "node/handle-callback-err": ["error", "^(err|error)$"],
1171
+ "node/no-deprecated-api": "error",
1172
+ "node/no-exports-assign": "error",
1173
+ "node/no-new-require": "error",
1174
+ "node/no-path-concat": "error",
1175
+ "node/prefer-global/buffer": ["error", "never"],
1176
+ "node/prefer-global/process": ["error", "never"],
1177
+ "node/process-exit-as-throw": "error"
1178
+ }
1179
+ }
1180
+ ];
1181
+ }
1182
+
1183
+ // src/configs/perfectionist.ts
1184
+ init_esm_shims();
1185
+ async function perfectionist() {
1186
+ return [
1187
+ {
1188
+ name: "antfu/perfectionist/setup",
1189
+ plugins: {
1190
+ perfectionist: default5
1191
+ },
1192
+ rules: {
1193
+ "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1194
+ "perfectionist/sort-imports": ["error", {
1195
+ groups: [
1196
+ "type",
1197
+ ["parent-type", "sibling-type", "index-type", "internal-type"],
1198
+ "builtin",
1199
+ "external",
1200
+ "internal",
1201
+ ["parent", "sibling", "index"],
1202
+ "side-effect",
1203
+ "object",
1204
+ "unknown"
1205
+ ],
1206
+ newlinesBetween: "ignore",
1207
+ order: "asc",
1208
+ type: "natural"
1209
+ }],
1210
+ "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1211
+ "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
1212
+ }
1213
+ }
1214
+ ];
1215
+ }
1216
+
1217
+ // src/configs/react.ts
1218
+ init_esm_shims();
1219
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
1220
+ var ReactRefreshAllowConstantExportPackages = [
1221
+ "vite"
1222
+ ];
1223
+ var RemixPackages = [
1224
+ "@remix-run/node",
1225
+ "@remix-run/react",
1226
+ "@remix-run/serve",
1227
+ "@remix-run/dev"
1228
+ ];
1229
+ var ReactRouterPackages = [
1230
+ "@react-router/node",
1231
+ "@react-router/react",
1232
+ "@react-router/serve",
1233
+ "@react-router/dev"
1234
+ ];
1235
+ var NextJsPackages = [
1236
+ "next"
1237
+ ];
1238
+ async function react(options = {}) {
1239
+ const {
1240
+ files = [GLOB_SRC],
1241
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
1242
+ ignoresTypeAware = [
1243
+ `${GLOB_MARKDOWN}/**`,
1244
+ GLOB_ASTRO_TS
1245
+ ],
1246
+ overrides = {},
1247
+ tsconfigPath
1248
+ } = options;
1249
+ await ensurePackages([
1250
+ "@eslint-react/eslint-plugin",
1251
+ "eslint-plugin-react-hooks",
1252
+ "eslint-plugin-react-refresh"
1253
+ ]);
1254
+ const isTypeAware = !!tsconfigPath;
1255
+ const typeAwareRules = {
1256
+ "react/no-leaked-conditional-rendering": "warn"
1257
+ };
1258
+ const [
1259
+ pluginReact,
1260
+ pluginReactHooks,
1261
+ pluginReactRefresh
1262
+ ] = await Promise.all([
1263
+ interopDefault(import("./dist-BE4MFJS4.js")),
1264
+ interopDefault(import("./eslint-plugin-react-hooks-BV2CYKDG.js")),
1265
+ interopDefault(import("./eslint-plugin-react-refresh-N5P3A37Z.js"))
1266
+ ]);
1267
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists3(i));
1268
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists3(i));
1269
+ const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists3(i));
1270
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists3(i));
1271
+ const plugins = pluginReact.configs.all.plugins;
1272
+ return [
1273
+ {
1274
+ name: "antfu/react/setup",
1275
+ plugins: {
1276
+ "react": plugins["@eslint-react"],
1277
+ "react-dom": plugins["@eslint-react/dom"],
1278
+ "react-hooks": pluginReactHooks,
1279
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1280
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
1281
+ "react-refresh": pluginReactRefresh,
1282
+ "react-web-api": plugins["@eslint-react/web-api"]
1283
+ }
1284
+ },
1285
+ {
1286
+ files,
1287
+ languageOptions: {
1288
+ parserOptions: {
1289
+ ecmaFeatures: {
1290
+ jsx: true
1291
+ }
1292
+ },
1293
+ sourceType: "module"
1294
+ },
1295
+ name: "antfu/react/rules",
1296
+ rules: {
1297
+ // recommended rules from @eslint-react/dom
1298
+ "react-dom/no-children-in-void-dom-elements": "warn",
1299
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1300
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1301
+ "react-dom/no-find-dom-node": "error",
1302
+ "react-dom/no-missing-button-type": "warn",
1303
+ "react-dom/no-missing-iframe-sandbox": "warn",
1304
+ "react-dom/no-namespace": "error",
1305
+ "react-dom/no-render-return-value": "error",
1306
+ "react-dom/no-script-url": "warn",
1307
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1308
+ "react-dom/no-unsafe-target-blank": "warn",
1309
+ // recommended rules react-hooks
1310
+ "react-hooks/exhaustive-deps": "warn",
1311
+ "react-hooks/rules-of-hooks": "error",
1312
+ // react refresh
1313
+ "react-refresh/only-export-components": [
1314
+ "warn",
1315
+ {
1316
+ allowConstantExport: isAllowConstantExport,
1317
+ allowExportNames: [
1318
+ ...isUsingNext ? [
1319
+ "dynamic",
1320
+ "dynamicParams",
1321
+ "revalidate",
1322
+ "fetchCache",
1323
+ "runtime",
1324
+ "preferredRegion",
1325
+ "maxDuration",
1326
+ "config",
1327
+ "generateStaticParams",
1328
+ "metadata",
1329
+ "generateMetadata",
1330
+ "viewport",
1331
+ "generateViewport"
1332
+ ] : [],
1333
+ ...isUsingRemix || isUsingReactRouter ? [
1334
+ "meta",
1335
+ "links",
1336
+ "headers",
1337
+ "loader",
1338
+ "action"
1339
+ ] : []
1340
+ ]
1341
+ }
1342
+ ],
1343
+ // recommended rules from @eslint-react/web-api
1344
+ "react-web-api/no-leaked-event-listener": "warn",
1345
+ "react-web-api/no-leaked-interval": "warn",
1346
+ "react-web-api/no-leaked-resize-observer": "warn",
1347
+ "react-web-api/no-leaked-timeout": "warn",
1348
+ // recommended rules from @eslint-react
1349
+ "react/ensure-forward-ref-using-ref": "warn",
1350
+ "react/jsx-no-duplicate-props": "warn",
1351
+ "react/jsx-uses-vars": "warn",
1352
+ "react/no-access-state-in-setstate": "error",
1353
+ "react/no-array-index-key": "warn",
1354
+ "react/no-children-count": "warn",
1355
+ "react/no-children-for-each": "warn",
1356
+ "react/no-children-map": "warn",
1357
+ "react/no-children-only": "warn",
1358
+ "react/no-children-to-array": "warn",
1359
+ "react/no-clone-element": "warn",
1360
+ "react/no-comment-textnodes": "warn",
1361
+ "react/no-component-will-mount": "error",
1362
+ "react/no-component-will-receive-props": "error",
1363
+ "react/no-component-will-update": "error",
1364
+ "react/no-context-provider": "warn",
1365
+ "react/no-create-ref": "error",
1366
+ "react/no-default-props": "error",
1367
+ "react/no-direct-mutation-state": "error",
1368
+ "react/no-duplicate-key": "error",
1369
+ "react/no-forward-ref": "warn",
1370
+ "react/no-implicit-key": "warn",
1371
+ "react/no-missing-key": "error",
1372
+ "react/no-nested-components": "error",
1373
+ "react/no-prop-types": "error",
1374
+ "react/no-redundant-should-component-update": "error",
1375
+ "react/no-set-state-in-component-did-mount": "warn",
1376
+ "react/no-set-state-in-component-did-update": "warn",
1377
+ "react/no-set-state-in-component-will-update": "warn",
1378
+ "react/no-string-refs": "error",
1379
+ "react/no-unsafe-component-will-mount": "warn",
1380
+ "react/no-unsafe-component-will-receive-props": "warn",
1381
+ "react/no-unsafe-component-will-update": "warn",
1382
+ "react/no-unstable-context-value": "warn",
1383
+ "react/no-unstable-default-props": "warn",
1384
+ "react/no-unused-class-component-members": "warn",
1385
+ "react/no-unused-state": "warn",
1386
+ "react/prefer-destructuring-assignment": "warn",
1387
+ "react/prefer-shorthand-boolean": "warn",
1388
+ "react/prefer-shorthand-fragment": "warn",
1389
+ // overrides
1390
+ ...overrides
1391
+ }
1392
+ },
1393
+ ...isTypeAware ? [{
1394
+ files: filesTypeAware,
1395
+ ignores: ignoresTypeAware,
1396
+ name: "antfu/react/type-aware-rules",
1397
+ rules: {
1398
+ ...typeAwareRules
1399
+ }
1400
+ }] : []
1401
+ ];
1402
+ }
1403
+
1404
+ // src/configs/regexp.ts
1405
+ init_esm_shims();
1406
+ import { configs } from "eslint-plugin-regexp";
1407
+ async function regexp(options = {}) {
1408
+ const config = configs["flat/recommended"];
1409
+ const rules = {
1410
+ ...config.rules
1411
+ };
1412
+ if (options.level === "warn") {
1413
+ for (const key in rules) {
1414
+ if (rules[key] === "error")
1415
+ rules[key] = "warn";
1416
+ }
1417
+ }
1418
+ return [
1419
+ {
1420
+ ...config,
1421
+ name: "antfu/regexp/rules",
1422
+ rules: {
1423
+ ...rules,
1424
+ ...options.overrides
1425
+ }
1426
+ }
1427
+ ];
1428
+ }
1429
+
1430
+ // src/configs/solid.ts
1431
+ init_esm_shims();
1432
+ async function solid(options = {}) {
1433
+ const {
1434
+ files = [GLOB_JSX, GLOB_TSX],
1435
+ overrides = {},
1436
+ typescript: typescript2 = true
1437
+ } = options;
1438
+ await ensurePackages([
1439
+ "eslint-plugin-solid"
1440
+ ]);
1441
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1442
+ const isTypeAware = !!tsconfigPath;
1443
+ const [
1444
+ pluginSolid,
1445
+ parserTs
1446
+ ] = await Promise.all([
1447
+ interopDefault(import("./dist-MYXPM6TG.js")),
1448
+ interopDefault(import("@typescript-eslint/parser"))
1449
+ ]);
1450
+ return [
1451
+ {
1452
+ name: "antfu/solid/setup",
1453
+ plugins: {
1454
+ solid: pluginSolid
1455
+ }
1456
+ },
1457
+ {
1458
+ files,
1459
+ languageOptions: {
1460
+ parser: parserTs,
1461
+ parserOptions: {
1462
+ ecmaFeatures: {
1463
+ jsx: true
1464
+ },
1465
+ ...isTypeAware ? { project: tsconfigPath } : {}
1466
+ },
1467
+ sourceType: "module"
1468
+ },
1469
+ name: "antfu/solid/rules",
1470
+ rules: {
1471
+ // reactivity
1472
+ "solid/components-return-once": "warn",
1473
+ "solid/event-handlers": ["error", {
1474
+ // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
1475
+ ignoreCase: false,
1476
+ // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
1477
+ warnOnSpread: false
1478
+ }],
1479
+ // these rules are mostly style suggestions
1480
+ "solid/imports": "error",
1481
+ // identifier usage is important
1482
+ "solid/jsx-no-duplicate-props": "error",
1483
+ "solid/jsx-no-script-url": "error",
1484
+ "solid/jsx-no-undef": "error",
1485
+ "solid/jsx-uses-vars": "error",
1486
+ "solid/no-destructure": "error",
1487
+ // security problems
1488
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
1489
+ "solid/no-react-deps": "error",
1490
+ "solid/no-react-specific-props": "error",
1491
+ "solid/no-unknown-namespaces": "error",
1492
+ "solid/prefer-for": "error",
1493
+ "solid/reactivity": "warn",
1494
+ "solid/self-closing-comp": "error",
1495
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
1496
+ ...typescript2 ? {
1497
+ "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
1498
+ "solid/no-unknown-namespaces": "off"
1499
+ } : {},
1500
+ // overrides
1501
+ ...overrides
1502
+ }
1503
+ }
1504
+ ];
1505
+ }
1506
+
1507
+ // src/configs/sort.ts
1508
+ init_esm_shims();
1509
+ async function sortPackageJson() {
1510
+ return [
1511
+ {
1512
+ files: ["**/package.json"],
1513
+ name: "antfu/sort/package-json",
1514
+ rules: {
1515
+ "jsonc/sort-array-values": [
1516
+ "error",
1517
+ {
1518
+ order: { type: "asc" },
1519
+ pathPattern: "^files$"
1520
+ }
1521
+ ],
1522
+ "jsonc/sort-keys": [
1523
+ "error",
1524
+ {
1525
+ order: [
1526
+ "publisher",
1527
+ "name",
1528
+ "displayName",
1529
+ "type",
1530
+ "version",
1531
+ "private",
1532
+ "packageManager",
1533
+ "description",
1534
+ "author",
1535
+ "contributors",
1536
+ "license",
1537
+ "funding",
1538
+ "homepage",
1539
+ "repository",
1540
+ "bugs",
1541
+ "keywords",
1542
+ "categories",
1543
+ "sideEffects",
1544
+ "exports",
1545
+ "main",
1546
+ "module",
1547
+ "unpkg",
1548
+ "jsdelivr",
1549
+ "types",
1550
+ "typesVersions",
1551
+ "bin",
1552
+ "icon",
1553
+ "files",
1554
+ "engines",
1555
+ "activationEvents",
1556
+ "contributes",
1557
+ "scripts",
1558
+ "peerDependencies",
1559
+ "peerDependenciesMeta",
1560
+ "dependencies",
1561
+ "optionalDependencies",
1562
+ "devDependencies",
1563
+ "pnpm",
1564
+ "overrides",
1565
+ "resolutions",
1566
+ "husky",
1567
+ "simple-git-hooks",
1568
+ "lint-staged",
1569
+ "eslintConfig"
1570
+ ],
1571
+ pathPattern: "^$"
1572
+ },
1573
+ {
1574
+ order: { type: "asc" },
1575
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1576
+ },
1577
+ {
1578
+ order: { type: "asc" },
1579
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1580
+ },
1581
+ {
1582
+ order: [
1583
+ "types",
1584
+ "import",
1585
+ "require",
1586
+ "default"
1587
+ ],
1588
+ pathPattern: "^exports.*$"
1589
+ },
1590
+ {
1591
+ order: [
1592
+ // client hooks only
1593
+ "pre-commit",
1594
+ "prepare-commit-msg",
1595
+ "commit-msg",
1596
+ "post-commit",
1597
+ "pre-rebase",
1598
+ "post-rewrite",
1599
+ "post-checkout",
1600
+ "post-merge",
1601
+ "pre-push",
1602
+ "pre-auto-gc"
1603
+ ],
1604
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1605
+ }
1606
+ ]
1607
+ }
1608
+ }
1609
+ ];
1610
+ }
1611
+ function sortTsconfig() {
1612
+ return [
1613
+ {
1614
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1615
+ name: "antfu/sort/tsconfig-json",
1616
+ rules: {
1617
+ "jsonc/sort-keys": [
1618
+ "error",
1619
+ {
1620
+ order: [
1621
+ "extends",
1622
+ "compilerOptions",
1623
+ "references",
1624
+ "files",
1625
+ "include",
1626
+ "exclude"
1627
+ ],
1628
+ pathPattern: "^$"
1629
+ },
1630
+ {
1631
+ order: [
1632
+ /* Projects */
1633
+ "incremental",
1634
+ "composite",
1635
+ "tsBuildInfoFile",
1636
+ "disableSourceOfProjectReferenceRedirect",
1637
+ "disableSolutionSearching",
1638
+ "disableReferencedProjectLoad",
1639
+ /* Language and Environment */
1640
+ "target",
1641
+ "jsx",
1642
+ "jsxFactory",
1643
+ "jsxFragmentFactory",
1644
+ "jsxImportSource",
1645
+ "lib",
1646
+ "moduleDetection",
1647
+ "noLib",
1648
+ "reactNamespace",
1649
+ "useDefineForClassFields",
1650
+ "emitDecoratorMetadata",
1651
+ "experimentalDecorators",
1652
+ /* Modules */
1653
+ "baseUrl",
1654
+ "rootDir",
1655
+ "rootDirs",
1656
+ "customConditions",
1657
+ "module",
1658
+ "moduleResolution",
1659
+ "moduleSuffixes",
1660
+ "noResolve",
1661
+ "paths",
1662
+ "resolveJsonModule",
1663
+ "resolvePackageJsonExports",
1664
+ "resolvePackageJsonImports",
1665
+ "typeRoots",
1666
+ "types",
1667
+ "allowArbitraryExtensions",
1668
+ "allowImportingTsExtensions",
1669
+ "allowUmdGlobalAccess",
1670
+ /* JavaScript Support */
1671
+ "allowJs",
1672
+ "checkJs",
1673
+ "maxNodeModuleJsDepth",
1674
+ /* Type Checking */
1675
+ "strict",
1676
+ "strictBindCallApply",
1677
+ "strictFunctionTypes",
1678
+ "strictNullChecks",
1679
+ "strictPropertyInitialization",
1680
+ "allowUnreachableCode",
1681
+ "allowUnusedLabels",
1682
+ "alwaysStrict",
1683
+ "exactOptionalPropertyTypes",
1684
+ "noFallthroughCasesInSwitch",
1685
+ "noImplicitAny",
1686
+ "noImplicitOverride",
1687
+ "noImplicitReturns",
1688
+ "noImplicitThis",
1689
+ "noPropertyAccessFromIndexSignature",
1690
+ "noUncheckedIndexedAccess",
1691
+ "noUnusedLocals",
1692
+ "noUnusedParameters",
1693
+ "useUnknownInCatchVariables",
1694
+ /* Emit */
1695
+ "declaration",
1696
+ "declarationDir",
1697
+ "declarationMap",
1698
+ "downlevelIteration",
1699
+ "emitBOM",
1700
+ "emitDeclarationOnly",
1701
+ "importHelpers",
1702
+ "importsNotUsedAsValues",
1703
+ "inlineSourceMap",
1704
+ "inlineSources",
1705
+ "mapRoot",
1706
+ "newLine",
1707
+ "noEmit",
1708
+ "noEmitHelpers",
1709
+ "noEmitOnError",
1710
+ "outDir",
1711
+ "outFile",
1712
+ "preserveConstEnums",
1713
+ "preserveValueImports",
1714
+ "removeComments",
1715
+ "sourceMap",
1716
+ "sourceRoot",
1717
+ "stripInternal",
1718
+ /* Interop Constraints */
1719
+ "allowSyntheticDefaultImports",
1720
+ "esModuleInterop",
1721
+ "forceConsistentCasingInFileNames",
1722
+ "isolatedDeclarations",
1723
+ "isolatedModules",
1724
+ "preserveSymlinks",
1725
+ "verbatimModuleSyntax",
1726
+ /* Completeness */
1727
+ "skipDefaultLibCheck",
1728
+ "skipLibCheck"
1729
+ ],
1730
+ pathPattern: "^compilerOptions$"
1731
+ }
1732
+ ]
1733
+ }
1734
+ }
1735
+ ];
1736
+ }
1737
+
1738
+ // src/configs/svelte.ts
1739
+ init_esm_shims();
1740
+ async function svelte(options = {}) {
1741
+ const {
1742
+ files = [GLOB_SVELTE],
1743
+ overrides = {},
1744
+ stylistic: stylistic2 = true
1745
+ } = options;
1746
+ const {
1747
+ indent = 2,
1748
+ quotes = "single"
1749
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1750
+ await ensurePackages([
1751
+ "eslint-plugin-svelte"
1752
+ ]);
1753
+ const [
1754
+ pluginSvelte,
1755
+ parserSvelte
1756
+ ] = await Promise.all([
1757
+ interopDefault(import("./lib-7QWIUEWR.js")),
1758
+ interopDefault(import("./lib-47EDT2ZH.js"))
1759
+ ]);
1760
+ return [
1761
+ {
1762
+ name: "antfu/svelte/setup",
1763
+ plugins: {
1764
+ svelte: pluginSvelte
1765
+ }
1766
+ },
1767
+ {
1768
+ files,
1769
+ languageOptions: {
1770
+ parser: parserSvelte,
1771
+ parserOptions: {
1772
+ extraFileExtensions: [".svelte"],
1773
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1774
+ }
1775
+ },
1776
+ name: "antfu/svelte/rules",
1777
+ processor: pluginSvelte.processors[".svelte"],
1778
+ rules: {
1779
+ "import/no-mutable-exports": "off",
1780
+ "no-undef": "off",
1781
+ // incompatible with most recent (attribute-form) generic types RFC
1782
+ "no-unused-vars": ["error", {
1783
+ args: "none",
1784
+ caughtErrors: "none",
1785
+ ignoreRestSiblings: true,
1786
+ vars: "all",
1787
+ varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1788
+ }],
1789
+ "svelte/comment-directive": "error",
1790
+ "svelte/no-at-debug-tags": "warn",
1791
+ "svelte/no-at-html-tags": "error",
1792
+ "svelte/no-dupe-else-if-blocks": "error",
1793
+ "svelte/no-dupe-style-properties": "error",
1794
+ "svelte/no-dupe-use-directives": "error",
1795
+ "svelte/no-dynamic-slot-name": "error",
1796
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1797
+ "svelte/no-inner-declarations": "error",
1798
+ "svelte/no-not-function-handler": "error",
1799
+ "svelte/no-object-in-text-mustaches": "error",
1800
+ "svelte/no-reactive-functions": "error",
1801
+ "svelte/no-reactive-literals": "error",
1802
+ "svelte/no-shorthand-style-property-overrides": "error",
1803
+ "svelte/no-unknown-style-directive-property": "error",
1804
+ "svelte/no-unused-svelte-ignore": "error",
1805
+ "svelte/no-useless-mustaches": "error",
1806
+ "svelte/require-store-callbacks-use-set-param": "error",
1807
+ "svelte/system": "error",
1808
+ "svelte/valid-each-key": "error",
1809
+ "unused-imports/no-unused-vars": [
1810
+ "error",
1811
+ {
1812
+ args: "after-used",
1813
+ argsIgnorePattern: "^_",
1814
+ vars: "all",
1815
+ varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1816
+ }
1817
+ ],
1818
+ ...stylistic2 ? {
1819
+ "style/indent": "off",
1820
+ // superseded by svelte/indent
1821
+ "style/no-trailing-spaces": "off",
1822
+ // superseded by svelte/no-trailing-spaces
1823
+ "svelte/derived-has-same-inputs-outputs": "error",
1824
+ "svelte/html-closing-bracket-spacing": "error",
1825
+ "svelte/html-quotes": ["error", { prefer: quotes === "backtick" ? "double" : quotes }],
1826
+ "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1827
+ "svelte/mustache-spacing": "error",
1828
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1829
+ "svelte/no-trailing-spaces": "error",
1830
+ "svelte/spaced-html-comment": "error"
1831
+ } : {},
1832
+ ...overrides
1833
+ }
1834
+ }
1835
+ ];
1836
+ }
1837
+
1838
+ // src/configs/test.ts
1839
+ init_esm_shims();
1840
+ var _pluginTest;
1841
+ async function test(options = {}) {
1842
+ const {
1843
+ files = GLOB_TESTS,
1844
+ isInEditor = false,
1845
+ overrides = {}
1846
+ } = options;
1847
+ const [
1848
+ pluginVitest,
1849
+ pluginNoOnlyTests
1850
+ ] = await Promise.all([
1851
+ interopDefault(import("@vitest/eslint-plugin")),
1852
+ // @ts-expect-error missing types
1853
+ interopDefault(import("eslint-plugin-no-only-tests"))
1854
+ ]);
1855
+ _pluginTest = _pluginTest || {
1856
+ ...pluginVitest,
1857
+ rules: {
1858
+ ...pluginVitest.rules,
1859
+ // extend `test/no-only-tests` rule
1860
+ ...pluginNoOnlyTests.rules
1861
+ }
1862
+ };
1863
+ return [
1864
+ {
1865
+ name: "antfu/test/setup",
1866
+ plugins: {
1867
+ test: _pluginTest
1868
+ }
1869
+ },
1870
+ {
1871
+ files,
1872
+ name: "antfu/test/rules",
1873
+ rules: {
1874
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1875
+ "test/no-identical-title": "error",
1876
+ "test/no-import-node-test": "error",
1877
+ "test/no-only-tests": isInEditor ? "warn" : "error",
1878
+ "test/prefer-hooks-in-order": "error",
1879
+ "test/prefer-lowercase-title": "error",
1880
+ // Disables
1881
+ ...{
1882
+ "antfu/no-top-level-await": "off",
1883
+ "no-unused-expressions": "off",
1884
+ "node/prefer-global/process": "off",
1885
+ "ts/explicit-function-return-type": "off"
1886
+ },
1887
+ ...overrides
1888
+ }
1889
+ }
1890
+ ];
1891
+ }
1892
+
1893
+ // src/configs/toml.ts
1894
+ init_esm_shims();
1895
+ async function toml(options = {}) {
1896
+ const {
1897
+ files = [GLOB_TOML],
1898
+ overrides = {},
1899
+ stylistic: stylistic2 = true
1900
+ } = options;
1901
+ const {
1902
+ indent = 2
1903
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1904
+ const [
1905
+ pluginToml,
1906
+ parserToml
1907
+ ] = await Promise.all([
1908
+ interopDefault(import("eslint-plugin-toml")),
1909
+ interopDefault(import("toml-eslint-parser"))
1910
+ ]);
1911
+ return [
1912
+ {
1913
+ name: "antfu/toml/setup",
1914
+ plugins: {
1915
+ toml: pluginToml
1916
+ }
1917
+ },
1918
+ {
1919
+ files,
1920
+ languageOptions: {
1921
+ parser: parserToml
1922
+ },
1923
+ name: "antfu/toml/rules",
1924
+ rules: {
1925
+ "style/spaced-comment": "off",
1926
+ "toml/comma-style": "error",
1927
+ "toml/keys-order": "error",
1928
+ "toml/no-space-dots": "error",
1929
+ "toml/no-unreadable-number-separator": "error",
1930
+ "toml/precision-of-fractional-seconds": "error",
1931
+ "toml/precision-of-integer": "error",
1932
+ "toml/tables-order": "error",
1933
+ "toml/vue-custom-block/no-parsing-error": "error",
1934
+ ...stylistic2 ? {
1935
+ "toml/array-bracket-newline": "error",
1936
+ "toml/array-bracket-spacing": "error",
1937
+ "toml/array-element-newline": "error",
1938
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1939
+ "toml/inline-table-curly-spacing": "error",
1940
+ "toml/key-spacing": "error",
1941
+ "toml/padding-line-between-pairs": "error",
1942
+ "toml/padding-line-between-tables": "error",
1943
+ "toml/quoted-keys": "error",
1944
+ "toml/spaced-comment": "error",
1945
+ "toml/table-bracket-spacing": "error"
1946
+ } : {},
1947
+ ...overrides
1948
+ }
1949
+ }
1950
+ ];
1951
+ }
1952
+
1953
+ // src/configs/typescript.ts
1954
+ init_esm_shims();
1955
+ import process2 from "node:process";
1956
+ async function typescript(options = {}) {
1957
+ const {
1958
+ componentExts = [],
1959
+ overrides = {},
1960
+ overridesTypeAware = {},
1961
+ parserOptions = {},
1962
+ type = "app"
1963
+ } = options;
1964
+ const files = options.files ?? [
1965
+ GLOB_TS,
1966
+ GLOB_TSX,
1967
+ ...componentExts.map((ext) => `**/*.${ext}`)
1968
+ ];
1969
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1970
+ const ignoresTypeAware = options.ignoresTypeAware ?? [
1971
+ `${GLOB_MARKDOWN}/**`,
1972
+ GLOB_ASTRO_TS
1973
+ ];
1974
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1975
+ const isTypeAware = !!tsconfigPath;
1976
+ const typeAwareRules = {
1977
+ "dot-notation": "off",
1978
+ "no-implied-eval": "off",
1979
+ "ts/await-thenable": "error",
1980
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1981
+ "ts/no-floating-promises": "error",
1982
+ "ts/no-for-in-array": "error",
1983
+ "ts/no-implied-eval": "error",
1984
+ "ts/no-misused-promises": "error",
1985
+ "ts/no-unnecessary-type-assertion": "error",
1986
+ "ts/no-unsafe-argument": "error",
1987
+ "ts/no-unsafe-assignment": "error",
1988
+ "ts/no-unsafe-call": "error",
1989
+ "ts/no-unsafe-member-access": "error",
1990
+ "ts/no-unsafe-return": "error",
1991
+ "ts/promise-function-async": "error",
1992
+ "ts/restrict-plus-operands": "error",
1993
+ "ts/restrict-template-expressions": "error",
1994
+ "ts/return-await": ["error", "in-try-catch"],
1995
+ "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
1996
+ "ts/switch-exhaustiveness-check": "error",
1997
+ "ts/unbound-method": "error"
1998
+ };
1999
+ const [
2000
+ pluginTs,
2001
+ parserTs
2002
+ ] = await Promise.all([
2003
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
2004
+ interopDefault(import("@typescript-eslint/parser"))
2005
+ ]);
2006
+ function makeParser(typeAware, files2, ignores2) {
2007
+ return {
2008
+ files: files2,
2009
+ ...ignores2 ? { ignores: ignores2 } : {},
2010
+ languageOptions: {
2011
+ parser: parserTs,
2012
+ parserOptions: {
2013
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
2014
+ sourceType: "module",
2015
+ ...typeAware ? {
2016
+ projectService: {
2017
+ allowDefaultProject: ["./*.js"],
2018
+ defaultProject: tsconfigPath
2019
+ },
2020
+ tsconfigRootDir: process2.cwd()
2021
+ } : {},
2022
+ ...parserOptions
2023
+ }
2024
+ },
2025
+ name: `antfu/typescript/${typeAware ? "type-aware-parser" : "parser"}`
2026
+ };
2027
+ }
2028
+ return [
2029
+ {
2030
+ // Install the plugins without globs, so they can be configured separately.
2031
+ name: "antfu/typescript/setup",
2032
+ plugins: {
2033
+ antfu: default3,
2034
+ ts: pluginTs
2035
+ }
2036
+ },
2037
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
2038
+ ...isTypeAware ? [
2039
+ makeParser(false, files),
2040
+ makeParser(true, filesTypeAware, ignoresTypeAware)
2041
+ ] : [
2042
+ makeParser(false, files)
2043
+ ],
2044
+ {
2045
+ files,
2046
+ name: "antfu/typescript/rules",
2047
+ rules: {
2048
+ ...renameRules(
2049
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
2050
+ { "@typescript-eslint": "ts" }
2051
+ ),
2052
+ ...renameRules(
2053
+ pluginTs.configs.strict.rules,
2054
+ { "@typescript-eslint": "ts" }
2055
+ ),
2056
+ "no-dupe-class-members": "off",
2057
+ "no-redeclare": "off",
2058
+ "no-use-before-define": "off",
2059
+ "no-useless-constructor": "off",
2060
+ "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
2061
+ "ts/consistent-type-definitions": ["error", "interface"],
2062
+ "ts/consistent-type-imports": ["error", {
2063
+ disallowTypeAnnotations: false,
2064
+ fixStyle: "separate-type-imports",
2065
+ prefer: "type-imports"
2066
+ }],
2067
+ "ts/method-signature-style": ["error", "property"],
2068
+ // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
2069
+ "ts/no-dupe-class-members": "error",
2070
+ "ts/no-dynamic-delete": "off",
2071
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
2072
+ "ts/no-explicit-any": "off",
2073
+ "ts/no-extraneous-class": "off",
2074
+ "ts/no-import-type-side-effects": "error",
2075
+ "ts/no-invalid-void-type": "off",
2076
+ "ts/no-non-null-assertion": "off",
2077
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
2078
+ "ts/no-require-imports": "error",
2079
+ "ts/no-unused-expressions": ["error", {
2080
+ allowShortCircuit: true,
2081
+ allowTaggedTemplates: true,
2082
+ allowTernary: true
2083
+ }],
2084
+ "ts/no-unused-vars": "off",
2085
+ "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
2086
+ "ts/no-useless-constructor": "off",
2087
+ "ts/no-wrapper-object-types": "error",
2088
+ "ts/triple-slash-reference": "off",
2089
+ "ts/unified-signatures": "off",
2090
+ ...type === "lib" ? {
2091
+ "ts/explicit-function-return-type": ["error", {
2092
+ allowExpressions: true,
2093
+ allowHigherOrderFunctions: true,
2094
+ allowIIFEs: true
2095
+ }]
2096
+ } : {},
2097
+ ...overrides
2098
+ }
2099
+ },
2100
+ ...isTypeAware ? [{
2101
+ files: filesTypeAware,
2102
+ ignores: ignoresTypeAware,
2103
+ name: "antfu/typescript/rules-type-aware",
2104
+ rules: {
2105
+ ...typeAwareRules,
2106
+ ...overridesTypeAware
2107
+ }
2108
+ }] : []
2109
+ ];
2110
+ }
2111
+
2112
+ // src/configs/unicorn.ts
2113
+ init_esm_shims();
2114
+ async function unicorn(options = {}) {
2115
+ return [
2116
+ {
2117
+ name: "antfu/unicorn/rules",
2118
+ plugins: {
2119
+ unicorn: default6
2120
+ },
2121
+ rules: {
2122
+ ...options.allRecommended ? default6.configs["flat/recommended"].rules : {
2123
+ "unicorn/consistent-empty-array-spread": "error",
2124
+ "unicorn/error-message": "error",
2125
+ "unicorn/escape-case": "error",
2126
+ "unicorn/new-for-builtins": "error",
2127
+ "unicorn/no-instanceof-array": "error",
2128
+ "unicorn/no-new-array": "error",
2129
+ "unicorn/no-new-buffer": "error",
2130
+ "unicorn/number-literal-case": "error",
2131
+ "unicorn/prefer-dom-node-text-content": "error",
2132
+ "unicorn/prefer-includes": "error",
2133
+ "unicorn/prefer-node-protocol": "error",
2134
+ "unicorn/prefer-number-properties": "error",
2135
+ "unicorn/prefer-string-starts-ends-with": "error",
2136
+ "unicorn/prefer-type-error": "error",
2137
+ "unicorn/throw-new-error": "error"
2138
+ }
2139
+ }
2140
+ }
2141
+ ];
2142
+ }
2143
+
2144
+ // src/configs/unocss.ts
2145
+ init_esm_shims();
2146
+ async function unocss(options = {}) {
2147
+ const {
2148
+ attributify = true,
2149
+ strict = false
2150
+ } = options;
2151
+ await ensurePackages([
2152
+ "@unocss/eslint-plugin"
2153
+ ]);
2154
+ const [
2155
+ pluginUnoCSS
2156
+ ] = await Promise.all([
2157
+ interopDefault(import("@unocss/eslint-plugin"))
2158
+ ]);
2159
+ return [
2160
+ {
2161
+ name: "antfu/unocss",
2162
+ plugins: {
2163
+ unocss: pluginUnoCSS
2164
+ },
2165
+ rules: {
2166
+ "unocss/order": "warn",
2167
+ ...attributify ? {
2168
+ "unocss/order-attributify": "warn"
2169
+ } : {},
2170
+ ...strict ? {
2171
+ "unocss/blocklist": "error"
2172
+ } : {}
2173
+ }
2174
+ }
2175
+ ];
2176
+ }
2177
+
2178
+ // src/configs/vue.ts
2179
+ init_esm_shims();
2180
+ import { mergeProcessors as mergeProcessors2 } from "eslint-merge-processors";
2181
+ async function vue(options = {}) {
2182
+ const {
2183
+ files = [GLOB_VUE],
2184
+ overrides = {},
2185
+ stylistic: stylistic2 = true,
2186
+ vueVersion = 3
2187
+ } = options;
2188
+ const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2189
+ const {
2190
+ indent = 2
2191
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2192
+ const [
2193
+ pluginVue,
2194
+ parserVue,
2195
+ processorVueBlocks
2196
+ ] = await Promise.all([
2197
+ interopDefault(import("eslint-plugin-vue")),
2198
+ interopDefault(import("vue-eslint-parser")),
2199
+ interopDefault(import("eslint-processor-vue-blocks"))
2200
+ ]);
2201
+ return [
2202
+ {
2203
+ // This allows Vue plugin to work with auto imports
2204
+ // https://github.com/vuejs/eslint-plugin-vue/pull/2422
2205
+ languageOptions: {
2206
+ globals: {
2207
+ computed: "readonly",
2208
+ defineEmits: "readonly",
2209
+ defineExpose: "readonly",
2210
+ defineProps: "readonly",
2211
+ onMounted: "readonly",
2212
+ onUnmounted: "readonly",
2213
+ reactive: "readonly",
2214
+ ref: "readonly",
2215
+ shallowReactive: "readonly",
2216
+ shallowRef: "readonly",
2217
+ toRef: "readonly",
2218
+ toRefs: "readonly",
2219
+ watch: "readonly",
2220
+ watchEffect: "readonly"
2221
+ }
2222
+ },
2223
+ name: "antfu/vue/setup",
2224
+ plugins: {
2225
+ vue: pluginVue
2226
+ }
2227
+ },
2228
+ {
2229
+ files,
2230
+ languageOptions: {
2231
+ parser: parserVue,
2232
+ parserOptions: {
2233
+ ecmaFeatures: {
2234
+ jsx: true
2235
+ },
2236
+ extraFileExtensions: [".vue"],
2237
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
2238
+ sourceType: "module"
2239
+ }
2240
+ },
2241
+ name: "antfu/vue/rules",
2242
+ processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors2([
2243
+ pluginVue.processors[".vue"],
2244
+ processorVueBlocks({
2245
+ ...sfcBlocks,
2246
+ blocks: {
2247
+ styles: true,
2248
+ ...sfcBlocks.blocks
2249
+ }
2250
+ })
2251
+ ]),
2252
+ rules: {
2253
+ ...pluginVue.configs.base.rules,
2254
+ ...vueVersion === 2 ? {
2255
+ ...pluginVue.configs.essential.rules,
2256
+ ...pluginVue.configs["strongly-recommended"].rules,
2257
+ ...pluginVue.configs.recommended.rules
2258
+ } : {
2259
+ ...pluginVue.configs["vue3-essential"].rules,
2260
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
2261
+ ...pluginVue.configs["vue3-recommended"].rules
2262
+ },
2263
+ "antfu/no-top-level-await": "off",
2264
+ "node/prefer-global/process": "off",
2265
+ "ts/explicit-function-return-type": "off",
2266
+ "vue/block-order": ["error", {
2267
+ order: ["script", "template", "style"]
2268
+ }],
2269
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
2270
+ "vue/component-options-name-casing": ["error", "PascalCase"],
2271
+ // this is deprecated
2272
+ "vue/component-tags-order": "off",
2273
+ "vue/custom-event-name-casing": ["error", "camelCase"],
2274
+ "vue/define-macros-order": ["error", {
2275
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
2276
+ }],
2277
+ "vue/dot-location": ["error", "property"],
2278
+ "vue/dot-notation": ["error", { allowKeywords: true }],
2279
+ "vue/eqeqeq": ["error", "smart"],
2280
+ "vue/html-indent": ["error", indent],
2281
+ "vue/html-quotes": ["error", "double"],
2282
+ "vue/max-attributes-per-line": "off",
2283
+ "vue/multi-word-component-names": "off",
2284
+ "vue/no-dupe-keys": "off",
2285
+ "vue/no-empty-pattern": "error",
2286
+ "vue/no-irregular-whitespace": "error",
2287
+ "vue/no-loss-of-precision": "error",
2288
+ "vue/no-restricted-syntax": [
2289
+ "error",
2290
+ "DebuggerStatement",
2291
+ "LabeledStatement",
2292
+ "WithStatement"
2293
+ ],
2294
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
2295
+ "vue/no-setup-props-reactivity-loss": "off",
2296
+ "vue/no-sparse-arrays": "error",
2297
+ "vue/no-unused-refs": "error",
2298
+ "vue/no-useless-v-bind": "error",
2299
+ "vue/no-v-html": "off",
2300
+ "vue/object-shorthand": [
2301
+ "error",
2302
+ "always",
2303
+ {
2304
+ avoidQuotes: true,
2305
+ ignoreConstructors: false
2306
+ }
2307
+ ],
2308
+ "vue/prefer-separate-static-class": "error",
2309
+ "vue/prefer-template": "error",
2310
+ "vue/prop-name-casing": ["error", "camelCase"],
2311
+ "vue/require-default-prop": "off",
2312
+ "vue/require-prop-types": "off",
2313
+ "vue/space-infix-ops": "error",
2314
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
2315
+ ...stylistic2 ? {
2316
+ "vue/array-bracket-spacing": ["error", "never"],
2317
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
2318
+ "vue/block-spacing": ["error", "always"],
2319
+ "vue/block-tag-newline": ["error", {
2320
+ multiline: "always",
2321
+ singleline: "always"
2322
+ }],
2323
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
2324
+ "vue/comma-dangle": ["error", "always-multiline"],
2325
+ "vue/comma-spacing": ["error", { after: true, before: false }],
2326
+ "vue/comma-style": ["error", "last"],
2327
+ "vue/html-comment-content-spacing": ["error", "always", {
2328
+ exceptions: ["-"]
2329
+ }],
2330
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
2331
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
2332
+ "vue/object-curly-newline": "off",
2333
+ "vue/object-curly-spacing": ["error", "always"],
2334
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
2335
+ "vue/operator-linebreak": ["error", "before"],
2336
+ "vue/padding-line-between-blocks": ["error", "always"],
2337
+ "vue/quote-props": ["error", "consistent-as-needed"],
2338
+ "vue/space-in-parens": ["error", "never"],
2339
+ "vue/template-curly-spacing": "error"
2340
+ } : {},
2341
+ ...overrides
2342
+ }
2343
+ }
2344
+ ];
2345
+ }
2346
+
2347
+ // src/configs/yaml.ts
2348
+ init_esm_shims();
2349
+ async function yaml(options = {}) {
2350
+ const {
2351
+ files = [GLOB_YAML],
2352
+ overrides = {},
2353
+ stylistic: stylistic2 = true
2354
+ } = options;
2355
+ const {
2356
+ indent = 2,
2357
+ quotes = "single"
2358
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2359
+ const [
2360
+ pluginYaml,
2361
+ parserYaml
2362
+ ] = await Promise.all([
2363
+ interopDefault(import("eslint-plugin-yml")),
2364
+ interopDefault(import("yaml-eslint-parser"))
2365
+ ]);
2366
+ return [
2367
+ {
2368
+ name: "antfu/yaml/setup",
2369
+ plugins: {
2370
+ yaml: pluginYaml
2371
+ }
2372
+ },
2373
+ {
2374
+ files,
2375
+ languageOptions: {
2376
+ parser: parserYaml
2377
+ },
2378
+ name: "antfu/yaml/rules",
2379
+ rules: {
2380
+ "style/spaced-comment": "off",
2381
+ "yaml/block-mapping": "error",
2382
+ "yaml/block-sequence": "error",
2383
+ "yaml/no-empty-key": "error",
2384
+ "yaml/no-empty-sequence-entry": "error",
2385
+ "yaml/no-irregular-whitespace": "error",
2386
+ "yaml/plain-scalar": "error",
2387
+ "yaml/vue-custom-block/no-parsing-error": "error",
2388
+ ...stylistic2 ? {
2389
+ "yaml/block-mapping-question-indicator-newline": "error",
2390
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
2391
+ "yaml/flow-mapping-curly-newline": "error",
2392
+ "yaml/flow-mapping-curly-spacing": "error",
2393
+ "yaml/flow-sequence-bracket-newline": "error",
2394
+ "yaml/flow-sequence-bracket-spacing": "error",
2395
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2396
+ "yaml/key-spacing": "error",
2397
+ "yaml/no-tab-indent": "error",
2398
+ "yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
2399
+ "yaml/spaced-comment": "error"
2400
+ } : {},
2401
+ ...overrides
2402
+ }
2403
+ }
2404
+ ];
2405
+ }
2406
+
2407
+ // src/factory.ts
2408
+ var flatConfigProps = [
2409
+ "name",
2410
+ "languageOptions",
2411
+ "linterOptions",
2412
+ "processor",
2413
+ "plugins",
2414
+ "rules",
2415
+ "settings"
2416
+ ];
2417
+ var VuePackages = [
2418
+ "vue",
2419
+ "nuxt",
2420
+ "vitepress",
2421
+ "@slidev/cli"
2422
+ ];
2423
+ var defaultPluginRenaming = {
2424
+ "@eslint-react": "react",
2425
+ "@eslint-react/dom": "react-dom",
2426
+ "@eslint-react/hooks-extra": "react-hooks-extra",
2427
+ "@eslint-react/naming-convention": "react-naming-convention",
2428
+ "@stylistic": "style",
2429
+ "@typescript-eslint": "ts",
2430
+ "import-x": "import",
2431
+ "n": "node",
2432
+ "vitest": "test",
2433
+ "yml": "yaml"
2434
+ };
2435
+ function antfu(options = {}, ...userConfigs) {
2436
+ const {
2437
+ astro: enableAstro = false,
2438
+ autoRenamePlugins = true,
2439
+ componentExts = [],
2440
+ gitignore: enableGitignore = true,
2441
+ jsx: enableJsx = true,
2442
+ react: enableReact = false,
2443
+ regexp: enableRegexp = true,
2444
+ solid: enableSolid = false,
2445
+ svelte: enableSvelte = false,
2446
+ typescript: enableTypeScript = isPackageExists4("typescript"),
2447
+ unicorn: enableUnicorn = true,
2448
+ unocss: enableUnoCSS = false,
2449
+ vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
2450
+ } = options;
2451
+ let isInEditor = options.isInEditor;
2452
+ if (isInEditor == null) {
2453
+ isInEditor = isInEditorEnv();
2454
+ if (isInEditor)
2455
+ console.log("[@whoj/eslint-config] Detected running in editor, some rules are disabled.");
2456
+ }
2457
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2458
+ if (stylisticOptions && !("jsx" in stylisticOptions))
2459
+ stylisticOptions.jsx = enableJsx;
2460
+ const configs2 = [];
2461
+ if (enableGitignore) {
2462
+ if (typeof enableGitignore !== "boolean") {
2463
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2464
+ name: "antfu/gitignore",
2465
+ ...enableGitignore
2466
+ })]));
2467
+ } else {
2468
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2469
+ name: "antfu/gitignore",
2470
+ strict: false
2471
+ })]));
2472
+ }
2473
+ }
2474
+ const typescriptOptions = resolveSubOptions(options, "typescript");
2475
+ const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2476
+ configs2.push(
2477
+ ignores(options.ignores),
2478
+ javascript({
2479
+ isInEditor,
2480
+ overrides: getOverrides(options, "javascript")
2481
+ }),
2482
+ comments(),
2483
+ node(),
2484
+ jsdoc({
2485
+ stylistic: stylisticOptions
2486
+ }),
2487
+ imports({
2488
+ stylistic: stylisticOptions
2489
+ }),
2490
+ command(),
2491
+ // Optional plugins (installed but not enabled by default)
2492
+ perfectionist()
2493
+ );
2494
+ if (enableUnicorn) {
2495
+ configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2496
+ }
2497
+ if (enableVue) {
2498
+ componentExts.push("vue");
2499
+ }
2500
+ if (enableJsx) {
2501
+ configs2.push(jsx());
2502
+ }
2503
+ if (enableTypeScript) {
2504
+ configs2.push(typescript({
2505
+ ...typescriptOptions,
2506
+ componentExts,
2507
+ overrides: getOverrides(options, "typescript"),
2508
+ type: options.type
2509
+ }));
2510
+ }
2511
+ if (stylisticOptions) {
2512
+ configs2.push(stylistic({
2513
+ ...stylisticOptions,
2514
+ lessOpinionated: options.lessOpinionated,
2515
+ overrides: getOverrides(options, "stylistic")
2516
+ }));
2517
+ }
2518
+ if (enableRegexp) {
2519
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2520
+ }
2521
+ if (options.test ?? true) {
2522
+ configs2.push(test({
2523
+ isInEditor,
2524
+ overrides: getOverrides(options, "test")
2525
+ }));
2526
+ }
2527
+ if (enableVue) {
2528
+ configs2.push(vue({
2529
+ ...resolveSubOptions(options, "vue"),
2530
+ overrides: getOverrides(options, "vue"),
2531
+ stylistic: stylisticOptions,
2532
+ typescript: !!enableTypeScript
2533
+ }));
2534
+ }
2535
+ if (enableReact) {
2536
+ configs2.push(react({
2537
+ ...typescriptOptions,
2538
+ overrides: getOverrides(options, "react"),
2539
+ tsconfigPath
2540
+ }));
2541
+ }
2542
+ if (enableSolid) {
2543
+ configs2.push(solid({
2544
+ overrides: getOverrides(options, "solid"),
2545
+ tsconfigPath,
2546
+ typescript: !!enableTypeScript
2547
+ }));
2548
+ }
2549
+ if (enableSvelte) {
2550
+ configs2.push(svelte({
2551
+ overrides: getOverrides(options, "svelte"),
2552
+ stylistic: stylisticOptions,
2553
+ typescript: !!enableTypeScript
2554
+ }));
2555
+ }
2556
+ if (enableUnoCSS) {
2557
+ configs2.push(unocss({
2558
+ ...resolveSubOptions(options, "unocss"),
2559
+ overrides: getOverrides(options, "unocss")
2560
+ }));
2561
+ }
2562
+ if (enableAstro) {
2563
+ configs2.push(astro({
2564
+ overrides: getOverrides(options, "astro"),
2565
+ stylistic: stylisticOptions
2566
+ }));
2567
+ }
2568
+ if (options.jsonc ?? true) {
2569
+ configs2.push(
2570
+ jsonc({
2571
+ overrides: getOverrides(options, "jsonc"),
2572
+ stylistic: stylisticOptions
2573
+ }),
2574
+ sortPackageJson(),
2575
+ sortTsconfig()
2576
+ );
2577
+ }
2578
+ if (options.yaml ?? true) {
2579
+ configs2.push(yaml({
2580
+ overrides: getOverrides(options, "yaml"),
2581
+ stylistic: stylisticOptions
2582
+ }));
2583
+ }
2584
+ if (options.toml ?? true) {
2585
+ configs2.push(toml({
2586
+ overrides: getOverrides(options, "toml"),
2587
+ stylistic: stylisticOptions
2588
+ }));
2589
+ }
2590
+ if (options.markdown ?? true) {
2591
+ configs2.push(
2592
+ markdown(
2593
+ {
2594
+ componentExts,
2595
+ overrides: getOverrides(options, "markdown")
2596
+ }
2597
+ )
2598
+ );
2599
+ }
2600
+ if (options.formatters) {
2601
+ configs2.push(formatters(
2602
+ options.formatters,
2603
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2604
+ ));
2605
+ }
2606
+ configs2.push(
2607
+ disables()
2608
+ );
2609
+ if ("files" in options) {
2610
+ throw new Error('[@whoj/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
2611
+ }
2612
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
2613
+ if (key in options)
2614
+ acc[key] = options[key];
2615
+ return acc;
2616
+ }, {});
2617
+ if (Object.keys(fusedConfig).length)
2618
+ configs2.push([fusedConfig]);
2619
+ let composer = new FlatConfigComposer();
2620
+ composer = composer.append(
2621
+ ...configs2,
2622
+ ...userConfigs
2623
+ );
2624
+ if (autoRenamePlugins) {
2625
+ composer = composer.renamePlugins(defaultPluginRenaming);
2626
+ }
2627
+ if (isInEditor) {
2628
+ composer = composer.disableRulesFix([
2629
+ "unused-imports/no-unused-imports",
2630
+ "test/no-only-tests",
2631
+ "prefer-const"
2632
+ ], {
2633
+ builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules)
2634
+ });
2635
+ }
2636
+ return composer;
2637
+ }
2638
+ function resolveSubOptions(options, key) {
2639
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
2640
+ }
2641
+ function getOverrides(options, key) {
2642
+ const sub = resolveSubOptions(options, key);
2643
+ return {
2644
+ ...options.overrides?.[key],
2645
+ ..."overrides" in sub ? sub.overrides : {}
2646
+ };
2647
+ }
2648
+
2649
+ // src/types.ts
2650
+ init_esm_shims();
2651
+
2652
+ // src/index.ts
2653
+ var index_default = antfu;
2654
+ export {
2655
+ GLOB_ALL_SRC,
2656
+ GLOB_ASTRO,
2657
+ GLOB_ASTRO_TS,
2658
+ GLOB_CSS,
2659
+ GLOB_EXCLUDE,
2660
+ GLOB_GRAPHQL,
2661
+ GLOB_HTML,
2662
+ GLOB_JS,
2663
+ GLOB_JSON,
2664
+ GLOB_JSON5,
2665
+ GLOB_JSONC,
2666
+ GLOB_JSX,
2667
+ GLOB_LESS,
2668
+ GLOB_MARKDOWN,
2669
+ GLOB_MARKDOWN_CODE,
2670
+ GLOB_MARKDOWN_IN_MARKDOWN,
2671
+ GLOB_POSTCSS,
2672
+ GLOB_SCSS,
2673
+ GLOB_SRC,
2674
+ GLOB_SRC_EXT,
2675
+ GLOB_STYLE,
2676
+ GLOB_SVELTE,
2677
+ GLOB_SVG,
2678
+ GLOB_TESTS,
2679
+ GLOB_TOML,
2680
+ GLOB_TS,
2681
+ GLOB_TSX,
2682
+ GLOB_VUE,
2683
+ GLOB_XML,
2684
+ GLOB_YAML,
2685
+ StylisticConfigDefaults,
2686
+ antfu,
2687
+ astro,
2688
+ combine,
2689
+ command,
2690
+ comments,
2691
+ index_default as default,
2692
+ defaultPluginRenaming,
2693
+ disables,
2694
+ ensurePackages,
2695
+ formatters,
2696
+ getOverrides,
2697
+ ignores,
2698
+ imports,
2699
+ interopDefault,
2700
+ isInEditorEnv,
2701
+ isInGitHooksOrLintStaged,
2702
+ isPackageInScope,
2703
+ javascript,
2704
+ jsdoc,
2705
+ jsonc,
2706
+ jsx,
2707
+ markdown,
2708
+ node,
2709
+ parserPlain,
2710
+ perfectionist,
2711
+ react,
2712
+ regexp,
2713
+ renamePluginInConfigs,
2714
+ renameRules,
2715
+ resolveSubOptions,
2716
+ solid,
2717
+ sortPackageJson,
2718
+ sortTsconfig,
2719
+ stylistic,
2720
+ svelte,
2721
+ test,
2722
+ toArray,
2723
+ toml,
2724
+ typescript,
2725
+ unicorn,
2726
+ unocss,
2727
+ vue,
2728
+ yaml
2729
+ };