@cany748/eslint-config 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1244 @@
1
+ // src/configs/comments.ts
2
+ import pluginComments from "eslint-plugin-eslint-comments";
3
+ function comments() {
4
+ return [
5
+ {
6
+ name: "eslint-comments",
7
+ plugins: {
8
+ "eslint-comments": pluginComments
9
+ },
10
+ rules: {
11
+ ...pluginComments.configs.recommended.rules,
12
+ "eslint-comments/disable-enable-pair": "off"
13
+ }
14
+ }
15
+ ];
16
+ }
17
+
18
+ // src/configs/formatters.ts
19
+ import pluginPrettier from "eslint-plugin-prettier";
20
+ import configPrettier from "eslint-plugin-prettier/recommended";
21
+
22
+ // src/globs.ts
23
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
24
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
25
+ var GLOB_JS = "**/*.?([cm])js";
26
+ var GLOB_JSX = "**/*.?([cm])jsx";
27
+ var GLOB_TS = "**/*.?([cm])ts";
28
+ var GLOB_TSX = "**/*.?([cm])tsx";
29
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
30
+ var GLOB_CSS = "**/*.css";
31
+ var GLOB_POSTCSS = "**/*.{p,post}css";
32
+ var GLOB_LESS = "**/*.less";
33
+ var GLOB_SCSS = "**/*.scss";
34
+ var GLOB_JSON = "**/*.json";
35
+ var GLOB_JSON5 = "**/*.json5";
36
+ var GLOB_JSONC = "**/*.jsonc";
37
+ var GLOB_MARKDOWN = "**/*.md";
38
+ var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
39
+ var GLOB_SVELTE = "**/*.svelte";
40
+ var GLOB_VUE = "**/*.vue";
41
+ var GLOB_YAML = "**/*.y?(a)ml";
42
+ var GLOB_TOML = "**/*.toml";
43
+ var GLOB_XML = "**/*.xml";
44
+ var GLOB_HTML = "**/*.htm?(l)";
45
+ var GLOB_ASTRO = "**/*.astro";
46
+ var GLOB_ASTRO_TS = "**/*.astro/*.ts";
47
+ var GLOB_GRAPHQL = "**/*.{g,graph}ql";
48
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
49
+ var GLOB_TESTS = [
50
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
51
+ `**/*.spec.${GLOB_SRC_EXT}`,
52
+ `**/*.test.${GLOB_SRC_EXT}`,
53
+ `**/*.bench.${GLOB_SRC_EXT}`,
54
+ `**/*.benchmark.${GLOB_SRC_EXT}`
55
+ ];
56
+ var GLOB_ALL_SRC = [
57
+ GLOB_SRC,
58
+ GLOB_STYLE,
59
+ GLOB_JSON,
60
+ GLOB_JSON5,
61
+ GLOB_MARKDOWN,
62
+ GLOB_SVELTE,
63
+ GLOB_VUE,
64
+ GLOB_YAML,
65
+ GLOB_XML,
66
+ GLOB_HTML
67
+ ];
68
+ var GLOB_EXCLUDE = [
69
+ "**/node_modules",
70
+ "**/dist",
71
+ "**/build",
72
+ "**/vendor",
73
+ "**/public",
74
+ "**/out",
75
+ "**/package-lock.json",
76
+ "**/yarn.lock",
77
+ "**/pnpm-lock.yaml",
78
+ "**/bun.lockb",
79
+ "**/output",
80
+ "**/coverage",
81
+ "**/temp",
82
+ "**/.temp",
83
+ "**/tmp",
84
+ "**/.tmp",
85
+ "**/.history",
86
+ "**/.vitepress/cache",
87
+ "**/.nuxt",
88
+ "**/.next",
89
+ "**/.svelte-kit",
90
+ "**/.vercel",
91
+ "**/.netlify",
92
+ "**/.changeset",
93
+ "**/.idea",
94
+ "**/.cache",
95
+ "**/.output",
96
+ "**/.vite-inspect",
97
+ "**/.yarn",
98
+ "**/vite.config.*.timestamp-*",
99
+ "**/CHANGELOG*.md",
100
+ "**/*.min.*",
101
+ "**/LICENSE*",
102
+ "**/__snapshots__",
103
+ "**/auto-import?(s).d.ts",
104
+ "**/components.d.ts"
105
+ ];
106
+
107
+ // src/utils.ts
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 toArray(value) {
133
+ return Array.isArray(value) ? value : [value];
134
+ }
135
+ async function interopDefault(m) {
136
+ const resolved = await m;
137
+ return resolved.default || resolved;
138
+ }
139
+ function isInEditorEnv() {
140
+ return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
141
+ }
142
+
143
+ // src/configs/formatters.ts
144
+ function formatters(options = true) {
145
+ if (options === true) {
146
+ options = {
147
+ css: true,
148
+ graphql: true,
149
+ html: true,
150
+ markdown: true
151
+ };
152
+ }
153
+ const configs2 = [
154
+ {
155
+ name: "formatter/setup",
156
+ plugins: {
157
+ prettier: pluginPrettier
158
+ },
159
+ rules: configPrettier.rules
160
+ }
161
+ ];
162
+ if (options.css) {
163
+ configs2.push(
164
+ {
165
+ files: [GLOB_CSS, GLOB_POSTCSS],
166
+ languageOptions: {
167
+ parser: parserPlain
168
+ },
169
+ name: "formatter/css",
170
+ rules: {
171
+ "prettier/prettier": ["error", { parser: "css" }]
172
+ }
173
+ },
174
+ {
175
+ files: [GLOB_SCSS],
176
+ languageOptions: {
177
+ parser: parserPlain
178
+ },
179
+ name: "formatter/scss",
180
+ rules: {
181
+ "prettier/prettier": ["error", { parser: "scss" }]
182
+ }
183
+ },
184
+ {
185
+ files: [GLOB_LESS],
186
+ languageOptions: {
187
+ parser: parserPlain
188
+ },
189
+ name: "formatter/less",
190
+ rules: {
191
+ "prettier/prettier": ["error", { parser: "less" }]
192
+ }
193
+ }
194
+ );
195
+ }
196
+ if (options.graphql) {
197
+ configs2.push({
198
+ files: [GLOB_GRAPHQL],
199
+ languageOptions: {
200
+ parser: parserPlain
201
+ },
202
+ name: "formatter/graphql",
203
+ rules: {
204
+ "prettier/prettier": ["error", { parser: "graphql" }]
205
+ }
206
+ });
207
+ }
208
+ if (options.html) {
209
+ configs2.push({
210
+ files: [GLOB_HTML],
211
+ languageOptions: {
212
+ parser: parserPlain
213
+ },
214
+ name: "formatter/html",
215
+ rules: {
216
+ "prettier/prettier": ["error", { parser: "html" }]
217
+ }
218
+ });
219
+ }
220
+ if (options.markdown) {
221
+ configs2.push({
222
+ files: [GLOB_MARKDOWN],
223
+ languageOptions: {
224
+ parser: parserPlain
225
+ },
226
+ name: "formatter/markdown",
227
+ rules: {
228
+ "prettier/prettier": ["error", { parser: "markdown" }]
229
+ }
230
+ });
231
+ }
232
+ return configs2;
233
+ }
234
+
235
+ // src/configs/ignores.ts
236
+ function ignores() {
237
+ return [
238
+ {
239
+ ignores: GLOB_EXCLUDE
240
+ }
241
+ ];
242
+ }
243
+
244
+ // src/configs/imports.ts
245
+ import * as pluginImport from "eslint-plugin-import-x";
246
+ function imports() {
247
+ return [
248
+ {
249
+ name: "imports",
250
+ plugins: {
251
+ import: pluginImport
252
+ },
253
+ rules: {
254
+ "import/export": "error",
255
+ "import/first": "error",
256
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
257
+ "import/no-duplicates": "error",
258
+ "import/no-mutable-exports": "error",
259
+ "import/no-named-default": "error",
260
+ "import/no-self-import": "error",
261
+ "import/no-webpack-loader-syntax": "error",
262
+ "import/order": "error"
263
+ }
264
+ }
265
+ ];
266
+ }
267
+
268
+ // src/configs/javascript.ts
269
+ import globals from "globals";
270
+ import pluginUnusedImports from "eslint-plugin-unused-imports";
271
+ function javascript(options = {}) {
272
+ const { isInEditor = false, overrides = {} } = options;
273
+ return [
274
+ {
275
+ languageOptions: {
276
+ ecmaVersion: 2022,
277
+ globals: {
278
+ ...globals.browser,
279
+ ...globals.es2021,
280
+ ...globals.node,
281
+ document: "readonly",
282
+ navigator: "readonly",
283
+ window: "readonly"
284
+ },
285
+ parserOptions: {
286
+ ecmaFeatures: {
287
+ jsx: true
288
+ },
289
+ ecmaVersion: 2022,
290
+ sourceType: "module"
291
+ },
292
+ sourceType: "module"
293
+ },
294
+ linterOptions: {
295
+ reportUnusedDisableDirectives: true
296
+ },
297
+ name: "javascript/rules",
298
+ plugins: {
299
+ "unused-imports": pluginUnusedImports
300
+ },
301
+ rules: {
302
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
303
+ "array-callback-return": "error",
304
+ "block-scoped-var": "error",
305
+ camelcase: [
306
+ "error",
307
+ { properties: "never", ignoreDestructuring: true, ignoreGlobals: true, ignoreImports: true, allow: ["^UNSAFE_"] }
308
+ ],
309
+ "constructor-super": "error",
310
+ "default-case-last": "error",
311
+ "dot-notation": ["error", { allowKeywords: true }],
312
+ eqeqeq: ["error", "smart"],
313
+ "for-direction": "error",
314
+ "getter-return": "error",
315
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
316
+ "no-alert": "error",
317
+ "no-array-constructor": "error",
318
+ "no-async-promise-executor": "error",
319
+ "no-caller": "error",
320
+ "no-case-declarations": "error",
321
+ "no-class-assign": "error",
322
+ "no-compare-neg-zero": "error",
323
+ "no-cond-assign": ["error", "always"],
324
+ "no-console": ["error", { allow: ["warn", "error"] }],
325
+ "no-const-assign": "error",
326
+ "no-constant-binary-expression": "error",
327
+ "no-constant-condition": "error",
328
+ "no-control-regex": "error",
329
+ "no-debugger": "error",
330
+ "no-delete-var": "error",
331
+ "no-dupe-args": "error",
332
+ "no-dupe-class-members": "error",
333
+ "no-dupe-else-if": "error",
334
+ "no-dupe-keys": "error",
335
+ "no-duplicate-case": "error",
336
+ "no-duplicate-imports": "error",
337
+ "no-empty-character-class": "error",
338
+ "no-empty-pattern": "error",
339
+ "no-empty-static-block": "error",
340
+ "no-empty": ["error", { allowEmptyCatch: true }],
341
+ "no-eval": "error",
342
+ "no-ex-assign": "error",
343
+ "no-extend-native": "error",
344
+ "no-extra-bind": "error",
345
+ "no-extra-boolean-cast": "error",
346
+ "no-fallthrough": "error",
347
+ "no-func-assign": "error",
348
+ "no-global-assign": "error",
349
+ "no-implied-eval": "error",
350
+ "no-import-assign": "error",
351
+ "no-invalid-regexp": "error",
352
+ "no-irregular-whitespace": "error",
353
+ "no-iterator": "error",
354
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
355
+ "no-lone-blocks": "error",
356
+ "no-lonely-if": "error",
357
+ "no-loss-of-precision": "error",
358
+ "no-misleading-character-class": "error",
359
+ "no-multi-str": "error",
360
+ "no-new-func": "error",
361
+ "no-new-native-nonconstructor": "error",
362
+ "no-new-wrappers": "error",
363
+ "no-new": "error",
364
+ "no-nonoctal-decimal-escape": "error",
365
+ "no-obj-calls": "error",
366
+ "no-octal-escape": "error",
367
+ "no-octal": "error",
368
+ "no-proto": "error",
369
+ "no-prototype-builtins": "error",
370
+ "no-redeclare": ["error", { builtinGlobals: false }],
371
+ "no-regex-spaces": "error",
372
+ "no-restricted-globals": [
373
+ "error",
374
+ { message: "Use `globalThis` instead.", name: "global" },
375
+ { message: "Use `globalThis` instead.", name: "self" }
376
+ ],
377
+ "no-restricted-properties": [
378
+ "error",
379
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
380
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
381
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
382
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
383
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
384
+ ],
385
+ "no-restricted-syntax": [
386
+ "error",
387
+ "DebuggerStatement",
388
+ "LabeledStatement",
389
+ "WithStatement",
390
+ "TSEnumDeclaration[const=true]",
391
+ "TSExportAssignment"
392
+ ],
393
+ "no-return-assign": ["error", "except-parens"],
394
+ "no-self-assign": ["error", { props: true }],
395
+ "no-self-compare": "error",
396
+ "no-sequences": "error",
397
+ "no-setter-return": "error",
398
+ "no-shadow-restricted-names": "error",
399
+ "no-sparse-arrays": "error",
400
+ "no-template-curly-in-string": "error",
401
+ "no-this-before-super": "error",
402
+ "no-throw-literal": "error",
403
+ "no-undef-init": "error",
404
+ "no-undef": "error",
405
+ "no-unexpected-multiline": "error",
406
+ "no-unmodified-loop-condition": "error",
407
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
408
+ "no-unreachable": "error",
409
+ "no-unreachable-loop": "error",
410
+ "no-unsafe-finally": "error",
411
+ "no-unsafe-negation": "error",
412
+ "no-unsafe-optional-chaining": "error",
413
+ "no-unused-expressions": [
414
+ "error",
415
+ {
416
+ allowShortCircuit: true,
417
+ allowTaggedTemplates: true,
418
+ allowTernary: true
419
+ }
420
+ ],
421
+ "no-unused-private-class-members": "error",
422
+ "no-unused-vars": "off",
423
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
424
+ "no-useless-backreference": "error",
425
+ "no-useless-call": "error",
426
+ "no-useless-catch": "error",
427
+ "no-useless-computed-key": "error",
428
+ "no-useless-constructor": "error",
429
+ "no-useless-escape": "error",
430
+ "no-useless-rename": "error",
431
+ "no-useless-return": "error",
432
+ "no-var": "error",
433
+ "no-void": ["error", { allowAsStatement: true }],
434
+ "no-with": "error",
435
+ "object-shorthand": [
436
+ "error",
437
+ "always",
438
+ {
439
+ avoidQuotes: true,
440
+ ignoreConstructors: false
441
+ }
442
+ ],
443
+ "one-var": ["error", { initialized: "never" }],
444
+ "prefer-arrow-callback": [
445
+ "error",
446
+ {
447
+ allowNamedFunctions: false,
448
+ allowUnboundThis: true
449
+ }
450
+ ],
451
+ "prefer-const": [
452
+ "error",
453
+ {
454
+ destructuring: "all",
455
+ ignoreReadBeforeAssign: true
456
+ }
457
+ ],
458
+ "prefer-exponentiation-operator": "error",
459
+ "prefer-promise-reject-errors": "error",
460
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
461
+ "prefer-rest-params": "error",
462
+ "prefer-spread": "error",
463
+ "prefer-template": "error",
464
+ "require-await": "error",
465
+ "require-yield": "error",
466
+ "sort-imports": [
467
+ "error",
468
+ {
469
+ allowSeparatedGroups: false,
470
+ ignoreCase: false,
471
+ ignoreDeclarationSort: true,
472
+ ignoreMemberSort: false,
473
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
474
+ }
475
+ ],
476
+ "symbol-description": "error",
477
+ "unicode-bom": ["error", "never"],
478
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
479
+ "unused-imports/no-unused-vars": [
480
+ "error",
481
+ {
482
+ args: "after-used",
483
+ argsIgnorePattern: "^_",
484
+ ignoreRestSiblings: true,
485
+ vars: "all",
486
+ varsIgnorePattern: "^_"
487
+ }
488
+ ],
489
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
490
+ "valid-typeof": ["error", { requireStringLiterals: true }],
491
+ "vars-on-top": "error",
492
+ yoda: ["error", "never"],
493
+ ...overrides
494
+ }
495
+ },
496
+ {
497
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
498
+ name: "javascript/disables/cli",
499
+ rules: {
500
+ "no-console": "off"
501
+ }
502
+ },
503
+ {
504
+ files: ["**/*.{test,spec}.js?(x)"],
505
+ name: "javascript/disables/test",
506
+ rules: {
507
+ "no-unused-expressions": "off"
508
+ }
509
+ }
510
+ ];
511
+ }
512
+
513
+ // src/configs/jsonc.ts
514
+ async function jsonc(options = {}) {
515
+ const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC] } = options;
516
+ const [pluginJsonc, parserJsonc] = await Promise.all([
517
+ interopDefault(import("eslint-plugin-jsonc")),
518
+ interopDefault(import("jsonc-eslint-parser"))
519
+ ]);
520
+ return [
521
+ {
522
+ name: "jsonc",
523
+ files,
524
+ languageOptions: {
525
+ parser: parserJsonc
526
+ },
527
+ plugins: {
528
+ jsonc: pluginJsonc
529
+ },
530
+ rules: {
531
+ ...pluginJsonc.configs["recommended-with-jsonc"].rules,
532
+ ...pluginJsonc.configs.prettier.rules
533
+ }
534
+ }
535
+ ];
536
+ }
537
+
538
+ // src/configs/node.ts
539
+ import pluginNode from "eslint-plugin-n";
540
+ function node() {
541
+ return [
542
+ {
543
+ name: "node",
544
+ plugins: {
545
+ n: pluginNode
546
+ },
547
+ rules: {
548
+ "n/handle-callback-err": ["error", "^(err|error)$"],
549
+ "n/no-deprecated-api": "error",
550
+ "n/no-exports-assign": "error",
551
+ "n/no-new-require": "error",
552
+ "n/no-path-concat": "error",
553
+ "n/prefer-global/buffer": ["error", "always"],
554
+ "n/prefer-global/console": ["error", "always"],
555
+ "n/prefer-global/process": ["error", "always"],
556
+ "n/prefer-global/text-decoder": ["error", "always"],
557
+ "n/prefer-global/text-encoder": ["error", "always"],
558
+ "n/prefer-global/url": ["error", "always"],
559
+ "n/prefer-global/url-search-params": ["error", "always"],
560
+ "n/process-exit-as-throw": "error"
561
+ }
562
+ }
563
+ ];
564
+ }
565
+
566
+ // src/configs/sort.ts
567
+ function sortPackageJson() {
568
+ return [
569
+ {
570
+ files: ["**/package.json"],
571
+ name: "sort/package-json",
572
+ rules: {
573
+ "jsonc/sort-array-values": [
574
+ "error",
575
+ {
576
+ order: { type: "asc" },
577
+ pathPattern: "^files$"
578
+ }
579
+ ],
580
+ "jsonc/sort-keys": [
581
+ "error",
582
+ {
583
+ order: [
584
+ "publisher",
585
+ "name",
586
+ "displayName",
587
+ "type",
588
+ "version",
589
+ "private",
590
+ "packageManager",
591
+ "description",
592
+ "author",
593
+ "contributors",
594
+ "license",
595
+ "funding",
596
+ "homepage",
597
+ "repository",
598
+ "bugs",
599
+ "keywords",
600
+ "categories",
601
+ "sideEffects",
602
+ "exports",
603
+ "main",
604
+ "module",
605
+ "unpkg",
606
+ "jsdelivr",
607
+ "types",
608
+ "typesVersions",
609
+ "bin",
610
+ "icon",
611
+ "files",
612
+ "engines",
613
+ "activationEvents",
614
+ "contributes",
615
+ "scripts",
616
+ "peerDependencies",
617
+ "peerDependenciesMeta",
618
+ "dependencies",
619
+ "optionalDependencies",
620
+ "devDependencies",
621
+ "pnpm",
622
+ "overrides",
623
+ "resolutions",
624
+ "husky",
625
+ "simple-git-hooks",
626
+ "lint-staged",
627
+ "eslintConfig",
628
+ "prettier",
629
+ "stylelint"
630
+ ],
631
+ pathPattern: "^$"
632
+ },
633
+ {
634
+ order: { type: "asc" },
635
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
636
+ },
637
+ {
638
+ order: { type: "asc" },
639
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
640
+ },
641
+ {
642
+ order: ["types", "import", "require", "default"],
643
+ pathPattern: "^exports.*$"
644
+ },
645
+ {
646
+ order: [
647
+ // client hooks only
648
+ "pre-commit",
649
+ "prepare-commit-msg",
650
+ "commit-msg",
651
+ "post-commit",
652
+ "pre-rebase",
653
+ "post-rewrite",
654
+ "post-checkout",
655
+ "post-merge",
656
+ "pre-push",
657
+ "pre-auto-gc"
658
+ ],
659
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
660
+ }
661
+ ]
662
+ }
663
+ }
664
+ ];
665
+ }
666
+ function sortTsconfig() {
667
+ return [
668
+ {
669
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
670
+ name: "sort/tsconfig-json",
671
+ rules: {
672
+ "jsonc/sort-keys": [
673
+ "error",
674
+ {
675
+ order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
676
+ pathPattern: "^$"
677
+ },
678
+ {
679
+ order: [
680
+ /* Projects */
681
+ "incremental",
682
+ "composite",
683
+ "tsBuildInfoFile",
684
+ "disableSourceOfProjectReferenceRedirect",
685
+ "disableSolutionSearching",
686
+ "disableReferencedProjectLoad",
687
+ /* Language and Environment */
688
+ "target",
689
+ "jsx",
690
+ "jsxFactory",
691
+ "jsxFragmentFactory",
692
+ "jsxImportSource",
693
+ "lib",
694
+ "moduleDetection",
695
+ "noLib",
696
+ "reactNamespace",
697
+ "useDefineForClassFields",
698
+ "emitDecoratorMetadata",
699
+ "experimentalDecorators",
700
+ /* Modules */
701
+ "baseUrl",
702
+ "rootDir",
703
+ "rootDirs",
704
+ "customConditions",
705
+ "module",
706
+ "moduleResolution",
707
+ "moduleSuffixes",
708
+ "noResolve",
709
+ "paths",
710
+ "resolveJsonModule",
711
+ "resolvePackageJsonExports",
712
+ "resolvePackageJsonImports",
713
+ "typeRoots",
714
+ "types",
715
+ "allowArbitraryExtensions",
716
+ "allowImportingTsExtensions",
717
+ "allowUmdGlobalAccess",
718
+ /* JavaScript Support */
719
+ "allowJs",
720
+ "checkJs",
721
+ "maxNodeModuleJsDepth",
722
+ /* Type Checking */
723
+ "strict",
724
+ "strictBindCallApply",
725
+ "strictFunctionTypes",
726
+ "strictNullChecks",
727
+ "strictPropertyInitialization",
728
+ "allowUnreachableCode",
729
+ "allowUnusedLabels",
730
+ "alwaysStrict",
731
+ "exactOptionalPropertyTypes",
732
+ "noFallthroughCasesInSwitch",
733
+ "noImplicitAny",
734
+ "noImplicitOverride",
735
+ "noImplicitReturns",
736
+ "noImplicitThis",
737
+ "noPropertyAccessFromIndexSignature",
738
+ "noUncheckedIndexedAccess",
739
+ "noUnusedLocals",
740
+ "noUnusedParameters",
741
+ "useUnknownInCatchVariables",
742
+ /* Emit */
743
+ "declaration",
744
+ "declarationDir",
745
+ "declarationMap",
746
+ "downlevelIteration",
747
+ "emitBOM",
748
+ "emitDeclarationOnly",
749
+ "importHelpers",
750
+ "importsNotUsedAsValues",
751
+ "inlineSourceMap",
752
+ "inlineSources",
753
+ "mapRoot",
754
+ "newLine",
755
+ "noEmit",
756
+ "noEmitHelpers",
757
+ "noEmitOnError",
758
+ "outDir",
759
+ "outFile",
760
+ "preserveConstEnums",
761
+ "preserveValueImports",
762
+ "removeComments",
763
+ "sourceMap",
764
+ "sourceRoot",
765
+ "stripInternal",
766
+ /* Interop Constraints */
767
+ "allowSyntheticDefaultImports",
768
+ "esModuleInterop",
769
+ "forceConsistentCasingInFileNames",
770
+ "isolatedDeclarations",
771
+ "isolatedModules",
772
+ "preserveSymlinks",
773
+ "verbatimModuleSyntax",
774
+ /* Completeness */
775
+ "skipDefaultLibCheck",
776
+ "skipLibCheck"
777
+ ],
778
+ pathPattern: "^compilerOptions$"
779
+ }
780
+ ]
781
+ }
782
+ }
783
+ ];
784
+ }
785
+
786
+ // src/configs/test.ts
787
+ var _pluginTest;
788
+ async function test(options = {}) {
789
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
790
+ const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
791
+ interopDefault(import("eslint-plugin-vitest")),
792
+ interopDefault(import("eslint-plugin-no-only-tests"))
793
+ ]);
794
+ _pluginTest = _pluginTest || {
795
+ ...pluginVitest,
796
+ rules: {
797
+ ...pluginVitest.rules,
798
+ ...pluginNoOnlyTests.rules
799
+ }
800
+ };
801
+ return [
802
+ {
803
+ files,
804
+ name: "test",
805
+ plugins: {
806
+ test: _pluginTest
807
+ },
808
+ rules: {
809
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
810
+ "test/no-identical-title": "error",
811
+ "test/no-import-node-test": "error",
812
+ "test/no-only-tests": isInEditor ? "off" : "error",
813
+ "test/prefer-hooks-in-order": "error",
814
+ "test/prefer-lowercase-title": "error",
815
+ "@typescript-eslint/explicit-function-return-type": "off",
816
+ ...overrides
817
+ }
818
+ }
819
+ ];
820
+ }
821
+
822
+ // src/configs/typescript.ts
823
+ async function typescript(options = {}) {
824
+ const { componentExts = [], overrides = {}, parserOptions = {}, type = "app" } = options;
825
+ const files = options.files ?? [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)];
826
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
827
+ const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
828
+ const tsconfigPath = options?.tsconfigPath;
829
+ const isTypeAware = !!tsconfigPath;
830
+ const [pluginTs, parserTs] = await Promise.all([
831
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
832
+ interopDefault(import("@typescript-eslint/parser"))
833
+ ]);
834
+ function makeParser(typeAware, files2, ignores2) {
835
+ return {
836
+ files: files2,
837
+ ...ignores2 ? { ignores: ignores2 } : {},
838
+ languageOptions: {
839
+ parser: parserTs,
840
+ parserOptions: {
841
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
842
+ sourceType: "module",
843
+ ...typeAware ? {
844
+ projectService: {
845
+ allowDefaultProject: ["./*.js"],
846
+ defaultProject: tsconfigPath
847
+ },
848
+ tsconfigRootDir: process.cwd()
849
+ } : {},
850
+ ...parserOptions
851
+ }
852
+ },
853
+ name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
854
+ };
855
+ }
856
+ return [
857
+ {
858
+ // Install the plugins without globs, so they can be configured separately.
859
+ name: "typescript/setup",
860
+ plugins: {
861
+ "@typescript-eslint": pluginTs
862
+ }
863
+ },
864
+ // assign type-aware parser for type-aware files and type-unaware parser for the rest
865
+ ...isTypeAware ? [makeParser(true, filesTypeAware, ignoresTypeAware), makeParser(false, files, filesTypeAware)] : [makeParser(false, files)],
866
+ {
867
+ files,
868
+ name: "typescript/rules",
869
+ rules: {
870
+ ...pluginTs.configs["eslint-recommended"].overrides[0].rules,
871
+ ...pluginTs.configs.strict.rules,
872
+ "@typescript-eslint/consistent-type-assertions": "error",
873
+ "@typescript-eslint/consistent-type-definitions": "off",
874
+ "@typescript-eslint/consistent-type-imports": [
875
+ "error",
876
+ { disallowTypeAnnotations: false, prefer: "type-imports", fixStyle: "inline-type-imports" }
877
+ ],
878
+ "@typescript-eslint/method-signature-style": "error",
879
+ "@typescript-eslint/no-dynamic-delete": "off",
880
+ "@typescript-eslint/no-explicit-any": "off",
881
+ "@typescript-eslint/no-import-type-side-effects": "error",
882
+ "@typescript-eslint/no-invalid-void-type": "off",
883
+ "@typescript-eslint/no-non-null-assertion": "off",
884
+ "@typescript-eslint/no-require-imports": "error",
885
+ "@typescript-eslint/triple-slash-reference": "off",
886
+ "@typescript-eslint/unified-signatures": "off",
887
+ // handled by unused-imports/no-unused-imports
888
+ "@typescript-eslint/no-unused-vars": "off",
889
+ "no-dupe-class-members": "off",
890
+ "@typescript-eslint/no-dupe-class-members": "error",
891
+ "no-invalid-this": "off",
892
+ "@typescript-eslint/no-invalid-this": "error",
893
+ "no-redeclare": "off",
894
+ "@typescript-eslint/no-redeclare": "error",
895
+ "no-unused-expressions": "off",
896
+ "@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }],
897
+ "no-use-before-define": "off",
898
+ "@typescript-eslint/no-use-before-define": "error",
899
+ ...type === "lib" ? {
900
+ "@typescript-eslint/explicit-function-return-type": [
901
+ "error",
902
+ {
903
+ allowExpressions: true,
904
+ allowHigherOrderFunctions: true,
905
+ allowIIFEs: true
906
+ }
907
+ ]
908
+ } : {},
909
+ ...overrides
910
+ }
911
+ },
912
+ ...isTypeAware ? [
913
+ {
914
+ files: filesTypeAware,
915
+ ignores: ignoresTypeAware,
916
+ name: "typescript/rules-type-aware",
917
+ rules: {
918
+ ...tsconfigPath ? {
919
+ ...pluginTs.configs["recommended-type-checked-only"].rules,
920
+ "@typescript-eslint/no-confusing-void-expression": "error",
921
+ "@typescript-eslint/promise-function-async": "error",
922
+ "@typescript-eslint/restrict-template-expressions": "off",
923
+ "@typescript-eslint/strict-boolean-expressions": "off",
924
+ "dot-notation": "off",
925
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
926
+ "no-throw-literal": "off",
927
+ "@typescript-eslint/only-throw-error": "error"
928
+ } : {},
929
+ ...overrides
930
+ }
931
+ }
932
+ ] : [],
933
+ {
934
+ files: ["**/*.d.?([cm])ts"],
935
+ name: "typescript/disables/dts",
936
+ rules: {
937
+ "eslint-comments/no-unlimited-disable": "off",
938
+ "import/no-duplicates": "off",
939
+ "no-restricted-syntax": "off",
940
+ "unused-imports/no-unused-vars": "off"
941
+ }
942
+ },
943
+ {
944
+ files: ["**/*.{test,spec}.ts?(x)"],
945
+ name: "typescript/disables/test",
946
+ rules: {
947
+ "no-unused-expressions": "off"
948
+ }
949
+ },
950
+ {
951
+ files: ["**/*.js", "**/*.cjs"],
952
+ name: "typescript/disables/cjs",
953
+ rules: {
954
+ "@typescript-eslint/no-require-imports": "off",
955
+ "@typescript-eslint/no-var-requires": "off"
956
+ }
957
+ }
958
+ ];
959
+ }
960
+
961
+ // src/configs/unicorn.ts
962
+ import pluginUnicorn from "eslint-plugin-unicorn";
963
+ function unicorn() {
964
+ return [
965
+ {
966
+ name: "unicorn",
967
+ plugins: {
968
+ unicorn: pluginUnicorn
969
+ },
970
+ rules: {
971
+ ...pluginUnicorn.configs["flat/recommended"].rules,
972
+ "unicorn/consistent-function-scoping": "off",
973
+ "unicorn/filename-case": "off",
974
+ "unicorn/no-array-callback-reference": "off",
975
+ "unicorn/no-null": "off",
976
+ "unicorn/prefer-string-replace-all": "off",
977
+ "unicorn/prefer-top-level-await": "off",
978
+ "unicorn/prevent-abbreviations": "off"
979
+ }
980
+ }
981
+ ];
982
+ }
983
+
984
+ // src/configs/unocss.ts
985
+ async function unocss() {
986
+ const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
987
+ return [
988
+ {
989
+ ...pluginUnoCSS.configs.flat,
990
+ name: "unocss"
991
+ }
992
+ ];
993
+ }
994
+
995
+ // src/configs/vue.ts
996
+ async function vue(options = {}) {
997
+ const { files = [GLOB_VUE], overrides = {}, vueVersion = 3 } = options;
998
+ const [pluginVue, parserVue] = await Promise.all([
999
+ interopDefault(import("eslint-plugin-vue")),
1000
+ interopDefault(import("vue-eslint-parser"))
1001
+ ]);
1002
+ return [
1003
+ {
1004
+ files,
1005
+ languageOptions: {
1006
+ parser: parserVue,
1007
+ globals: {
1008
+ computed: "readonly",
1009
+ defineEmits: "readonly",
1010
+ defineExpose: "readonly",
1011
+ defineProps: "readonly",
1012
+ onMounted: "readonly",
1013
+ onUnmounted: "readonly",
1014
+ reactive: "readonly",
1015
+ ref: "readonly",
1016
+ shallowReactive: "readonly",
1017
+ shallowRef: "readonly",
1018
+ toRef: "readonly",
1019
+ toRefs: "readonly",
1020
+ watch: "readonly",
1021
+ watchEffect: "readonly"
1022
+ },
1023
+ parserOptions: {
1024
+ ecmaFeatures: {
1025
+ jsx: true
1026
+ },
1027
+ extraFileExtensions: [".vue"],
1028
+ parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
1029
+ sourceType: "module"
1030
+ }
1031
+ },
1032
+ name: "vue",
1033
+ processor: pluginVue.processors[".vue"],
1034
+ plugins: {
1035
+ vue: pluginVue
1036
+ },
1037
+ rules: {
1038
+ ...pluginVue.configs.base.rules,
1039
+ ...vueVersion === 2 ? {
1040
+ ...pluginVue.configs.essential.rules,
1041
+ ...pluginVue.configs["strongly-recommended"].rules,
1042
+ ...pluginVue.configs.recommended.rules
1043
+ } : {
1044
+ ...pluginVue.configs["vue3-essential"].rules,
1045
+ ...pluginVue.configs["vue3-strongly-recommended"].rules,
1046
+ ...pluginVue.configs["vue3-recommended"].rules
1047
+ },
1048
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1049
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1050
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1051
+ "vue/define-macros-order": [
1052
+ "error",
1053
+ {
1054
+ order: ["defineOptions", "defineModel", "defineProps", "defineEmits", "defineSlots"]
1055
+ }
1056
+ ],
1057
+ "vue/dot-notation": "error",
1058
+ "vue/eqeqeq": ["error", "smart"],
1059
+ "vue/html-comment-content-spacing": ["error", "always", { exceptions: ["-"] }],
1060
+ "vue/no-constant-condition": "error",
1061
+ "vue/no-empty-pattern": "error",
1062
+ "vue/no-irregular-whitespace": "error",
1063
+ "vue/no-loss-of-precision": "error",
1064
+ "vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
1065
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1066
+ "vue/no-sparse-arrays": "error",
1067
+ "vue/no-unused-refs": "error",
1068
+ "vue/no-useless-v-bind": "error",
1069
+ "vue/no-v-html": "off",
1070
+ "vue/object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
1071
+ "vue/prefer-separate-static-class": "error",
1072
+ "vue/prefer-template": "error",
1073
+ "vue/padding-line-between-blocks": ["error", "always"],
1074
+ "vue/component-tags-order": "off",
1075
+ ...overrides
1076
+ }
1077
+ }
1078
+ ];
1079
+ }
1080
+
1081
+ // src/configs/regexp.ts
1082
+ import { configs } from "eslint-plugin-regexp";
1083
+ function regexp(options = {}) {
1084
+ const config = configs["flat/recommended"];
1085
+ return [
1086
+ {
1087
+ ...config,
1088
+ name: "regexp",
1089
+ rules: {
1090
+ ...config.rules,
1091
+ ...options.overrides
1092
+ }
1093
+ }
1094
+ ];
1095
+ }
1096
+
1097
+ // src/factory.ts
1098
+ import { isPackageExists } from "local-pkg";
1099
+ import { FlatConfigComposer } from "eslint-flat-config-utils";
1100
+ var flatConfigProps = [
1101
+ "name",
1102
+ "files",
1103
+ "ignores",
1104
+ "languageOptions",
1105
+ "linterOptions",
1106
+ "processor",
1107
+ "plugins",
1108
+ "rules",
1109
+ "settings"
1110
+ ];
1111
+ var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1112
+ var factoryConfig = function(options = {}, ...userConfigs) {
1113
+ const {
1114
+ componentExts = [],
1115
+ formatters: enableFormatters = true,
1116
+ gitignore: enableGitignore = true,
1117
+ isInEditor = isInEditorEnv(),
1118
+ jsonc: enableJSONC = true,
1119
+ regexp: enableRegexp = true,
1120
+ test: enableTest = true,
1121
+ typescript: enableTypeScript = isPackageExists("typescript"),
1122
+ unocss: enableUnoCSS = isPackageExists("unocss"),
1123
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i))
1124
+ } = options;
1125
+ const configs2 = [];
1126
+ if (enableGitignore) {
1127
+ if (typeof enableGitignore === "boolean") {
1128
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
1129
+ } else {
1130
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
1131
+ }
1132
+ }
1133
+ configs2.push(
1134
+ comments(),
1135
+ ignores(),
1136
+ imports(),
1137
+ javascript({
1138
+ isInEditor,
1139
+ overrides: options.javascript?.overrides
1140
+ }),
1141
+ node(),
1142
+ unicorn()
1143
+ );
1144
+ if (enableVue) {
1145
+ componentExts.push("vue");
1146
+ }
1147
+ if (enableTypeScript) {
1148
+ configs2.push(
1149
+ typescript({
1150
+ ...typeof enableTypeScript === "boolean" ? {} : enableTypeScript || {},
1151
+ componentExts,
1152
+ type: options.type
1153
+ })
1154
+ );
1155
+ }
1156
+ if (enableRegexp) {
1157
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1158
+ }
1159
+ if (enableTest) {
1160
+ configs2.push(
1161
+ test({
1162
+ isInEditor,
1163
+ overrides: typeof enableTest === "boolean" ? {} : enableTest?.overrides
1164
+ })
1165
+ );
1166
+ }
1167
+ if (enableVue) {
1168
+ configs2.push(
1169
+ vue({
1170
+ ...typeof enableVue === "boolean" ? {} : enableVue || {},
1171
+ typescript: !!enableTypeScript
1172
+ })
1173
+ );
1174
+ }
1175
+ if (enableUnoCSS) {
1176
+ configs2.push(unocss());
1177
+ }
1178
+ if (enableJSONC) {
1179
+ configs2.push(jsonc(typeof enableJSONC === "boolean" ? {} : enableJSONC), sortPackageJson(), sortTsconfig());
1180
+ }
1181
+ if (enableFormatters) {
1182
+ configs2.push(formatters(enableFormatters));
1183
+ }
1184
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1185
+ if (key in options) acc[key] = options[key];
1186
+ return acc;
1187
+ }, {});
1188
+ if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
1189
+ let composer = new FlatConfigComposer();
1190
+ composer = composer.append(...configs2, ...userConfigs);
1191
+ return composer;
1192
+ };
1193
+ export {
1194
+ GLOB_ALL_SRC,
1195
+ GLOB_ASTRO,
1196
+ GLOB_ASTRO_TS,
1197
+ GLOB_CSS,
1198
+ GLOB_EXCLUDE,
1199
+ GLOB_GRAPHQL,
1200
+ GLOB_HTML,
1201
+ GLOB_JS,
1202
+ GLOB_JSON,
1203
+ GLOB_JSON5,
1204
+ GLOB_JSONC,
1205
+ GLOB_JSX,
1206
+ GLOB_LESS,
1207
+ GLOB_MARKDOWN,
1208
+ GLOB_MARKDOWN_CODE,
1209
+ GLOB_MARKDOWN_IN_MARKDOWN,
1210
+ GLOB_POSTCSS,
1211
+ GLOB_SCSS,
1212
+ GLOB_SRC,
1213
+ GLOB_SRC_EXT,
1214
+ GLOB_STYLE,
1215
+ GLOB_SVELTE,
1216
+ GLOB_TESTS,
1217
+ GLOB_TOML,
1218
+ GLOB_TS,
1219
+ GLOB_TSX,
1220
+ GLOB_VUE,
1221
+ GLOB_XML,
1222
+ GLOB_YAML,
1223
+ combine,
1224
+ comments,
1225
+ factoryConfig,
1226
+ formatters,
1227
+ ignores,
1228
+ imports,
1229
+ interopDefault,
1230
+ isInEditorEnv,
1231
+ javascript,
1232
+ jsonc,
1233
+ node,
1234
+ parserPlain,
1235
+ regexp,
1236
+ sortPackageJson,
1237
+ sortTsconfig,
1238
+ test,
1239
+ toArray,
1240
+ typescript,
1241
+ unicorn,
1242
+ unocss,
1243
+ vue
1244
+ };