@ghettoddos/eslint-config 1.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,1991 @@
1
+ // src/factory.ts
2
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
3
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
4
+
5
+ // src/plugins.ts
6
+ import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
7
+ import * as pluginImport from "eslint-plugin-import-x";
8
+ import { default as default3 } from "eslint-plugin-n";
9
+ import { default as default4 } from "eslint-plugin-perfectionist";
10
+ import { default as default5 } from "eslint-plugin-unicorn";
11
+ import { default as default6 } from "eslint-plugin-unused-imports";
12
+
13
+ // src/configs/comments.ts
14
+ async function comments() {
15
+ return [
16
+ {
17
+ name: "eslint-comments/rules",
18
+ plugins: {
19
+ "eslint-comments": default2
20
+ },
21
+ rules: {
22
+ "eslint-comments/no-aggregating-enable": "error",
23
+ "eslint-comments/no-duplicate-disable": "error",
24
+ "eslint-comments/no-unlimited-disable": "error",
25
+ "eslint-comments/no-unused-enable": "error"
26
+ }
27
+ }
28
+ ];
29
+ }
30
+
31
+ // src/globs.ts
32
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
33
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
34
+ var GLOB_JS = "**/*.?([cm])js";
35
+ var GLOB_JSX = "**/*.?([cm])jsx";
36
+ var GLOB_TS = "**/*.?([cm])ts";
37
+ var GLOB_TSX = "**/*.?([cm])tsx";
38
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
39
+ var GLOB_CSS = "**/*.css";
40
+ var GLOB_POSTCSS = "**/*.{p,post}css";
41
+ var GLOB_SCSS = "**/*.scss";
42
+ var GLOB_JSON = "**/*.json";
43
+ var GLOB_JSON5 = "**/*.json5";
44
+ var GLOB_JSONC = "**/*.jsonc";
45
+ var GLOB_MARKDOWN = "**/*.md";
46
+ var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
47
+ var GLOB_YAML = "**/*.y?(a)ml";
48
+ var GLOB_TOML = "**/*.toml";
49
+ var GLOB_XML = "**/*.xml";
50
+ var GLOB_SVG = "**/*.svg";
51
+ var GLOB_HTML = "**/*.htm?(l)";
52
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
53
+ var GLOB_ALL_SRC = [
54
+ GLOB_SRC,
55
+ GLOB_STYLE,
56
+ GLOB_JSON,
57
+ GLOB_JSON5,
58
+ GLOB_MARKDOWN,
59
+ GLOB_YAML,
60
+ GLOB_XML,
61
+ GLOB_HTML
62
+ ];
63
+ var GLOB_EXCLUDE = [
64
+ "**/node_modules",
65
+ "**/dist",
66
+ "**/package-lock.json",
67
+ "**/yarn.lock",
68
+ "**/pnpm-lock.yaml",
69
+ "**/bun.lockb",
70
+ "**/output",
71
+ "**/coverage",
72
+ "**/temp",
73
+ "**/.temp",
74
+ "**/tmp",
75
+ "**/.tmp",
76
+ "**/.history",
77
+ "**/.vitepress/cache",
78
+ "**/.nuxt",
79
+ "**/.next",
80
+ "**/.svelte-kit",
81
+ "**/.vercel",
82
+ "**/.changeset",
83
+ "**/.idea",
84
+ "**/.cache",
85
+ "**/.output",
86
+ "**/.vite-inspect",
87
+ "**/.yarn",
88
+ "**/vite.config.*.timestamp-*",
89
+ "**/CHANGELOG*.md",
90
+ "**/*.min.*",
91
+ "**/LICENSE*",
92
+ "**/__snapshots__",
93
+ "**/auto-import?(s).d.ts",
94
+ "**/components.d.ts"
95
+ ];
96
+
97
+ // src/configs/disables.ts
98
+ async function disables() {
99
+ return [
100
+ {
101
+ files: [`**/scripts/${GLOB_SRC}`],
102
+ name: "disables/scripts",
103
+ rules: {
104
+ "no-console": "off",
105
+ "ts/explicit-function-return-type": "off"
106
+ }
107
+ },
108
+ {
109
+ files: ["**/*.d.?([cm])ts"],
110
+ name: "disables/dts",
111
+ rules: {
112
+ "eslint-comments/no-unlimited-disable": "off",
113
+ "import/no-duplicates": "off",
114
+ "no-restricted-syntax": "off",
115
+ "unused-imports/no-unused-vars": "off"
116
+ }
117
+ },
118
+ {
119
+ files: ["**/*.js", "**/*.cjs"],
120
+ name: "disables/cjs",
121
+ rules: {
122
+ "ts/no-require-imports": "off"
123
+ }
124
+ }
125
+ ];
126
+ }
127
+
128
+ // src/utils.ts
129
+ import process from "node:process";
130
+ import { fileURLToPath } from "node:url";
131
+ import { isPackageExists } from "local-pkg";
132
+ var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
133
+ var isCwdInScope = isPackageExists("@ghettoddos/eslint-config");
134
+ var parserPlain = {
135
+ meta: {
136
+ name: "parser-plain"
137
+ },
138
+ parseForESLint: (code) => ({
139
+ ast: {
140
+ body: [],
141
+ comments: [],
142
+ loc: { end: code.length, start: 0 },
143
+ range: [0, code.length],
144
+ tokens: [],
145
+ type: "Program"
146
+ },
147
+ scopeManager: null,
148
+ services: { isPlain: true },
149
+ visitorKeys: {
150
+ Program: []
151
+ }
152
+ })
153
+ };
154
+ async function combine(...configs2) {
155
+ const resolved = await Promise.all(configs2);
156
+ return resolved.flat();
157
+ }
158
+ function renameRules(rules, map) {
159
+ return Object.fromEntries(
160
+ Object.entries(rules).map(([key, value]) => {
161
+ for (const [from, to] of Object.entries(map)) {
162
+ if (key.startsWith(`${from}/`)) {
163
+ return [to + key.slice(from.length), value];
164
+ }
165
+ }
166
+ return [key, value];
167
+ })
168
+ );
169
+ }
170
+ async function interopDefault(m) {
171
+ const resolved = await m;
172
+ return resolved.default || resolved;
173
+ }
174
+ function isPackageInScope(name) {
175
+ return isPackageExists(name, { paths: [scopeUrl] });
176
+ }
177
+ async function ensurePackages(packages) {
178
+ if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) {
179
+ return;
180
+ }
181
+ const nonExistingPackages = packages.filter(
182
+ (i) => i && !isPackageInScope(i)
183
+ );
184
+ if (nonExistingPackages.length === 0) {
185
+ return;
186
+ }
187
+ const p = await import("@clack/prompts");
188
+ const result = await p.confirm({
189
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(
190
+ ", "
191
+ )}. Do you want to install them?`
192
+ });
193
+ if (result) {
194
+ await import("@antfu/install-pkg").then(
195
+ (i) => i.installPackage(nonExistingPackages, { dev: true })
196
+ );
197
+ }
198
+ }
199
+ function isInEditorEnv() {
200
+ if (process.env.CI) {
201
+ return false;
202
+ }
203
+ if (isInGitHooksOrLintStaged()) {
204
+ return false;
205
+ }
206
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
207
+ }
208
+ function isInGitHooksOrLintStaged() {
209
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
210
+ }
211
+
212
+ // src/configs/stylistic.ts
213
+ var StylisticConfigDefaults = {
214
+ indent: 2,
215
+ jsx: true,
216
+ quotes: "single",
217
+ semi: false
218
+ };
219
+ async function stylistic(options = {}) {
220
+ const {
221
+ indent,
222
+ jsx: jsx2,
223
+ overrides = {},
224
+ quotes,
225
+ semi
226
+ } = {
227
+ ...StylisticConfigDefaults,
228
+ ...options
229
+ };
230
+ const pluginStylistic = await interopDefault(
231
+ import("@stylistic/eslint-plugin")
232
+ );
233
+ const config2 = pluginStylistic.configs.customize({
234
+ indent,
235
+ jsx: jsx2,
236
+ pluginName: "style",
237
+ quotes,
238
+ semi
239
+ });
240
+ return [
241
+ {
242
+ name: "stylistic/rules",
243
+ plugins: {
244
+ style: pluginStylistic
245
+ },
246
+ rules: {
247
+ ...config2.rules,
248
+ "curly": ["error", "all"],
249
+ "style/generator-star-spacing": [
250
+ "error",
251
+ { after: true, before: false }
252
+ ],
253
+ "style/yield-star-spacing": ["error", { after: true, before: false }],
254
+ ...overrides
255
+ }
256
+ }
257
+ ];
258
+ }
259
+
260
+ // src/configs/formatters.ts
261
+ function mergePrettierOptions(options, overrides = {}) {
262
+ return {
263
+ ...options,
264
+ ...overrides,
265
+ plugins: [...overrides.plugins || [], ...options.plugins || []]
266
+ };
267
+ }
268
+ async function formatters(options = {}, stylistic2 = {}) {
269
+ if (options === true) {
270
+ const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
271
+ options = {
272
+ css: true,
273
+ html: true,
274
+ markdown: true,
275
+ svg: isPrettierPluginXmlInScope,
276
+ xml: isPrettierPluginXmlInScope
277
+ };
278
+ }
279
+ await ensurePackages([
280
+ "eslint-plugin-format",
281
+ options.xml || options.svg ? "@prettier/plugin-xml" : void 0
282
+ ]);
283
+ const { indent, quotes, semi } = {
284
+ ...StylisticConfigDefaults,
285
+ ...stylistic2
286
+ };
287
+ const prettierOptions = Object.assign(
288
+ {
289
+ endOfLine: "auto",
290
+ printWidth: 120,
291
+ semi,
292
+ singleQuote: quotes === "single",
293
+ tabWidth: typeof indent === "number" ? indent : 2,
294
+ trailingComma: "all",
295
+ useTabs: indent === "tab"
296
+ },
297
+ options.prettierOptions || {}
298
+ );
299
+ const prettierXmlOptions = {
300
+ xmlQuoteAttributes: "double",
301
+ xmlSelfClosingSpace: true,
302
+ xmlSortAttributesByKey: false,
303
+ xmlWhitespaceSensitivity: "ignore"
304
+ };
305
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
306
+ const configs2 = [
307
+ {
308
+ name: "formatter/setup",
309
+ plugins: {
310
+ format: pluginFormat
311
+ }
312
+ }
313
+ ];
314
+ if (options.css) {
315
+ configs2.push(
316
+ {
317
+ files: [GLOB_CSS, GLOB_POSTCSS],
318
+ languageOptions: {
319
+ parser: parserPlain
320
+ },
321
+ name: "formatter/css",
322
+ rules: {
323
+ "format/prettier": [
324
+ "error",
325
+ mergePrettierOptions(prettierOptions, {
326
+ parser: "css"
327
+ })
328
+ ]
329
+ }
330
+ },
331
+ {
332
+ files: [GLOB_SCSS],
333
+ languageOptions: {
334
+ parser: parserPlain
335
+ },
336
+ name: "formatter/scss",
337
+ rules: {
338
+ "format/prettier": [
339
+ "error",
340
+ mergePrettierOptions(prettierOptions, {
341
+ parser: "scss"
342
+ })
343
+ ]
344
+ }
345
+ }
346
+ );
347
+ }
348
+ if (options.html) {
349
+ configs2.push({
350
+ files: [GLOB_HTML],
351
+ languageOptions: {
352
+ parser: parserPlain
353
+ },
354
+ name: "formatter/html",
355
+ rules: {
356
+ "format/prettier": [
357
+ "error",
358
+ mergePrettierOptions(prettierOptions, {
359
+ parser: "html"
360
+ })
361
+ ]
362
+ }
363
+ });
364
+ }
365
+ if (options.xml) {
366
+ configs2.push({
367
+ files: [GLOB_XML],
368
+ languageOptions: {
369
+ parser: parserPlain
370
+ },
371
+ name: "formatter/xml",
372
+ rules: {
373
+ "format/prettier": [
374
+ "error",
375
+ mergePrettierOptions(
376
+ { ...prettierXmlOptions, ...prettierOptions },
377
+ {
378
+ parser: "xml",
379
+ plugins: ["@prettier/plugin-xml"]
380
+ }
381
+ )
382
+ ]
383
+ }
384
+ });
385
+ }
386
+ if (options.svg) {
387
+ configs2.push({
388
+ files: [GLOB_SVG],
389
+ languageOptions: {
390
+ parser: parserPlain
391
+ },
392
+ name: "formatter/svg",
393
+ rules: {
394
+ "format/prettier": [
395
+ "error",
396
+ mergePrettierOptions(
397
+ { ...prettierXmlOptions, ...prettierOptions },
398
+ {
399
+ parser: "xml",
400
+ plugins: ["@prettier/plugin-xml"]
401
+ }
402
+ )
403
+ ]
404
+ }
405
+ });
406
+ }
407
+ if (options.markdown) {
408
+ configs2.push({
409
+ files: [GLOB_MARKDOWN],
410
+ languageOptions: {
411
+ parser: parserPlain
412
+ },
413
+ name: "formatter/markdown",
414
+ rules: {
415
+ "format/prettier": [
416
+ "error",
417
+ mergePrettierOptions(prettierOptions, {
418
+ embeddedLanguageFormatting: "off",
419
+ parser: "markdown"
420
+ })
421
+ ]
422
+ }
423
+ });
424
+ }
425
+ return configs2;
426
+ }
427
+
428
+ // src/configs/ignores.ts
429
+ async function ignores(userIgnores = []) {
430
+ return [
431
+ {
432
+ ignores: [...GLOB_EXCLUDE, ...userIgnores],
433
+ name: "ignores"
434
+ }
435
+ ];
436
+ }
437
+
438
+ // src/configs/imports.ts
439
+ async function imports(options = {}) {
440
+ const { stylistic: stylistic2 = true } = options;
441
+ return [
442
+ {
443
+ name: "imports/rules",
444
+ plugins: {
445
+ import: pluginImport
446
+ },
447
+ rules: {
448
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
449
+ "import/first": "error",
450
+ "import/no-duplicates": "error",
451
+ "import/no-mutable-exports": "error",
452
+ "import/no-named-default": "error",
453
+ "import/no-self-import": "error",
454
+ "import/no-webpack-loader-syntax": "error",
455
+ ...stylistic2 ? {
456
+ "import/newline-after-import": ["error", { count: 1 }]
457
+ } : {}
458
+ }
459
+ }
460
+ ];
461
+ }
462
+
463
+ // src/configs/javascript.ts
464
+ import globals from "globals";
465
+ async function javascript(options = {}) {
466
+ const { isInEditor = false, overrides = {} } = options;
467
+ return [
468
+ {
469
+ languageOptions: {
470
+ ecmaVersion: 2022,
471
+ globals: {
472
+ ...globals.browser,
473
+ ...globals.es2021,
474
+ ...globals.node,
475
+ document: "readonly",
476
+ navigator: "readonly",
477
+ window: "readonly"
478
+ },
479
+ parserOptions: {
480
+ ecmaFeatures: {
481
+ jsx: true
482
+ },
483
+ ecmaVersion: 2022,
484
+ sourceType: "module"
485
+ },
486
+ sourceType: "module"
487
+ },
488
+ linterOptions: {
489
+ reportUnusedDisableDirectives: true
490
+ },
491
+ name: "javascript/setup"
492
+ },
493
+ {
494
+ name: "javascript/rules",
495
+ plugins: {
496
+ "unused-imports": default6
497
+ },
498
+ rules: {
499
+ "accessor-pairs": [
500
+ "error",
501
+ { enforceForClassMembers: true, setWithoutGet: true }
502
+ ],
503
+ "array-callback-return": "error",
504
+ "block-scoped-var": "error",
505
+ "constructor-super": "error",
506
+ "default-case-last": "error",
507
+ "dot-notation": ["error", { allowKeywords: true }],
508
+ "eqeqeq": ["error", "smart"],
509
+ "new-cap": [
510
+ "error",
511
+ { capIsNew: false, newIsCap: true, properties: true }
512
+ ],
513
+ "no-alert": "error",
514
+ "no-array-constructor": "error",
515
+ "no-async-promise-executor": "error",
516
+ "no-caller": "error",
517
+ "no-case-declarations": "error",
518
+ "no-class-assign": "error",
519
+ "no-compare-neg-zero": "error",
520
+ "no-cond-assign": ["error", "always"],
521
+ "no-console": ["error", { allow: ["warn", "error"] }],
522
+ "no-const-assign": "error",
523
+ "no-control-regex": "error",
524
+ "no-debugger": "error",
525
+ "no-delete-var": "error",
526
+ "no-dupe-args": "error",
527
+ "no-dupe-class-members": "error",
528
+ "no-dupe-keys": "error",
529
+ "no-duplicate-case": "error",
530
+ "no-empty": ["error", { allowEmptyCatch: true }],
531
+ "no-empty-character-class": "error",
532
+ "no-empty-pattern": "error",
533
+ "no-eval": "error",
534
+ "no-ex-assign": "error",
535
+ "no-extend-native": "error",
536
+ "no-extra-bind": "error",
537
+ "no-extra-boolean-cast": "error",
538
+ "no-fallthrough": "error",
539
+ "no-func-assign": "error",
540
+ "no-global-assign": "error",
541
+ "no-implied-eval": "error",
542
+ "no-import-assign": "error",
543
+ "no-invalid-regexp": "error",
544
+ "no-irregular-whitespace": "error",
545
+ "no-iterator": "error",
546
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
547
+ "no-lone-blocks": "error",
548
+ "no-loss-of-precision": "error",
549
+ "no-misleading-character-class": "error",
550
+ "no-multi-str": "error",
551
+ "no-new": "error",
552
+ "no-new-func": "error",
553
+ "no-new-native-nonconstructor": "error",
554
+ "no-new-wrappers": "error",
555
+ "no-obj-calls": "error",
556
+ "no-octal": "error",
557
+ "no-octal-escape": "error",
558
+ "no-proto": "error",
559
+ "no-prototype-builtins": "error",
560
+ "no-redeclare": ["error", { builtinGlobals: false }],
561
+ "no-regex-spaces": "error",
562
+ "no-restricted-globals": [
563
+ "error",
564
+ { message: "Use `globalThis` instead.", name: "global" },
565
+ { message: "Use `globalThis` instead.", name: "self" }
566
+ ],
567
+ "no-restricted-properties": [
568
+ "error",
569
+ {
570
+ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
571
+ property: "__proto__"
572
+ },
573
+ {
574
+ message: "Use `Object.defineProperty` instead.",
575
+ property: "__defineGetter__"
576
+ },
577
+ {
578
+ message: "Use `Object.defineProperty` instead.",
579
+ property: "__defineSetter__"
580
+ },
581
+ {
582
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
583
+ property: "__lookupGetter__"
584
+ },
585
+ {
586
+ message: "Use `Object.getOwnPropertyDescriptor` instead.",
587
+ property: "__lookupSetter__"
588
+ }
589
+ ],
590
+ "no-restricted-syntax": [
591
+ "error",
592
+ "TSEnumDeclaration[const=true]",
593
+ "TSExportAssignment"
594
+ ],
595
+ "no-self-assign": ["error", { props: true }],
596
+ "no-self-compare": "error",
597
+ "no-sequences": "error",
598
+ "no-shadow-restricted-names": "error",
599
+ "no-sparse-arrays": "error",
600
+ "no-template-curly-in-string": "error",
601
+ "no-this-before-super": "error",
602
+ "no-throw-literal": "error",
603
+ "no-undef": "error",
604
+ "no-undef-init": "error",
605
+ "no-unexpected-multiline": "error",
606
+ "no-unmodified-loop-condition": "error",
607
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
608
+ "no-unreachable": "error",
609
+ "no-unreachable-loop": "error",
610
+ "no-unsafe-finally": "error",
611
+ "no-unsafe-negation": "error",
612
+ "no-unused-expressions": [
613
+ "error",
614
+ {
615
+ allowShortCircuit: true,
616
+ allowTaggedTemplates: true,
617
+ allowTernary: true
618
+ }
619
+ ],
620
+ "no-unused-vars": [
621
+ "error",
622
+ {
623
+ args: "none",
624
+ caughtErrors: "none",
625
+ ignoreRestSiblings: true,
626
+ vars: "all"
627
+ }
628
+ ],
629
+ "no-use-before-define": [
630
+ "error",
631
+ { classes: false, functions: false, variables: true }
632
+ ],
633
+ "no-useless-backreference": "error",
634
+ "no-useless-call": "error",
635
+ "no-useless-catch": "error",
636
+ "no-useless-computed-key": "error",
637
+ "no-useless-constructor": "error",
638
+ "no-useless-rename": "error",
639
+ "no-useless-return": "error",
640
+ "no-var": "error",
641
+ "no-with": "error",
642
+ "object-shorthand": [
643
+ "error",
644
+ "always",
645
+ {
646
+ avoidQuotes: true,
647
+ ignoreConstructors: false
648
+ }
649
+ ],
650
+ "one-var": ["error", { initialized: "never" }],
651
+ "prefer-arrow-callback": [
652
+ "error",
653
+ {
654
+ allowNamedFunctions: false,
655
+ allowUnboundThis: true
656
+ }
657
+ ],
658
+ "prefer-const": [
659
+ isInEditor ? "warn" : "error",
660
+ {
661
+ destructuring: "all",
662
+ ignoreReadBeforeAssign: true
663
+ }
664
+ ],
665
+ "prefer-exponentiation-operator": "error",
666
+ "prefer-promise-reject-errors": "error",
667
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
668
+ "prefer-rest-params": "error",
669
+ "prefer-spread": "error",
670
+ "prefer-template": "error",
671
+ "symbol-description": "error",
672
+ "unicode-bom": ["error", "never"],
673
+ "unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
674
+ "unused-imports/no-unused-vars": [
675
+ "error",
676
+ {
677
+ args: "after-used",
678
+ argsIgnorePattern: "^_",
679
+ ignoreRestSiblings: true,
680
+ vars: "all",
681
+ varsIgnorePattern: "^_"
682
+ }
683
+ ],
684
+ "use-isnan": [
685
+ "error",
686
+ { enforceForIndexOf: true, enforceForSwitchCase: true }
687
+ ],
688
+ "valid-typeof": ["error", { requireStringLiterals: true }],
689
+ "vars-on-top": "error",
690
+ "yoda": ["error", "never"],
691
+ ...overrides
692
+ }
693
+ }
694
+ ];
695
+ }
696
+
697
+ // src/configs/jsonc.ts
698
+ async function jsonc(options = {}) {
699
+ const {
700
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
701
+ overrides = {},
702
+ stylistic: stylistic2 = true
703
+ } = options;
704
+ const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
705
+ const [pluginJsonc, parserJsonc] = await Promise.all([
706
+ interopDefault(import("eslint-plugin-jsonc")),
707
+ interopDefault(import("jsonc-eslint-parser"))
708
+ ]);
709
+ return [
710
+ {
711
+ name: "jsonc/setup",
712
+ plugins: {
713
+ jsonc: pluginJsonc
714
+ }
715
+ },
716
+ {
717
+ files,
718
+ languageOptions: {
719
+ parser: parserJsonc
720
+ },
721
+ name: "jsonc/rules",
722
+ rules: {
723
+ "jsonc/no-bigint-literals": "error",
724
+ "jsonc/no-binary-expression": "error",
725
+ "jsonc/no-binary-numeric-literals": "error",
726
+ "jsonc/no-dupe-keys": "error",
727
+ "jsonc/no-escape-sequence-in-identifier": "error",
728
+ "jsonc/no-floating-decimal": "error",
729
+ "jsonc/no-hexadecimal-numeric-literals": "error",
730
+ "jsonc/no-infinity": "error",
731
+ "jsonc/no-multi-str": "error",
732
+ "jsonc/no-nan": "error",
733
+ "jsonc/no-number-props": "error",
734
+ "jsonc/no-numeric-separators": "error",
735
+ "jsonc/no-octal": "error",
736
+ "jsonc/no-octal-escape": "error",
737
+ "jsonc/no-octal-numeric-literals": "error",
738
+ "jsonc/no-parenthesized": "error",
739
+ "jsonc/no-plus-sign": "error",
740
+ "jsonc/no-regexp-literals": "error",
741
+ "jsonc/no-sparse-arrays": "error",
742
+ "jsonc/no-template-literals": "error",
743
+ "jsonc/no-undefined-value": "error",
744
+ "jsonc/no-unicode-codepoint-escapes": "error",
745
+ "jsonc/no-useless-escape": "error",
746
+ "jsonc/space-unary-ops": "error",
747
+ "jsonc/valid-json-number": "error",
748
+ "jsonc/vue-custom-block/no-parsing-error": "error",
749
+ ...stylistic2 ? {
750
+ "jsonc/array-bracket-spacing": ["error", "never"],
751
+ "jsonc/comma-dangle": ["error", "never"],
752
+ "jsonc/comma-style": ["error", "last"],
753
+ "jsonc/indent": ["error", indent],
754
+ "jsonc/key-spacing": [
755
+ "error",
756
+ { afterColon: true, beforeColon: false }
757
+ ],
758
+ "jsonc/object-curly-newline": [
759
+ "error",
760
+ { consistent: true, multiline: true }
761
+ ],
762
+ "jsonc/object-curly-spacing": ["error", "always"],
763
+ "jsonc/object-property-newline": [
764
+ "error",
765
+ { allowMultiplePropertiesPerLine: true }
766
+ ],
767
+ "jsonc/quote-props": "error",
768
+ "jsonc/quotes": "error"
769
+ } : {},
770
+ ...overrides
771
+ }
772
+ }
773
+ ];
774
+ }
775
+
776
+ // src/configs/jsx.ts
777
+ async function jsx() {
778
+ return [
779
+ {
780
+ files: [GLOB_JSX, GLOB_TSX],
781
+ languageOptions: {
782
+ parserOptions: {
783
+ ecmaFeatures: {
784
+ jsx: true
785
+ }
786
+ }
787
+ },
788
+ name: "jsx/setup"
789
+ }
790
+ ];
791
+ }
792
+
793
+ // src/configs/markdown.ts
794
+ import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
795
+ async function markdown(options = {}) {
796
+ const {
797
+ componentExts = [],
798
+ files = [GLOB_MARKDOWN],
799
+ overrides = {}
800
+ } = options;
801
+ const markdown2 = await interopDefault(import("@eslint/markdown"));
802
+ return [
803
+ {
804
+ name: "markdown/setup",
805
+ plugins: {
806
+ markdown: markdown2
807
+ }
808
+ },
809
+ {
810
+ files,
811
+ ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
812
+ name: "markdown/processor",
813
+ // `eslint-plugin-markdown` only creates virtual files for code blocks,
814
+ // but not the markdown file itself. We use `eslint-merge-processors` to
815
+ // add a pass-through processor for the markdown file itself.
816
+ processor: mergeProcessors([
817
+ markdown2.processors.markdown,
818
+ processorPassThrough
819
+ ])
820
+ },
821
+ {
822
+ files,
823
+ languageOptions: {
824
+ parser: parserPlain
825
+ },
826
+ name: "markdown/parser"
827
+ },
828
+ {
829
+ files: [
830
+ GLOB_MARKDOWN_CODE,
831
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
832
+ ],
833
+ languageOptions: {
834
+ parserOptions: {
835
+ ecmaFeatures: {
836
+ impliedStrict: true
837
+ }
838
+ }
839
+ },
840
+ name: "markdown/disables",
841
+ rules: {
842
+ "import/newline-after-import": "off",
843
+ "no-alert": "off",
844
+ "no-console": "off",
845
+ "no-labels": "off",
846
+ "no-lone-blocks": "off",
847
+ "no-restricted-syntax": "off",
848
+ "no-undef": "off",
849
+ "no-unused-expressions": "off",
850
+ "no-unused-labels": "off",
851
+ "no-unused-vars": "off",
852
+ "node/prefer-global/process": "off",
853
+ "style/comma-dangle": "off",
854
+ "style/eol-last": "off",
855
+ "ts/consistent-type-imports": "off",
856
+ "ts/explicit-function-return-type": "off",
857
+ "ts/no-namespace": "off",
858
+ "ts/no-redeclare": "off",
859
+ "ts/no-require-imports": "off",
860
+ "ts/no-unused-expressions": "off",
861
+ "ts/no-unused-vars": "off",
862
+ "ts/no-use-before-define": "off",
863
+ "unicode-bom": "off",
864
+ "unused-imports/no-unused-imports": "off",
865
+ "unused-imports/no-unused-vars": "off",
866
+ ...overrides
867
+ }
868
+ }
869
+ ];
870
+ }
871
+
872
+ // src/configs/node.ts
873
+ async function node() {
874
+ return [
875
+ {
876
+ name: "node/rules",
877
+ plugins: {
878
+ node: default3
879
+ },
880
+ rules: {
881
+ "node/handle-callback-err": ["error", "^(err|error)$"],
882
+ "node/no-deprecated-api": "error",
883
+ "node/no-exports-assign": "error",
884
+ "node/no-new-require": "error",
885
+ "node/no-path-concat": "error",
886
+ "node/prefer-global/buffer": ["error", "never"],
887
+ "node/prefer-global/process": ["error", "never"],
888
+ "node/process-exit-as-throw": "error"
889
+ }
890
+ }
891
+ ];
892
+ }
893
+
894
+ // src/configs/perfectionist.ts
895
+ async function perfectionist() {
896
+ return [
897
+ {
898
+ name: "perfectionist/setup",
899
+ plugins: {
900
+ perfectionist: default4
901
+ },
902
+ rules: {
903
+ "perfectionist/sort-exports": [
904
+ "error",
905
+ { order: "asc", type: "natural" }
906
+ ],
907
+ "perfectionist/sort-imports": [
908
+ "error",
909
+ {
910
+ groups: [
911
+ "type",
912
+ ["parent-type", "sibling-type", "index-type", "internal-type"],
913
+ "builtin",
914
+ "external",
915
+ "internal",
916
+ ["parent", "sibling", "index"],
917
+ "side-effect",
918
+ "object",
919
+ "unknown"
920
+ ],
921
+ newlinesBetween: "always",
922
+ order: "asc",
923
+ type: "natural"
924
+ }
925
+ ],
926
+ "perfectionist/sort-named-exports": [
927
+ "error",
928
+ { order: "asc", type: "natural" }
929
+ ],
930
+ "perfectionist/sort-named-imports": [
931
+ "error",
932
+ { order: "asc", type: "natural" }
933
+ ]
934
+ }
935
+ }
936
+ ];
937
+ }
938
+
939
+ // src/configs/react.ts
940
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
941
+ var ReactRefreshAllowConstantExportPackages = ["vite"];
942
+ var ReactRouterPackages = [
943
+ "@react-router/node",
944
+ "@react-router/react",
945
+ "@react-router/serve",
946
+ "@react-router/dev"
947
+ ];
948
+ var NextJsPackages = ["next"];
949
+ async function react(options = {}) {
950
+ const {
951
+ files = [GLOB_SRC],
952
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
953
+ ignoresTypeAware = [`${GLOB_MARKDOWN}/**`],
954
+ overrides = {},
955
+ tsconfigPath
956
+ } = options;
957
+ const isTypeAware = !!tsconfigPath;
958
+ const typeAwareRules = {
959
+ "react/no-leaked-conditional-rendering": "warn"
960
+ };
961
+ const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
962
+ [
963
+ interopDefault(import("@eslint-react/eslint-plugin")),
964
+ interopDefault(import("eslint-plugin-react-hooks")),
965
+ interopDefault(import("eslint-plugin-react-refresh"))
966
+ ]
967
+ );
968
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
969
+ (i) => isPackageExists2(i)
970
+ );
971
+ const isUsingReactRouter = ReactRouterPackages.some(
972
+ (i) => isPackageExists2(i)
973
+ );
974
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
975
+ const plugins = pluginReact.configs.all.plugins;
976
+ return [
977
+ {
978
+ name: "react/setup",
979
+ plugins: {
980
+ "react": plugins["@eslint-react"],
981
+ "react-dom": plugins["@eslint-react/dom"],
982
+ "react-hooks": pluginReactHooks,
983
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
984
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
985
+ "react-refresh": pluginReactRefresh,
986
+ "react-web-api": plugins["@eslint-react/web-api"]
987
+ }
988
+ },
989
+ {
990
+ files,
991
+ languageOptions: {
992
+ parserOptions: {
993
+ ecmaFeatures: {
994
+ jsx: true
995
+ }
996
+ },
997
+ sourceType: "module"
998
+ },
999
+ name: "react/rules",
1000
+ rules: {
1001
+ // recommended rules from @eslint-react/dom
1002
+ "react-dom/no-children-in-void-dom-elements": "warn",
1003
+ "react-dom/no-dangerously-set-innerhtml": "warn",
1004
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1005
+ "react-dom/no-find-dom-node": "error",
1006
+ "react-dom/no-missing-button-type": "warn",
1007
+ "react-dom/no-missing-iframe-sandbox": "warn",
1008
+ "react-dom/no-namespace": "error",
1009
+ "react-dom/no-render-return-value": "error",
1010
+ "react-dom/no-script-url": "warn",
1011
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
1012
+ "react-dom/no-unsafe-target-blank": "warn",
1013
+ // recommended rules react-hooks
1014
+ "react-hooks/exhaustive-deps": "warn",
1015
+ "react-hooks/rules-of-hooks": "error",
1016
+ // react refresh
1017
+ "react-refresh/only-export-components": [
1018
+ "warn",
1019
+ {
1020
+ allowConstantExport: isAllowConstantExport,
1021
+ allowExportNames: [
1022
+ ...isUsingNext ? [
1023
+ "dynamic",
1024
+ "dynamicParams",
1025
+ "revalidate",
1026
+ "fetchCache",
1027
+ "runtime",
1028
+ "preferredRegion",
1029
+ "maxDuration",
1030
+ "config",
1031
+ "generateStaticParams",
1032
+ "metadata",
1033
+ "generateMetadata",
1034
+ "viewport",
1035
+ "generateViewport"
1036
+ ] : [],
1037
+ ...isUsingReactRouter ? ["meta", "links", "headers", "loader", "action"] : []
1038
+ ]
1039
+ }
1040
+ ],
1041
+ // recommended rules from @eslint-react/web-api
1042
+ "react-web-api/no-leaked-event-listener": "warn",
1043
+ "react-web-api/no-leaked-interval": "warn",
1044
+ "react-web-api/no-leaked-resize-observer": "warn",
1045
+ "react-web-api/no-leaked-timeout": "warn",
1046
+ // recommended rules from @eslint-react
1047
+ "react/ensure-forward-ref-using-ref": "warn",
1048
+ "react/jsx-no-duplicate-props": "warn",
1049
+ "react/jsx-uses-vars": "warn",
1050
+ "react/no-access-state-in-setstate": "error",
1051
+ "react/no-array-index-key": "warn",
1052
+ "react/no-children-count": "warn",
1053
+ "react/no-children-for-each": "warn",
1054
+ "react/no-children-map": "warn",
1055
+ "react/no-children-only": "warn",
1056
+ "react/no-children-to-array": "warn",
1057
+ "react/no-clone-element": "warn",
1058
+ "react/no-comment-textnodes": "warn",
1059
+ "react/no-component-will-mount": "error",
1060
+ "react/no-component-will-receive-props": "error",
1061
+ "react/no-component-will-update": "error",
1062
+ "react/no-context-provider": "warn",
1063
+ "react/no-create-ref": "error",
1064
+ "react/no-default-props": "error",
1065
+ "react/no-direct-mutation-state": "error",
1066
+ "react/no-duplicate-key": "error",
1067
+ "react/no-forward-ref": "warn",
1068
+ "react/no-implicit-key": "warn",
1069
+ "react/no-missing-key": "error",
1070
+ "react/no-nested-components": "error",
1071
+ "react/no-prop-types": "error",
1072
+ "react/no-redundant-should-component-update": "error",
1073
+ "react/no-set-state-in-component-did-mount": "warn",
1074
+ "react/no-set-state-in-component-did-update": "warn",
1075
+ "react/no-set-state-in-component-will-update": "warn",
1076
+ "react/no-string-refs": "error",
1077
+ "react/no-unsafe-component-will-mount": "warn",
1078
+ "react/no-unsafe-component-will-receive-props": "warn",
1079
+ "react/no-unsafe-component-will-update": "warn",
1080
+ "react/no-unstable-context-value": "warn",
1081
+ "react/no-unstable-default-props": "warn",
1082
+ "react/no-unused-class-component-members": "warn",
1083
+ "react/no-unused-state": "warn",
1084
+ "react/prefer-destructuring-assignment": "warn",
1085
+ "react/prefer-shorthand-boolean": "warn",
1086
+ "react/prefer-shorthand-fragment": "warn",
1087
+ // overrides
1088
+ ...overrides
1089
+ }
1090
+ },
1091
+ ...isTypeAware ? [
1092
+ {
1093
+ files: filesTypeAware,
1094
+ ignores: ignoresTypeAware,
1095
+ name: "react/type-aware-rules",
1096
+ rules: {
1097
+ ...typeAwareRules
1098
+ }
1099
+ }
1100
+ ] : []
1101
+ ];
1102
+ }
1103
+
1104
+ // src/configs/regexp.ts
1105
+ import { configs } from "eslint-plugin-regexp";
1106
+ async function regexp(options = {}) {
1107
+ const config2 = configs["flat/recommended"];
1108
+ const rules = {
1109
+ ...config2.rules
1110
+ };
1111
+ if (options.level === "warn") {
1112
+ for (const key in rules) {
1113
+ if (rules[key] === "error") {
1114
+ rules[key] = "warn";
1115
+ }
1116
+ }
1117
+ }
1118
+ return [
1119
+ {
1120
+ ...config2,
1121
+ name: "regexp/rules",
1122
+ rules: {
1123
+ ...rules,
1124
+ ...options.overrides
1125
+ }
1126
+ }
1127
+ ];
1128
+ }
1129
+
1130
+ // src/configs/sort.ts
1131
+ async function sortPackageJson() {
1132
+ return [
1133
+ {
1134
+ files: ["**/package.json"],
1135
+ name: "sort/package-json",
1136
+ rules: {
1137
+ "jsonc/sort-array-values": [
1138
+ "error",
1139
+ {
1140
+ order: { type: "asc" },
1141
+ pathPattern: "^files$"
1142
+ }
1143
+ ],
1144
+ "jsonc/sort-keys": [
1145
+ "error",
1146
+ {
1147
+ order: [
1148
+ "publisher",
1149
+ "name",
1150
+ "displayName",
1151
+ "type",
1152
+ "version",
1153
+ "private",
1154
+ "packageManager",
1155
+ "description",
1156
+ "author",
1157
+ "contributors",
1158
+ "license",
1159
+ "funding",
1160
+ "homepage",
1161
+ "repository",
1162
+ "bugs",
1163
+ "keywords",
1164
+ "categories",
1165
+ "sideEffects",
1166
+ "exports",
1167
+ "main",
1168
+ "module",
1169
+ "unpkg",
1170
+ "jsdelivr",
1171
+ "types",
1172
+ "typesVersions",
1173
+ "bin",
1174
+ "icon",
1175
+ "files",
1176
+ "engines",
1177
+ "activationEvents",
1178
+ "contributes",
1179
+ "scripts",
1180
+ "peerDependencies",
1181
+ "peerDependenciesMeta",
1182
+ "dependencies",
1183
+ "optionalDependencies",
1184
+ "devDependencies",
1185
+ "pnpm",
1186
+ "overrides",
1187
+ "resolutions",
1188
+ "husky",
1189
+ "simple-git-hooks",
1190
+ "lint-staged",
1191
+ "eslintConfig"
1192
+ ],
1193
+ pathPattern: "^$"
1194
+ },
1195
+ {
1196
+ order: { type: "asc" },
1197
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1198
+ },
1199
+ {
1200
+ order: { type: "asc" },
1201
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1202
+ },
1203
+ {
1204
+ order: ["types", "import", "require", "default"],
1205
+ pathPattern: "^exports.*$"
1206
+ },
1207
+ {
1208
+ order: [
1209
+ // client hooks only
1210
+ "pre-commit",
1211
+ "prepare-commit-msg",
1212
+ "commit-msg",
1213
+ "post-commit",
1214
+ "pre-rebase",
1215
+ "post-rewrite",
1216
+ "post-checkout",
1217
+ "post-merge",
1218
+ "pre-push",
1219
+ "pre-auto-gc"
1220
+ ],
1221
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1222
+ }
1223
+ ]
1224
+ }
1225
+ }
1226
+ ];
1227
+ }
1228
+ function sortTsconfig() {
1229
+ return [
1230
+ {
1231
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1232
+ name: "sort/tsconfig-json",
1233
+ rules: {
1234
+ "jsonc/sort-keys": [
1235
+ "error",
1236
+ {
1237
+ order: [
1238
+ "extends",
1239
+ "compilerOptions",
1240
+ "references",
1241
+ "files",
1242
+ "include",
1243
+ "exclude"
1244
+ ],
1245
+ pathPattern: "^$"
1246
+ },
1247
+ {
1248
+ order: [
1249
+ /* Projects */
1250
+ "incremental",
1251
+ "composite",
1252
+ "tsBuildInfoFile",
1253
+ "disableSourceOfProjectReferenceRedirect",
1254
+ "disableSolutionSearching",
1255
+ "disableReferencedProjectLoad",
1256
+ /* Language and Environment */
1257
+ "target",
1258
+ "jsx",
1259
+ "jsxFactory",
1260
+ "jsxFragmentFactory",
1261
+ "jsxImportSource",
1262
+ "lib",
1263
+ "moduleDetection",
1264
+ "noLib",
1265
+ "reactNamespace",
1266
+ "useDefineForClassFields",
1267
+ "emitDecoratorMetadata",
1268
+ "experimentalDecorators",
1269
+ /* Modules */
1270
+ "baseUrl",
1271
+ "rootDir",
1272
+ "rootDirs",
1273
+ "customConditions",
1274
+ "module",
1275
+ "moduleResolution",
1276
+ "moduleSuffixes",
1277
+ "noResolve",
1278
+ "paths",
1279
+ "resolveJsonModule",
1280
+ "resolvePackageJsonExports",
1281
+ "resolvePackageJsonImports",
1282
+ "typeRoots",
1283
+ "types",
1284
+ "allowArbitraryExtensions",
1285
+ "allowImportingTsExtensions",
1286
+ "allowUmdGlobalAccess",
1287
+ /* JavaScript Support */
1288
+ "allowJs",
1289
+ "checkJs",
1290
+ "maxNodeModuleJsDepth",
1291
+ /* Type Checking */
1292
+ "strict",
1293
+ "strictBindCallApply",
1294
+ "strictFunctionTypes",
1295
+ "strictNullChecks",
1296
+ "strictPropertyInitialization",
1297
+ "allowUnreachableCode",
1298
+ "allowUnusedLabels",
1299
+ "alwaysStrict",
1300
+ "exactOptionalPropertyTypes",
1301
+ "noFallthroughCasesInSwitch",
1302
+ "noImplicitAny",
1303
+ "noImplicitOverride",
1304
+ "noImplicitReturns",
1305
+ "noImplicitThis",
1306
+ "noPropertyAccessFromIndexSignature",
1307
+ "noUncheckedIndexedAccess",
1308
+ "noUnusedLocals",
1309
+ "noUnusedParameters",
1310
+ "useUnknownInCatchVariables",
1311
+ /* Emit */
1312
+ "declaration",
1313
+ "declarationDir",
1314
+ "declarationMap",
1315
+ "downlevelIteration",
1316
+ "emitBOM",
1317
+ "emitDeclarationOnly",
1318
+ "importHelpers",
1319
+ "importsNotUsedAsValues",
1320
+ "inlineSourceMap",
1321
+ "inlineSources",
1322
+ "mapRoot",
1323
+ "newLine",
1324
+ "noEmit",
1325
+ "noEmitHelpers",
1326
+ "noEmitOnError",
1327
+ "outDir",
1328
+ "outFile",
1329
+ "preserveConstEnums",
1330
+ "preserveValueImports",
1331
+ "removeComments",
1332
+ "sourceMap",
1333
+ "sourceRoot",
1334
+ "stripInternal",
1335
+ /* Interop Constraints */
1336
+ "allowSyntheticDefaultImports",
1337
+ "esModuleInterop",
1338
+ "forceConsistentCasingInFileNames",
1339
+ "isolatedDeclarations",
1340
+ "isolatedModules",
1341
+ "preserveSymlinks",
1342
+ "verbatimModuleSyntax",
1343
+ /* Completeness */
1344
+ "skipDefaultLibCheck",
1345
+ "skipLibCheck"
1346
+ ],
1347
+ pathPattern: "^compilerOptions$"
1348
+ }
1349
+ ]
1350
+ }
1351
+ }
1352
+ ];
1353
+ }
1354
+
1355
+ // src/configs/toml.ts
1356
+ async function toml(options = {}) {
1357
+ const { files = [GLOB_TOML], overrides = {}, stylistic: stylistic2 = true } = options;
1358
+ const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1359
+ const [pluginToml, parserToml] = await Promise.all([
1360
+ interopDefault(import("eslint-plugin-toml")),
1361
+ interopDefault(import("toml-eslint-parser"))
1362
+ ]);
1363
+ return [
1364
+ {
1365
+ name: "toml/setup",
1366
+ plugins: {
1367
+ toml: pluginToml
1368
+ }
1369
+ },
1370
+ {
1371
+ files,
1372
+ languageOptions: {
1373
+ parser: parserToml
1374
+ },
1375
+ name: "toml/rules",
1376
+ rules: {
1377
+ "style/spaced-comment": "off",
1378
+ "toml/comma-style": "error",
1379
+ "toml/keys-order": "error",
1380
+ "toml/no-space-dots": "error",
1381
+ "toml/no-unreadable-number-separator": "error",
1382
+ "toml/precision-of-fractional-seconds": "error",
1383
+ "toml/precision-of-integer": "error",
1384
+ "toml/tables-order": "error",
1385
+ "toml/vue-custom-block/no-parsing-error": "error",
1386
+ ...stylistic2 ? {
1387
+ "toml/array-bracket-newline": "error",
1388
+ "toml/array-bracket-spacing": "error",
1389
+ "toml/array-element-newline": "error",
1390
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
1391
+ "toml/inline-table-curly-spacing": "error",
1392
+ "toml/key-spacing": "error",
1393
+ "toml/padding-line-between-pairs": "error",
1394
+ "toml/padding-line-between-tables": "error",
1395
+ "toml/quoted-keys": "error",
1396
+ "toml/spaced-comment": "error",
1397
+ "toml/table-bracket-spacing": "error"
1398
+ } : {},
1399
+ ...overrides
1400
+ }
1401
+ }
1402
+ ];
1403
+ }
1404
+
1405
+ // src/configs/typescript.ts
1406
+ import process2 from "node:process";
1407
+ async function typescript(options = {}) {
1408
+ const {
1409
+ componentExts = [],
1410
+ overrides = {},
1411
+ overridesTypeAware = {},
1412
+ parserOptions = {},
1413
+ type = "app"
1414
+ } = options;
1415
+ const files = options.files ?? [
1416
+ GLOB_TS,
1417
+ GLOB_TSX,
1418
+ ...componentExts.map((ext) => `**/*.${ext}`)
1419
+ ];
1420
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1421
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
1422
+ const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1423
+ const isTypeAware = !!tsconfigPath;
1424
+ const typeAwareRules = {
1425
+ "dot-notation": "off",
1426
+ "no-implied-eval": "off",
1427
+ "ts/await-thenable": "error",
1428
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1429
+ "ts/no-floating-promises": "error",
1430
+ "ts/no-for-in-array": "error",
1431
+ "ts/no-implied-eval": "error",
1432
+ "ts/no-misused-promises": "error",
1433
+ "ts/no-unnecessary-type-assertion": "error",
1434
+ "ts/no-unsafe-argument": "error",
1435
+ "ts/no-unsafe-assignment": "error",
1436
+ "ts/no-unsafe-call": "error",
1437
+ "ts/no-unsafe-member-access": "error",
1438
+ "ts/no-unsafe-return": "error",
1439
+ "ts/promise-function-async": "error",
1440
+ "ts/restrict-plus-operands": "error",
1441
+ "ts/restrict-template-expressions": "error",
1442
+ "ts/return-await": ["error", "in-try-catch"],
1443
+ "ts/strict-boolean-expressions": [
1444
+ "error",
1445
+ { allowNullableBoolean: true, allowNullableObject: true }
1446
+ ],
1447
+ "ts/switch-exhaustiveness-check": "error",
1448
+ "ts/unbound-method": "error"
1449
+ };
1450
+ const [pluginTs, parserTs] = await Promise.all([
1451
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
1452
+ interopDefault(import("@typescript-eslint/parser"))
1453
+ ]);
1454
+ function makeParser(typeAware, files2, ignores2) {
1455
+ return {
1456
+ files: files2,
1457
+ ...ignores2 ? { ignores: ignores2 } : {},
1458
+ languageOptions: {
1459
+ parser: parserTs,
1460
+ parserOptions: {
1461
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1462
+ sourceType: "module",
1463
+ ...typeAware ? {
1464
+ projectService: {
1465
+ allowDefaultProject: ["./*.js"],
1466
+ defaultProject: tsconfigPath
1467
+ },
1468
+ tsconfigRootDir: process2.cwd()
1469
+ } : {},
1470
+ ...parserOptions
1471
+ }
1472
+ },
1473
+ name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
1474
+ };
1475
+ }
1476
+ return [
1477
+ {
1478
+ // Install the plugins without globs, so they can be configured separately.
1479
+ name: "typescript/setup",
1480
+ plugins: {
1481
+ ts: pluginTs
1482
+ }
1483
+ },
1484
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
1485
+ ...isTypeAware ? [
1486
+ makeParser(false, files),
1487
+ makeParser(true, filesTypeAware, ignoresTypeAware)
1488
+ ] : [makeParser(false, files)],
1489
+ {
1490
+ files,
1491
+ name: "typescript/rules",
1492
+ rules: {
1493
+ ...renameRules(
1494
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
1495
+ { "@typescript-eslint": "ts" }
1496
+ ),
1497
+ ...renameRules(pluginTs.configs.strict.rules, {
1498
+ "@typescript-eslint": "ts"
1499
+ }),
1500
+ "no-dupe-class-members": "off",
1501
+ "no-redeclare": "off",
1502
+ "no-use-before-define": "off",
1503
+ "no-useless-constructor": "off",
1504
+ "ts/ban-ts-comment": [
1505
+ "error",
1506
+ { "ts-expect-error": "allow-with-description" }
1507
+ ],
1508
+ "ts/consistent-type-definitions": ["error", "interface"],
1509
+ "ts/consistent-type-imports": [
1510
+ "error",
1511
+ {
1512
+ disallowTypeAnnotations: false,
1513
+ fixStyle: "separate-type-imports",
1514
+ prefer: "type-imports"
1515
+ }
1516
+ ],
1517
+ "ts/method-signature-style": ["error", "property"],
1518
+ // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
1519
+ "ts/no-dupe-class-members": "error",
1520
+ "ts/no-dynamic-delete": "off",
1521
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
1522
+ "ts/no-explicit-any": "off",
1523
+ "ts/no-extraneous-class": "off",
1524
+ "ts/no-import-type-side-effects": "error",
1525
+ "ts/no-invalid-void-type": "off",
1526
+ "ts/no-non-null-assertion": "off",
1527
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1528
+ "ts/no-require-imports": "error",
1529
+ "ts/no-unused-expressions": [
1530
+ "error",
1531
+ {
1532
+ allowShortCircuit: true,
1533
+ allowTaggedTemplates: true,
1534
+ allowTernary: true
1535
+ }
1536
+ ],
1537
+ "ts/no-unused-vars": "off",
1538
+ "ts/no-use-before-define": [
1539
+ "error",
1540
+ { classes: false, functions: false, variables: true }
1541
+ ],
1542
+ "ts/no-useless-constructor": "off",
1543
+ "ts/no-wrapper-object-types": "error",
1544
+ "ts/triple-slash-reference": "off",
1545
+ "ts/unified-signatures": "off",
1546
+ ...type === "lib" ? {
1547
+ "ts/explicit-function-return-type": [
1548
+ "error",
1549
+ {
1550
+ allowExpressions: true,
1551
+ allowHigherOrderFunctions: true,
1552
+ allowIIFEs: true
1553
+ }
1554
+ ]
1555
+ } : {},
1556
+ ...overrides
1557
+ }
1558
+ },
1559
+ ...isTypeAware ? [
1560
+ {
1561
+ files: filesTypeAware,
1562
+ ignores: ignoresTypeAware,
1563
+ name: "typescript/rules-type-aware",
1564
+ rules: {
1565
+ ...typeAwareRules,
1566
+ ...overridesTypeAware
1567
+ }
1568
+ }
1569
+ ] : []
1570
+ ];
1571
+ }
1572
+
1573
+ // src/configs/unicorn.ts
1574
+ async function unicorn(options = {}) {
1575
+ return [
1576
+ {
1577
+ name: "unicorn/rules",
1578
+ plugins: {
1579
+ unicorn: default5
1580
+ },
1581
+ rules: {
1582
+ ...options.allRecommended ? default5.configs.recommended.rules : {
1583
+ "unicorn/consistent-empty-array-spread": "error",
1584
+ "unicorn/error-message": "error",
1585
+ "unicorn/escape-case": "error",
1586
+ "unicorn/new-for-builtins": "error",
1587
+ "unicorn/no-instanceof-builtins": "error",
1588
+ "unicorn/no-new-array": "error",
1589
+ "unicorn/no-new-buffer": "error",
1590
+ "unicorn/number-literal-case": "error",
1591
+ "unicorn/prefer-dom-node-text-content": "error",
1592
+ "unicorn/prefer-includes": "error",
1593
+ "unicorn/prefer-node-protocol": "error",
1594
+ "unicorn/prefer-number-properties": "error",
1595
+ "unicorn/prefer-string-starts-ends-with": "error",
1596
+ "unicorn/prefer-type-error": "error",
1597
+ "unicorn/throw-new-error": "error"
1598
+ }
1599
+ }
1600
+ }
1601
+ ];
1602
+ }
1603
+
1604
+ // src/configs/unocss.ts
1605
+ async function unocss(options = {}) {
1606
+ const { attributify = true, strict = false } = options;
1607
+ await ensurePackages(["@unocss/eslint-plugin"]);
1608
+ const [pluginUnoCSS] = await Promise.all([
1609
+ interopDefault(import("@unocss/eslint-plugin"))
1610
+ ]);
1611
+ return [
1612
+ {
1613
+ name: "unocss",
1614
+ plugins: {
1615
+ unocss: pluginUnoCSS
1616
+ },
1617
+ rules: {
1618
+ "unocss/order": "warn",
1619
+ ...attributify ? {
1620
+ "unocss/order-attributify": "warn"
1621
+ } : {},
1622
+ ...strict ? {
1623
+ "unocss/blocklist": "error"
1624
+ } : {}
1625
+ }
1626
+ }
1627
+ ];
1628
+ }
1629
+
1630
+ // src/configs/yaml.ts
1631
+ async function yaml(options = {}) {
1632
+ const { files = [GLOB_YAML], overrides = {}, stylistic: stylistic2 = true } = options;
1633
+ const { indent = 2, quotes = "single" } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1634
+ const [pluginYaml, parserYaml] = await Promise.all([
1635
+ interopDefault(import("eslint-plugin-yml")),
1636
+ interopDefault(import("yaml-eslint-parser"))
1637
+ ]);
1638
+ return [
1639
+ {
1640
+ name: "yaml/setup",
1641
+ plugins: {
1642
+ yaml: pluginYaml
1643
+ }
1644
+ },
1645
+ {
1646
+ files,
1647
+ languageOptions: {
1648
+ parser: parserYaml
1649
+ },
1650
+ name: "yaml/rules",
1651
+ rules: {
1652
+ "style/spaced-comment": "off",
1653
+ "yaml/block-mapping": "error",
1654
+ "yaml/block-sequence": "error",
1655
+ "yaml/no-empty-key": "error",
1656
+ "yaml/no-empty-sequence-entry": "error",
1657
+ "yaml/no-irregular-whitespace": "error",
1658
+ "yaml/plain-scalar": "error",
1659
+ "yaml/vue-custom-block/no-parsing-error": "error",
1660
+ ...stylistic2 ? {
1661
+ "yaml/block-mapping-question-indicator-newline": "error",
1662
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1663
+ "yaml/flow-mapping-curly-newline": "error",
1664
+ "yaml/flow-mapping-curly-spacing": "error",
1665
+ "yaml/flow-sequence-bracket-newline": "error",
1666
+ "yaml/flow-sequence-bracket-spacing": "error",
1667
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1668
+ "yaml/key-spacing": "error",
1669
+ "yaml/no-tab-indent": "error",
1670
+ "yaml/quotes": [
1671
+ "error",
1672
+ {
1673
+ avoidEscape: true,
1674
+ prefer: quotes === "backtick" ? "single" : quotes
1675
+ }
1676
+ ],
1677
+ "yaml/spaced-comment": "error"
1678
+ } : {},
1679
+ ...overrides
1680
+ }
1681
+ },
1682
+ {
1683
+ files: ["pnpm-workspace.yaml"],
1684
+ name: "yaml/pnpm-workspace",
1685
+ rules: {
1686
+ "yaml/sort-keys": [
1687
+ "error",
1688
+ {
1689
+ order: [
1690
+ "packages",
1691
+ "overrides",
1692
+ "patchedDependencies",
1693
+ "hoistPattern",
1694
+ "catalog",
1695
+ "catalogs",
1696
+ "allowedDeprecatedVersions",
1697
+ "allowNonAppliedPatches",
1698
+ "configDependencies",
1699
+ "ignoredBuiltDependencies",
1700
+ "ignoredOptionalDependencies",
1701
+ "neverBuiltDependencies",
1702
+ "onlyBuiltDependencies",
1703
+ "onlyBuiltDependenciesFile",
1704
+ "packageExtensions",
1705
+ "peerDependencyRules",
1706
+ "supportedArchitectures"
1707
+ ],
1708
+ pathPattern: "^$"
1709
+ }
1710
+ ]
1711
+ }
1712
+ }
1713
+ ];
1714
+ }
1715
+
1716
+ // src/factory.ts
1717
+ var flatConfigProps = [
1718
+ "name",
1719
+ "languageOptions",
1720
+ "linterOptions",
1721
+ "processor",
1722
+ "plugins",
1723
+ "rules",
1724
+ "settings"
1725
+ ];
1726
+ var ReactPackages = ["react", "nest"];
1727
+ var defaultPluginRenaming = {
1728
+ "@eslint-react": "react",
1729
+ "@eslint-react/dom": "react-dom",
1730
+ "@eslint-react/hooks-extra": "react-hooks-extra",
1731
+ "@eslint-react/naming-convention": "react-naming-convention",
1732
+ "@stylistic": "style",
1733
+ "@typescript-eslint": "ts",
1734
+ "import-x": "import",
1735
+ "n": "node",
1736
+ "yml": "yaml"
1737
+ };
1738
+ function config(options = {}, ...userConfigs) {
1739
+ const {
1740
+ autoRenamePlugins = true,
1741
+ componentExts = [],
1742
+ gitignore: enableGitignore = true,
1743
+ jsx: enableJsx = true,
1744
+ react: enableReact = ReactPackages.some((i) => isPackageExists3(i)),
1745
+ regexp: enableRegexp = true,
1746
+ typescript: enableTypeScript = isPackageExists3("typescript"),
1747
+ unicorn: enableUnicorn = true,
1748
+ unocss: enableUnoCSS = false
1749
+ } = options;
1750
+ let isInEditor = options.isInEditor;
1751
+ if (isInEditor == null) {
1752
+ isInEditor = isInEditorEnv();
1753
+ if (isInEditor) {
1754
+ console.log(
1755
+ "[@ghettoddos/eslint-config] Detected running in editor, some rules are disabled."
1756
+ );
1757
+ }
1758
+ }
1759
+ const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
1760
+ if (stylisticOptions && !("jsx" in stylisticOptions)) {
1761
+ stylisticOptions.jsx = enableJsx;
1762
+ }
1763
+ const configs2 = [];
1764
+ if (enableGitignore) {
1765
+ if (typeof enableGitignore !== "boolean") {
1766
+ configs2.push(
1767
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1768
+ r({
1769
+ name: "gitignore",
1770
+ ...enableGitignore
1771
+ })
1772
+ ])
1773
+ );
1774
+ } else {
1775
+ configs2.push(
1776
+ interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1777
+ r({
1778
+ name: "gitignore",
1779
+ strict: false
1780
+ })
1781
+ ])
1782
+ );
1783
+ }
1784
+ }
1785
+ const typescriptOptions = resolveSubOptions(options, "typescript");
1786
+ const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
1787
+ configs2.push(
1788
+ ignores(options.ignores),
1789
+ javascript({
1790
+ isInEditor,
1791
+ overrides: getOverrides(options, "javascript")
1792
+ }),
1793
+ comments(),
1794
+ node(),
1795
+ imports({
1796
+ stylistic: stylisticOptions
1797
+ }),
1798
+ // Optional plugins (installed but not enabled by default)
1799
+ perfectionist()
1800
+ );
1801
+ if (enableUnicorn) {
1802
+ configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
1803
+ }
1804
+ if (enableJsx) {
1805
+ configs2.push(jsx());
1806
+ }
1807
+ if (enableTypeScript) {
1808
+ configs2.push(
1809
+ typescript({
1810
+ ...typescriptOptions,
1811
+ componentExts,
1812
+ overrides: getOverrides(options, "typescript"),
1813
+ type: options.type
1814
+ })
1815
+ );
1816
+ }
1817
+ if (stylisticOptions) {
1818
+ configs2.push(
1819
+ stylistic({
1820
+ ...stylisticOptions,
1821
+ overrides: getOverrides(options, "stylistic")
1822
+ })
1823
+ );
1824
+ }
1825
+ if (enableRegexp) {
1826
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1827
+ }
1828
+ if (enableReact) {
1829
+ configs2.push(
1830
+ react({
1831
+ ...typescriptOptions,
1832
+ overrides: getOverrides(options, "react"),
1833
+ tsconfigPath
1834
+ })
1835
+ );
1836
+ }
1837
+ if (enableUnoCSS) {
1838
+ configs2.push(
1839
+ unocss({
1840
+ ...resolveSubOptions(options, "unocss"),
1841
+ overrides: getOverrides(options, "unocss")
1842
+ })
1843
+ );
1844
+ }
1845
+ if (options.jsonc ?? true) {
1846
+ configs2.push(
1847
+ jsonc({
1848
+ overrides: getOverrides(options, "jsonc"),
1849
+ stylistic: stylisticOptions
1850
+ }),
1851
+ sortPackageJson(),
1852
+ sortTsconfig()
1853
+ );
1854
+ }
1855
+ if (options.yaml ?? true) {
1856
+ configs2.push(
1857
+ yaml({
1858
+ overrides: getOverrides(options, "yaml"),
1859
+ stylistic: stylisticOptions
1860
+ })
1861
+ );
1862
+ }
1863
+ if (options.toml ?? true) {
1864
+ configs2.push(
1865
+ toml({
1866
+ overrides: getOverrides(options, "toml"),
1867
+ stylistic: stylisticOptions
1868
+ })
1869
+ );
1870
+ }
1871
+ if (options.markdown ?? true) {
1872
+ configs2.push(
1873
+ markdown({
1874
+ componentExts,
1875
+ overrides: getOverrides(options, "markdown")
1876
+ })
1877
+ );
1878
+ }
1879
+ if (options.formatters) {
1880
+ configs2.push(
1881
+ formatters(
1882
+ options.formatters,
1883
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions
1884
+ )
1885
+ );
1886
+ }
1887
+ configs2.push(disables());
1888
+ if ("files" in options) {
1889
+ throw new Error(
1890
+ '[@ghettoddos/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.'
1891
+ );
1892
+ }
1893
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1894
+ if (key in options) {
1895
+ acc[key] = options[key];
1896
+ }
1897
+ return acc;
1898
+ }, {});
1899
+ if (Object.keys(fusedConfig).length) {
1900
+ configs2.push([fusedConfig]);
1901
+ }
1902
+ let composer = new FlatConfigComposer();
1903
+ composer = composer.append(...configs2, ...userConfigs);
1904
+ if (autoRenamePlugins) {
1905
+ composer = composer.renamePlugins(defaultPluginRenaming);
1906
+ }
1907
+ if (isInEditor) {
1908
+ composer = composer.disableRulesFix(
1909
+ ["unused-imports/no-unused-imports", "prefer-const"],
1910
+ {
1911
+ builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then(
1912
+ (r) => r.builtinRules
1913
+ )
1914
+ }
1915
+ );
1916
+ }
1917
+ return composer;
1918
+ }
1919
+ function resolveSubOptions(options, key) {
1920
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
1921
+ }
1922
+ function getOverrides(options, key) {
1923
+ const sub = resolveSubOptions(options, key);
1924
+ return {
1925
+ ...options.overrides?.[key],
1926
+ ..."overrides" in sub ? sub.overrides : {}
1927
+ };
1928
+ }
1929
+
1930
+ // src/index.ts
1931
+ var index_default = config;
1932
+ export {
1933
+ GLOB_ALL_SRC,
1934
+ GLOB_CSS,
1935
+ GLOB_EXCLUDE,
1936
+ GLOB_HTML,
1937
+ GLOB_JS,
1938
+ GLOB_JSON,
1939
+ GLOB_JSON5,
1940
+ GLOB_JSONC,
1941
+ GLOB_JSX,
1942
+ GLOB_MARKDOWN,
1943
+ GLOB_MARKDOWN_CODE,
1944
+ GLOB_MARKDOWN_IN_MARKDOWN,
1945
+ GLOB_POSTCSS,
1946
+ GLOB_SCSS,
1947
+ GLOB_SRC,
1948
+ GLOB_SRC_EXT,
1949
+ GLOB_STYLE,
1950
+ GLOB_SVG,
1951
+ GLOB_TOML,
1952
+ GLOB_TS,
1953
+ GLOB_TSX,
1954
+ GLOB_XML,
1955
+ GLOB_YAML,
1956
+ StylisticConfigDefaults,
1957
+ combine,
1958
+ comments,
1959
+ config,
1960
+ index_default as default,
1961
+ defaultPluginRenaming,
1962
+ disables,
1963
+ ensurePackages,
1964
+ formatters,
1965
+ getOverrides,
1966
+ ignores,
1967
+ imports,
1968
+ interopDefault,
1969
+ isInEditorEnv,
1970
+ isInGitHooksOrLintStaged,
1971
+ isPackageInScope,
1972
+ javascript,
1973
+ jsonc,
1974
+ jsx,
1975
+ markdown,
1976
+ node,
1977
+ parserPlain,
1978
+ perfectionist,
1979
+ react,
1980
+ regexp,
1981
+ renameRules,
1982
+ resolveSubOptions,
1983
+ sortPackageJson,
1984
+ sortTsconfig,
1985
+ stylistic,
1986
+ toml,
1987
+ typescript,
1988
+ unicorn,
1989
+ unocss,
1990
+ yaml
1991
+ };