@dhzh/eslint-config 1.25.2 → 1.27.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 DELETED
@@ -1,1820 +0,0 @@
1
- // src/configs/react.ts
2
- import pluginReact from "@eslint-react/eslint-plugin";
3
- import pluginReactHooks from "eslint-plugin-react-hooks";
4
- import pluginReactRefresh from "eslint-plugin-react-refresh";
5
- import pluginReactCompiler from "eslint-plugin-react-compiler";
6
- import pluginReactGoogleTranslate from "eslint-plugin-react-google-translate";
7
- import { isPackageExists } from "local-pkg";
8
- import { defineConfig } from "eslint/config";
9
-
10
- // src/consts.ts
11
- var RULE_PREFIX = "tinywaves";
12
- var GLOB_YML = "**/*.y?(a)ml";
13
- var GLOB_TOML = "**/*.toml";
14
- var GLOB_JSON = "**/*.json";
15
- var GLOB_JSON5 = "**/*.json5";
16
- var GLOB_JSONC = "**/*.jsonc";
17
- var GLOB_PACKAGE_JSON = "**/package.json";
18
- var GLOB_HTML = "**/*.htm?(l)";
19
- var GLOB_CSS = "**/*.css";
20
- var GLOB_POSTCSS = "**/*.{p,post}css";
21
- var GLOB_LESS = "**/*.less";
22
- var GLOB_SCSS = "**/*.scss";
23
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
24
- var GLOB_XML = "**/*.xml";
25
- var GLOB_SVG = "**/*.svg";
26
- var GLOB_VUE = "**/*.vue";
27
- var GLOB_JSON_SRC = [
28
- GLOB_JSON,
29
- GLOB_JSON5,
30
- GLOB_JSONC,
31
- GLOB_PACKAGE_JSON
32
- ];
33
- var GLOB_TS_SRC = [
34
- "**/*.cts",
35
- "**/*.mts",
36
- "**/*.ts",
37
- "**/*.tsx"
38
- ];
39
- var GLOB_JS_SRC = [
40
- "**/*.cjs",
41
- "**/*.mjs",
42
- "**/*.js",
43
- "**/*.jsx"
44
- ];
45
- var GLOB_JSX_SRC = [
46
- "**/*.jsx",
47
- "**/*.tsx"
48
- ];
49
- var GLOB_SRC = [
50
- ...GLOB_TS_SRC,
51
- ...GLOB_JS_SRC
52
- ];
53
- var GLOB_SRC_EXT = GLOB_SRC.map((item) => item.replace("**/*.", ""));
54
- var GLOB_TESTS = GLOB_SRC_EXT.flatMap((item) => [
55
- `**/__tests__/**/*.${item}`,
56
- `**/*.spec.${item}`,
57
- `**/*.test.${item}`,
58
- `**/*.bench.${item}`,
59
- `**/*.benchmark.${item}`
60
- ]);
61
- var GLOB_EXCLUDE = [
62
- "**/node_modules",
63
- "**/dist",
64
- "**/package-lock.json",
65
- "**/yarn.lock",
66
- "**/pnpm-lock.yaml",
67
- "**/bun.lockb",
68
- "**/output",
69
- "**/coverage",
70
- "**/temp",
71
- "**/.temp",
72
- "**/tmp",
73
- "**/.tmp",
74
- "**/.history",
75
- "**/.vitepress/cache",
76
- "**/.nuxt",
77
- "**/.next",
78
- "**/.svelte-kit",
79
- "**/.vercel",
80
- "**/.changeset",
81
- "**/.idea",
82
- "**/.cache",
83
- "**/.output",
84
- "**/.vite-inspect",
85
- "**/.yarn",
86
- "**/vite.config.*.timestamp-*",
87
- "**/CHANGELOG*.md",
88
- "**/*.min.*",
89
- "**/LICENSE*",
90
- "**/__snapshots__",
91
- "**/auto-import?(s).d.ts",
92
- "**/components.d.ts"
93
- ];
94
-
95
- // src/utils.ts
96
- var parserPlain = {
97
- meta: {
98
- name: "parser-plain"
99
- },
100
- parseForESLint: (code) => ({
101
- ast: {
102
- body: [],
103
- comments: [],
104
- loc: {
105
- end: code.length,
106
- start: 0
107
- },
108
- range: [0, code.length],
109
- tokens: [],
110
- type: "Program"
111
- },
112
- scopeManager: null,
113
- services: {
114
- isPlain: true
115
- },
116
- visitorKeys: {
117
- Program: []
118
- }
119
- })
120
- };
121
- var mergeRule = (...rules) => {
122
- let finalLevel;
123
- let finalOptions = {};
124
- for (const rule of rules) {
125
- if (!rule) {
126
- continue;
127
- }
128
- if (!Array.isArray(rule)) {
129
- finalLevel = rule;
130
- continue;
131
- }
132
- const [level, options] = rule;
133
- finalLevel = level;
134
- if (options && typeof options === "object") {
135
- finalOptions = {
136
- ...finalOptions,
137
- ...options
138
- };
139
- }
140
- }
141
- if (Object.keys(finalOptions).length === 0) {
142
- return finalLevel;
143
- }
144
- return [finalLevel, finalOptions];
145
- };
146
-
147
- // src/configs/react.ts
148
- var ReactRefreshAllowConstantExportPackages = ["vite"];
149
- var RemixPackages = [
150
- "@remix-run/node",
151
- "@remix-run/react",
152
- "@remix-run/serve",
153
- "@remix-run/dev"
154
- ];
155
- var ReactRouterPackages = [
156
- "@react-router/node",
157
- "@react-router/react",
158
- "@react-router/serve",
159
- "@react-router/dev"
160
- ];
161
- var NextJsPackages = ["next"];
162
- var ExpoPackages = ["expo"];
163
- function react(options = {}) {
164
- const {
165
- language = "typescript",
166
- overrides = { compiler: {}, core: {}, hooks: {}, refresh: {}, googleTranslate: {} }
167
- } = options;
168
- const config = language === "typescript" ? pluginReact.configs["recommended-type-checked"] : pluginReact.configs.recommended;
169
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
170
- const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
171
- const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
172
- const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
173
- const isUsingExpo = ExpoPackages.some((i) => isPackageExists(i));
174
- return [
175
- {
176
- ...config,
177
- name: `${RULE_PREFIX}/react/core/shared`,
178
- files: GLOB_SRC
179
- },
180
- {
181
- name: `${RULE_PREFIX}/react/core/customize`,
182
- files: GLOB_SRC,
183
- rules: {
184
- "@eslint-react/jsx-dollar": "warn",
185
- "@eslint-react/no-missing-context-display-name": "warn",
186
- "@eslint-react/no-missing-component-display-name": "off",
187
- "@eslint-react/dom/no-hydrate": "error",
188
- "@eslint-react/no-useless-fragment": [
189
- "warn",
190
- {
191
- allowEmptyFragment: true,
192
- allowExpressions: true
193
- }
194
- ],
195
- "@eslint-react/no-unnecessary-use-prefix": "warn",
196
- "@eslint-react/naming-convention/use-state": [
197
- "warn",
198
- {
199
- enforceAssignment: true,
200
- enforceSetterName: true
201
- }
202
- ],
203
- "@eslint-react/naming-convention/context-name": "warn",
204
- ...language === "typescript" ? {
205
- "@eslint-react/no-leaked-conditional-rendering": "warn"
206
- } : {},
207
- ...overrides.core
208
- }
209
- },
210
- ...defineConfig([pluginReactHooks.configs.flat["recommended-latest"]]).map((item) => ({
211
- ...item,
212
- name: `${RULE_PREFIX}/react/hooks/shared`,
213
- files: GLOB_SRC
214
- })),
215
- {
216
- name: `${RULE_PREFIX}/react/hooks/customize`,
217
- files: GLOB_SRC,
218
- rules: overrides.hooks || {}
219
- },
220
- {
221
- ...pluginReactRefresh.configs.recommended,
222
- name: `${RULE_PREFIX}/react/refresh/shared`,
223
- files: GLOB_JSX_SRC
224
- },
225
- {
226
- name: `${RULE_PREFIX}/react/refresh/customize`,
227
- files: GLOB_JSX_SRC,
228
- rules: {
229
- "react-refresh/only-export-components": mergeRule(
230
- ["warn", { allowConstantExport: isAllowConstantExport }],
231
- [
232
- "warn",
233
- {
234
- allowExportNames: [
235
- ...isUsingNext ? [
236
- "dynamic",
237
- "dynamicParams",
238
- "revalidate",
239
- "fetchCache",
240
- "runtime",
241
- "preferredRegion",
242
- "maxDuration",
243
- "config",
244
- "generateMetadata",
245
- "generateViewport",
246
- // https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
247
- "experimental_ppr",
248
- // https://nextjs.org/docs/app/api-reference/functions/generate-metadata
249
- "metadata",
250
- // https://nextjs.org/docs/app/api-reference/functions/generate-viewport
251
- "viewport",
252
- // https://nextjs.org/docs/app/api-reference/functions/generate-image-metadata
253
- "generateImageMetadata",
254
- // https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps
255
- "generateSitemaps",
256
- // https://nextjs.org/docs/app/api-reference/functions/generate-static-params
257
- "generateStaticParams"
258
- ] : [],
259
- ...isUsingRemix || isUsingReactRouter ? [
260
- "meta",
261
- "links",
262
- "headers",
263
- "loader",
264
- "action"
265
- ] : [],
266
- ...isUsingExpo ? ["unstable_settings"] : []
267
- ]
268
- }
269
- ]
270
- ),
271
- ...overrides.refresh
272
- }
273
- },
274
- {
275
- ...pluginReactCompiler.configs.recommended,
276
- name: `${RULE_PREFIX}/react/compiler/shared`,
277
- files: GLOB_SRC
278
- },
279
- {
280
- name: `${RULE_PREFIX}/react/compiler/customize`,
281
- files: GLOB_SRC,
282
- rules: overrides.compiler || {}
283
- },
284
- {
285
- name: `${RULE_PREFIX}/react/google-translate`,
286
- files: GLOB_JSX_SRC,
287
- plugins: {
288
- "react-google-translate": pluginReactGoogleTranslate
289
- },
290
- rules: {
291
- "react-google-translate/no-conditional-text-nodes-with-siblings": "warn",
292
- "react-google-translate/no-return-text-nodes": "warn",
293
- ...overrides.googleTranslate
294
- }
295
- }
296
- ];
297
- }
298
-
299
- // src/configs/vue.ts
300
- import { defineConfig as defineConfig2 } from "eslint/config";
301
- import js from "@eslint/js";
302
- import tseslint from "typescript-eslint";
303
- import pluginVue from "eslint-plugin-vue";
304
- import globals from "globals";
305
- import { mergeProcessors } from "eslint-merge-processors";
306
- import processorVueBlocks from "eslint-processor-vue-blocks";
307
- function vue(options = {}) {
308
- const { overrides = {} } = options;
309
- return defineConfig2(
310
- {
311
- ...js.configs.recommended,
312
- name: `${RULE_PREFIX}/vue/shared/javascript`,
313
- files: [GLOB_VUE]
314
- },
315
- tseslint.configs.recommended.map((item) => ({
316
- ...item,
317
- name: `${RULE_PREFIX}/vue/shared/typescript/${item.name?.replace("typescript-eslint/", "")}`,
318
- files: [GLOB_VUE]
319
- })),
320
- pluginVue.configs["flat/recommended"].map((item) => ({
321
- ...item,
322
- name: `${RULE_PREFIX}/vue/shared/${item.name?.replace("vue/", "")}`,
323
- files: [GLOB_VUE]
324
- })),
325
- {
326
- name: `${RULE_PREFIX}/vue/customize`,
327
- files: [GLOB_VUE],
328
- languageOptions: {
329
- ecmaVersion: "latest",
330
- sourceType: "module",
331
- globals: globals.browser,
332
- parserOptions: {
333
- parser: tseslint.parser
334
- }
335
- },
336
- processor: mergeProcessors([
337
- pluginVue.processors[".vue"],
338
- processorVueBlocks({
339
- blocks: {
340
- styles: true,
341
- customBlocks: true,
342
- script: false,
343
- template: false
344
- }
345
- })
346
- ]),
347
- rules: overrides
348
- }
349
- );
350
- }
351
-
352
- // src/configs/stylistic.ts
353
- import pluginStylistic from "@stylistic/eslint-plugin";
354
- import pluginAntfu from "eslint-plugin-antfu";
355
- function stylistic(options = {}) {
356
- const { overrides = {} } = options;
357
- const jsxIgnoreNodes = [
358
- "TemplateLiteral *",
359
- "TSUnionType",
360
- "TSIntersectionType",
361
- "TSTypeParameterInstantiation",
362
- "FunctionExpression > .params[decorators.length > 0]",
363
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))"
364
- ];
365
- const nonJsxIgnoreNodes = [
366
- "JSXOpeningElement",
367
- "JSXClosingElement"
368
- ];
369
- const basicIndentRuleOptions = {
370
- ArrayExpression: 1,
371
- CallExpression: {
372
- arguments: 1
373
- },
374
- flatTernaryExpressions: false,
375
- FunctionDeclaration: {
376
- body: 1,
377
- parameters: 1
378
- },
379
- FunctionExpression: {
380
- body: 1,
381
- parameters: 1
382
- },
383
- ignoreComments: false,
384
- ImportDeclaration: 1,
385
- MemberExpression: 1,
386
- ObjectExpression: 1,
387
- offsetTernaryExpressions: true,
388
- outerIIFEBody: 1,
389
- SwitchCase: 1,
390
- VariableDeclarator: 1
391
- };
392
- return [
393
- {
394
- ...pluginStylistic.configs.customize({
395
- arrowParens: true,
396
- semi: true,
397
- braceStyle: "1tbs"
398
- }),
399
- name: `${RULE_PREFIX}/stylistic/shared`,
400
- files: [...GLOB_SRC, ...GLOB_JSON_SRC, GLOB_VUE]
401
- },
402
- {
403
- name: `${RULE_PREFIX}/stylistic/customize`,
404
- files: [...GLOB_SRC, ...GLOB_JSON_SRC, GLOB_VUE],
405
- plugins: {
406
- stylistic: pluginStylistic,
407
- antfu: pluginAntfu
408
- },
409
- rules: {
410
- "curly": ["error", "all"],
411
- "object-shorthand": "error",
412
- "prefer-destructuring": [
413
- "error",
414
- {
415
- VariableDeclarator: {
416
- array: false,
417
- object: true
418
- },
419
- AssignmentExpression: {
420
- array: false,
421
- object: false
422
- }
423
- },
424
- {
425
- enforceForRenamedProperties: false
426
- }
427
- ],
428
- "prefer-template": "error",
429
- "stylistic/array-bracket-newline": [
430
- "error",
431
- {
432
- multiline: true
433
- }
434
- ],
435
- "stylistic/array-element-newline": ["error", "consistent"],
436
- "stylistic/brace-style": [
437
- "error",
438
- "1tbs",
439
- {
440
- allowSingleLine: false
441
- }
442
- ],
443
- "stylistic/function-call-spacing": ["error", "never"],
444
- "stylistic/function-paren-newline": "off",
445
- "stylistic/indent": [
446
- "error",
447
- 2,
448
- {
449
- ...basicIndentRuleOptions,
450
- ignoredNodes: [
451
- ...jsxIgnoreNodes,
452
- ...nonJsxIgnoreNodes
453
- ]
454
- }
455
- ],
456
- "stylistic/key-spacing": [
457
- "error",
458
- {
459
- beforeColon: false,
460
- afterColon: true,
461
- mode: "strict"
462
- }
463
- ],
464
- "stylistic/keyword-spacing": [
465
- "error",
466
- {
467
- before: true,
468
- after: true
469
- }
470
- ],
471
- "stylistic/line-comment-position": "off",
472
- "stylistic/linebreak-style": ["error", "unix"],
473
- "stylistic/lines-around-comment": "off",
474
- "stylistic/new-parens": ["error", "always"],
475
- "stylistic/no-confusing-arrow": [
476
- "error",
477
- {
478
- allowParens: true,
479
- onlyOneSimpleParam: true
480
- }
481
- ],
482
- "stylistic/no-extra-semi": "error",
483
- "stylistic/object-property-newline": [
484
- "error",
485
- {
486
- allowAllPropertiesOnSameLine: true
487
- }
488
- ],
489
- "stylistic/space-before-function-paren": [
490
- "error",
491
- {
492
- named: "never",
493
- anonymous: "always",
494
- asyncArrow: "always",
495
- catch: "always"
496
- }
497
- ],
498
- "stylistic/switch-colon-spacing": [
499
- "error",
500
- {
501
- after: true,
502
- before: false
503
- }
504
- ],
505
- "stylistic/type-annotation-spacing": "error",
506
- "stylistic/wrap-regex": "error",
507
- "stylistic/quotes": [
508
- "error",
509
- "single",
510
- {
511
- allowTemplateLiterals: true,
512
- avoidEscape: true
513
- }
514
- ],
515
- "stylistic/no-tabs": "off",
516
- "antfu/consistent-chaining": "error",
517
- "antfu/consistent-list-newline": "error",
518
- "antfu/top-level-function": "off",
519
- "antfu/curly": "off",
520
- ...overrides
521
- }
522
- },
523
- {
524
- name: `${RULE_PREFIX}/stylistic/customize/jsx`,
525
- files: [...GLOB_JSX_SRC, GLOB_VUE],
526
- plugins: {
527
- stylistic: pluginStylistic
528
- },
529
- rules: {
530
- "stylistic/indent": [
531
- "error",
532
- 2,
533
- {
534
- ...basicIndentRuleOptions,
535
- ignoredNodes: jsxIgnoreNodes
536
- }
537
- ],
538
- "stylistic/jsx-closing-bracket-location": [
539
- "error",
540
- {
541
- nonEmpty: "tag-aligned",
542
- selfClosing: "tag-aligned"
543
- }
544
- ],
545
- "stylistic/jsx-closing-tag-location": ["error", "tag-aligned"],
546
- "stylistic/jsx-curly-brace-presence": [
547
- "error",
548
- {
549
- props: "never",
550
- children: "never",
551
- propElementValues: "always"
552
- }
553
- ],
554
- "stylistic/jsx-curly-newline": [
555
- "error",
556
- {
557
- singleline: "consistent",
558
- multiline: "consistent"
559
- }
560
- ],
561
- "stylistic/jsx-curly-spacing": [
562
- "error",
563
- {
564
- when: "never",
565
- attributes: {
566
- when: "never"
567
- },
568
- children: {
569
- when: "never"
570
- }
571
- }
572
- ],
573
- "stylistic/jsx-first-prop-new-line": ["error", "multiline"],
574
- "stylistic/jsx-one-expression-per-line": [
575
- "error",
576
- {
577
- allow: "non-jsx"
578
- }
579
- ],
580
- "stylistic/jsx-pascal-case": [
581
- "error",
582
- {
583
- allowAllCaps: false,
584
- allowLeadingUnderscore: false,
585
- allowNamespace: true
586
- }
587
- ],
588
- "stylistic/jsx-props-no-multi-spaces": "error",
589
- "stylistic/jsx-quotes": ["error", "prefer-double"],
590
- "stylistic/jsx-self-closing-comp": [
591
- "error",
592
- {
593
- component: true,
594
- html: true
595
- }
596
- ],
597
- "stylistic/jsx-sort-props": "off",
598
- "stylistic/jsx-indent-props": "off",
599
- ...overrides
600
- }
601
- }
602
- ];
603
- }
604
-
605
- // src/configs/typescript.ts
606
- import process from "process";
607
- import { defineConfig as defineConfig3 } from "eslint/config";
608
- import tseslint2 from "typescript-eslint";
609
- function typescript(options = {}) {
610
- const { overrides = {}, typeSafe = false, strict = false } = options;
611
- return [
612
- ...defineConfig3(
613
- tseslint2.configs.base,
614
- tseslint2.configs.recommendedTypeChecked,
615
- tseslint2.configs.strictTypeChecked,
616
- tseslint2.configs.stylisticTypeChecked
617
- ).map((item) => ({
618
- ...item,
619
- name: `${RULE_PREFIX}/typescript/shared/${item.name?.replace("typescript-eslint/", "")}`,
620
- files: GLOB_TS_SRC
621
- })),
622
- {
623
- name: `${RULE_PREFIX}/typescript/customize`,
624
- files: GLOB_TS_SRC,
625
- languageOptions: {
626
- parserOptions: {
627
- projectService: true,
628
- tsconfigRootDir: process.cwd()
629
- },
630
- sourceType: "module"
631
- },
632
- rules: {
633
- "@typescript-eslint/consistent-type-imports": [
634
- "error",
635
- {
636
- disallowTypeAnnotations: false
637
- }
638
- ],
639
- "@typescript-eslint/no-import-type-side-effects": "error",
640
- "@typescript-eslint/method-signature-style": ["error", "property"],
641
- "no-unused-expressions": "off",
642
- "@typescript-eslint/no-unused-expressions": [
643
- "error",
644
- {
645
- allowShortCircuit: true,
646
- allowTernary: true
647
- }
648
- ],
649
- "@typescript-eslint/no-dynamic-delete": "off",
650
- "@typescript-eslint/no-empty-object-type": [
651
- "error",
652
- {
653
- allowInterfaces: "with-single-extends",
654
- allowObjectTypes: "never",
655
- allowWithName: "Props$"
656
- }
657
- ],
658
- "@typescript-eslint/no-non-null-assertion": "off",
659
- "@typescript-eslint/ban-ts-comment": "off",
660
- "@typescript-eslint/no-explicit-any": "off",
661
- "@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
662
- "@typescript-eslint/await-thenable": "error",
663
- "@typescript-eslint/no-floating-promises": "error",
664
- "@typescript-eslint/consistent-type-exports": "error",
665
- "@typescript-eslint/no-misused-promises": [
666
- "error",
667
- {
668
- checksVoidReturn: {
669
- arguments: false,
670
- attributes: false
671
- }
672
- }
673
- ],
674
- "@typescript-eslint/restrict-template-expressions": ["error", {}],
675
- "@typescript-eslint/no-deprecated": "warn",
676
- "@typescript-eslint/no-empty-function": "off",
677
- "@typescript-eslint/consistent-type-definitions": "off",
678
- "@typescript-eslint/array-type": [
679
- "error",
680
- {
681
- default: "array-simple"
682
- }
683
- ],
684
- "@typescript-eslint/prefer-nullish-coalescing": "off",
685
- "@typescript-eslint/no-confusing-void-expression": [
686
- "error",
687
- {
688
- ignoreArrowShorthand: true
689
- }
690
- ],
691
- ...typeSafe ? {} : {
692
- "@typescript-eslint/no-unsafe-assignment": "off",
693
- "@typescript-eslint/no-unsafe-member-access": "off",
694
- "@typescript-eslint/no-unsafe-call": "off",
695
- "@typescript-eslint/no-unsafe-return": "off",
696
- "@typescript-eslint/no-unsafe-argument": "off"
697
- },
698
- ...strict ? {} : {
699
- "@typescript-eslint/no-extraneous-class": "off"
700
- },
701
- ...overrides
702
- }
703
- }
704
- ];
705
- }
706
-
707
- // src/configs/javascript.ts
708
- import js2 from "@eslint/js";
709
- import pluginAntfu2 from "eslint-plugin-antfu";
710
- import globals2 from "globals";
711
- function javascript(options = {}) {
712
- const { overrides = {} } = options;
713
- return [
714
- {
715
- name: `${RULE_PREFIX}/javascript/shared`,
716
- files: GLOB_SRC,
717
- languageOptions: {
718
- ecmaVersion: 2022,
719
- globals: {
720
- ...globals2.browser,
721
- ...globals2.es2021,
722
- ...globals2.node,
723
- document: "readonly",
724
- navigator: "readonly",
725
- window: "readonly"
726
- },
727
- parserOptions: {
728
- ecmaFeatures: {
729
- jsx: true
730
- },
731
- ecmaVersion: 2022,
732
- sourceType: "module"
733
- },
734
- sourceType: "module"
735
- },
736
- linterOptions: {
737
- reportUnusedDisableDirectives: true
738
- },
739
- rules: js2.configs.recommended.rules
740
- },
741
- {
742
- name: `${RULE_PREFIX}/javascript/customize`,
743
- files: GLOB_SRC,
744
- plugins: {
745
- antfu: pluginAntfu2
746
- },
747
- rules: {
748
- "arrow-body-style": ["error", "as-needed"],
749
- "func-style": [
750
- "warn",
751
- "declaration",
752
- {
753
- allowArrowFunctions: true
754
- }
755
- ],
756
- "no-empty-function": "off",
757
- "prefer-destructuring": "off",
758
- "capitalized-comments": "off",
759
- "id-length": "off",
760
- "accessor-pairs": [
761
- "error",
762
- {
763
- enforceForClassMembers: true,
764
- setWithoutGet: true
765
- }
766
- ],
767
- "antfu/no-top-level-await": "error",
768
- // https://x.com/karlhorky/status/1773632485055680875
769
- "array-callback-return": "error",
770
- "block-scoped-var": "error",
771
- "constructor-super": "error",
772
- "default-case-last": "error",
773
- "dot-notation": [
774
- "error",
775
- {
776
- allowKeywords: true
777
- }
778
- ],
779
- "eqeqeq": ["error", "smart"],
780
- "new-cap": [
781
- "error",
782
- {
783
- capIsNew: false,
784
- newIsCap: true,
785
- properties: true
786
- }
787
- ],
788
- "no-alert": "error",
789
- "no-array-constructor": "error",
790
- "no-async-promise-executor": "error",
791
- "no-caller": "error",
792
- "no-case-declarations": "error",
793
- "no-class-assign": "error",
794
- "no-compare-neg-zero": "error",
795
- "no-cond-assign": ["error", "always"],
796
- "no-console": [
797
- "error",
798
- {
799
- allow: ["warn", "error", "info"]
800
- }
801
- ],
802
- "no-const-assign": "error",
803
- "no-control-regex": "error",
804
- "no-debugger": "error",
805
- "no-delete-var": "error",
806
- "no-dupe-args": "error",
807
- "no-dupe-class-members": "error",
808
- "no-dupe-keys": "error",
809
- "no-duplicate-case": "error",
810
- "no-empty": [
811
- "error",
812
- {
813
- allowEmptyCatch: true
814
- }
815
- ],
816
- "no-empty-character-class": "error",
817
- "no-empty-pattern": "error",
818
- "no-eval": "error",
819
- "no-ex-assign": "error",
820
- "no-extend-native": "error",
821
- "no-extra-bind": "error",
822
- "no-extra-boolean-cast": "error",
823
- "no-fallthrough": "error",
824
- "no-func-assign": "error",
825
- "no-global-assign": "error",
826
- "no-implied-eval": "error",
827
- "no-import-assign": "error",
828
- "no-invalid-regexp": "error",
829
- "no-irregular-whitespace": "error",
830
- "no-iterator": "error",
831
- "no-labels": [
832
- "error",
833
- {
834
- allowLoop: false,
835
- allowSwitch: false
836
- }
837
- ],
838
- "no-lone-blocks": "error",
839
- "no-loss-of-precision": "error",
840
- "no-misleading-character-class": "error",
841
- "no-multi-str": "error",
842
- "no-new": "error",
843
- "no-new-func": "error",
844
- "no-new-native-nonconstructor": "error",
845
- "no-new-wrappers": "error",
846
- "no-obj-calls": "error",
847
- "no-octal": "error",
848
- "no-octal-escape": "error",
849
- // https://twitter.com/ryanflorence/status/1786394911895683512
850
- "no-param-reassign": "warn",
851
- "no-proto": "error",
852
- "no-prototype-builtins": "error",
853
- "no-redeclare": [
854
- "error",
855
- {
856
- builtinGlobals: false
857
- }
858
- ],
859
- "no-regex-spaces": "error",
860
- "no-restricted-globals": [
861
- "error",
862
- {
863
- message: "Use `globalThis` instead.",
864
- name: "global"
865
- },
866
- {
867
- message: "Use `globalThis` instead.",
868
- name: "self"
869
- }
870
- ],
871
- "no-restricted-properties": [
872
- "error",
873
- {
874
- message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
875
- property: "__proto__"
876
- },
877
- {
878
- message: "Use `Object.defineProperty` instead.",
879
- property: "__defineGetter__"
880
- },
881
- {
882
- message: "Use `Object.defineProperty` instead.",
883
- property: "__defineSetter__"
884
- },
885
- {
886
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
887
- property: "__lookupGetter__"
888
- },
889
- {
890
- message: "Use `Object.getOwnPropertyDescriptor` instead.",
891
- property: "__lookupSetter__"
892
- }
893
- ],
894
- "no-restricted-syntax": [
895
- "error",
896
- "TSEnumDeclaration[const=true]",
897
- "TSExportAssignment"
898
- ],
899
- "no-self-assign": [
900
- "error",
901
- {
902
- props: true
903
- }
904
- ],
905
- "no-self-compare": "error",
906
- "no-sequences": "error",
907
- "no-shadow-restricted-names": "error",
908
- "no-sparse-arrays": "error",
909
- "no-template-curly-in-string": "error",
910
- "no-this-before-super": "error",
911
- "no-throw-literal": "error",
912
- "no-undef": "error",
913
- "no-undef-init": "error",
914
- "no-unexpected-multiline": "error",
915
- "no-unmodified-loop-condition": "error",
916
- "no-unneeded-ternary": [
917
- "error",
918
- {
919
- defaultAssignment: false
920
- }
921
- ],
922
- "no-unreachable": "error",
923
- "no-unreachable-loop": "error",
924
- "no-unsafe-finally": "error",
925
- "no-unsafe-negation": "error",
926
- "no-unused-expressions": [
927
- "error",
928
- {
929
- allowShortCircuit: true,
930
- allowTaggedTemplates: true,
931
- allowTernary: true
932
- }
933
- ],
934
- "no-unused-vars": [
935
- "error",
936
- {
937
- args: "none",
938
- caughtErrors: "none",
939
- ignoreRestSiblings: true,
940
- vars: "all"
941
- }
942
- ],
943
- "no-use-before-define": [
944
- "error",
945
- {
946
- classes: false,
947
- functions: false,
948
- variables: true
949
- }
950
- ],
951
- "no-useless-backreference": "error",
952
- "no-useless-call": "error",
953
- "no-useless-catch": "error",
954
- "no-useless-computed-key": "error",
955
- "no-useless-constructor": "error",
956
- "no-useless-rename": "error",
957
- "no-useless-return": "error",
958
- "no-var": "error",
959
- "no-with": "error",
960
- "object-shorthand": [
961
- "error",
962
- "always",
963
- {
964
- avoidQuotes: true,
965
- ignoreConstructors: false
966
- }
967
- ],
968
- "one-var": [
969
- "error",
970
- {
971
- initialized: "never"
972
- }
973
- ],
974
- "prefer-arrow-callback": [
975
- "error",
976
- {
977
- allowNamedFunctions: false,
978
- allowUnboundThis: true
979
- }
980
- ],
981
- "prefer-const": [
982
- "error",
983
- {
984
- destructuring: "all",
985
- ignoreReadBeforeAssign: true
986
- }
987
- ],
988
- "prefer-exponentiation-operator": "error",
989
- "prefer-promise-reject-errors": "error",
990
- "prefer-regex-literals": [
991
- "error",
992
- {
993
- disallowRedundantWrapping: true
994
- }
995
- ],
996
- "prefer-rest-params": "error",
997
- "prefer-spread": "error",
998
- "prefer-template": "error",
999
- "symbol-description": "error",
1000
- "unicode-bom": ["error", "never"],
1001
- "use-isnan": [
1002
- "error",
1003
- {
1004
- enforceForIndexOf: true,
1005
- enforceForSwitchCase: true
1006
- }
1007
- ],
1008
- "valid-typeof": [
1009
- "error",
1010
- {
1011
- requireStringLiterals: true
1012
- }
1013
- ],
1014
- "vars-on-top": "error",
1015
- "yoda": ["error", "never"],
1016
- ...overrides
1017
- }
1018
- }
1019
- ];
1020
- }
1021
-
1022
- // src/configs/node.ts
1023
- import pluginNode from "eslint-plugin-n";
1024
- function node(options = {}) {
1025
- const { overrides = {} } = options;
1026
- const config = pluginNode.configs["flat/recommended"];
1027
- return [
1028
- {
1029
- ...config,
1030
- name: `${RULE_PREFIX}/node/shared`,
1031
- files: GLOB_SRC
1032
- },
1033
- {
1034
- name: `${RULE_PREFIX}/node/customize`,
1035
- files: GLOB_SRC,
1036
- rules: {
1037
- "n/handle-callback-err": ["error", "^(err|error)$"],
1038
- "n/no-new-require": "error",
1039
- "n/no-path-concat": "error",
1040
- "n/prefer-global/buffer": ["error", "never"],
1041
- "n/prefer-global/process": ["error", "never"],
1042
- "n/no-missing-import": "off",
1043
- ...overrides
1044
- }
1045
- }
1046
- ];
1047
- }
1048
-
1049
- // src/configs/json.ts
1050
- import pluginJsonc from "eslint-plugin-jsonc";
1051
- import pluginPackageJson from "eslint-plugin-package-json";
1052
- function json(options = {}) {
1053
- const {
1054
- overrides = { core: {}, packageJson: {} },
1055
- indent = 2,
1056
- packageJsonRequireType = true
1057
- } = options;
1058
- return [
1059
- ...pluginJsonc.configs["recommended-with-json"].map((item) => ({
1060
- ...item,
1061
- name: `${RULE_PREFIX}/json/shared/json`,
1062
- files: [GLOB_JSON]
1063
- })),
1064
- ...pluginJsonc.configs["recommended-with-jsonc"].map((item) => ({
1065
- ...item,
1066
- name: `${RULE_PREFIX}/json/shared/jsonc`,
1067
- files: [GLOB_JSONC]
1068
- })),
1069
- ...pluginJsonc.configs["recommended-with-json5"].map((item) => ({
1070
- ...item,
1071
- name: `${RULE_PREFIX}/json/shared/json5`,
1072
- files: [GLOB_JSON5]
1073
- })),
1074
- {
1075
- name: `${RULE_PREFIX}/json/customize`,
1076
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
1077
- rules: {
1078
- "jsonc/array-bracket-spacing": ["error", "never"],
1079
- "jsonc/comma-dangle": ["error", "never"],
1080
- "jsonc/comma-style": ["error", "last"],
1081
- "jsonc/indent": ["error", indent],
1082
- "jsonc/no-comments": "off",
1083
- "jsonc/key-spacing": [
1084
- "error",
1085
- {
1086
- afterColon: true,
1087
- beforeColon: false
1088
- }
1089
- ],
1090
- "jsonc/object-curly-newline": [
1091
- "error",
1092
- {
1093
- consistent: true,
1094
- multiline: true
1095
- }
1096
- ],
1097
- "jsonc/object-curly-spacing": ["error", "always"],
1098
- "jsonc/quote-props": "error",
1099
- "jsonc/quotes": "error",
1100
- "jsonc/no-bigint-literals": "error",
1101
- "jsonc/object-property-newline": [
1102
- "error",
1103
- {
1104
- allowMultiplePropertiesPerLine: true
1105
- }
1106
- ],
1107
- "jsonc/no-binary-expression": "error",
1108
- "jsonc/no-binary-numeric-literals": "error",
1109
- "jsonc/no-dupe-keys": "error",
1110
- "jsonc/no-escape-sequence-in-identifier": "error",
1111
- "jsonc/no-floating-decimal": "error",
1112
- "jsonc/no-hexadecimal-numeric-literals": "error",
1113
- "jsonc/no-infinity": "error",
1114
- "jsonc/no-multi-str": "error",
1115
- "jsonc/no-nan": "error",
1116
- "jsonc/no-number-props": "error",
1117
- "jsonc/no-numeric-separators": "error",
1118
- "jsonc/no-octal": "error",
1119
- "jsonc/no-octal-escape": "error",
1120
- "jsonc/no-octal-numeric-literals": "error",
1121
- "jsonc/no-parenthesized": "error",
1122
- "jsonc/no-plus-sign": "error",
1123
- "jsonc/no-regexp-literals": "error",
1124
- "jsonc/no-sparse-arrays": "error",
1125
- "jsonc/no-template-literals": "error",
1126
- "jsonc/no-undefined-value": "error",
1127
- "jsonc/no-unicode-codepoint-escapes": "error",
1128
- "jsonc/no-useless-escape": "error",
1129
- "jsonc/space-unary-ops": "error",
1130
- "jsonc/valid-json-number": "error",
1131
- "jsonc/vue-custom-block/no-parsing-error": "error",
1132
- ...overrides.core
1133
- }
1134
- },
1135
- {
1136
- ...pluginPackageJson.configs.recommended,
1137
- name: `${RULE_PREFIX}/json/shared/package.json`,
1138
- files: [GLOB_PACKAGE_JSON]
1139
- },
1140
- {
1141
- name: `${RULE_PREFIX}/json/customize/package.json`,
1142
- files: [GLOB_PACKAGE_JSON],
1143
- rules: {
1144
- "package-json/order-properties": [
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
- "release-it",
1181
- "peerDependencies",
1182
- "peerDependenciesMeta",
1183
- "dependencies",
1184
- "optionalDependencies",
1185
- "devDependencies",
1186
- "pnpm",
1187
- "overrides",
1188
- "resolutions",
1189
- "husky",
1190
- "simple-git-hooks",
1191
- "lint-staged",
1192
- "eslintConfig"
1193
- ]
1194
- }
1195
- ],
1196
- "package-json/require-type": packageJsonRequireType ? "error" : "off",
1197
- ...overrides.packageJson
1198
- }
1199
- }
1200
- ];
1201
- }
1202
-
1203
- // src/configs/unicorn.ts
1204
- import pluginUnicorn from "eslint-plugin-unicorn";
1205
- function unicorn(options = {}) {
1206
- const { overrides = {} } = options;
1207
- return [
1208
- {
1209
- ...pluginUnicorn.configs.recommended,
1210
- name: `${RULE_PREFIX}/unicorn/shared`,
1211
- files: GLOB_SRC
1212
- },
1213
- {
1214
- name: `${RULE_PREFIX}/unicorn/customize`,
1215
- files: GLOB_SRC,
1216
- rules: {
1217
- // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1109#issuecomment-782689255
1218
- "unicorn/consistent-destructuring": "off",
1219
- "unicorn/prevent-abbreviations": "off",
1220
- // https://github.com/orgs/web-infra-dev/discussions/10
1221
- "unicorn/prefer-top-level-await": "off",
1222
- "unicorn/no-unreadable-array-destructuring": "off",
1223
- // https://github.com/sindresorhus/meta/discussions/7
1224
- "unicorn/no-null": "off",
1225
- "unicorn/consistent-empty-array-spread": "error",
1226
- "unicorn/error-message": "error",
1227
- "unicorn/escape-case": "error",
1228
- "unicorn/no-hex-escape": "error",
1229
- "unicorn/new-for-builtins": "error",
1230
- "unicorn/no-instanceof-builtins": "error",
1231
- "unicorn/no-new-array": "error",
1232
- "unicorn/no-new-buffer": "error",
1233
- "unicorn/number-literal-case": "error",
1234
- "unicorn/prefer-dom-node-text-content": "error",
1235
- "unicorn/prefer-includes": "error",
1236
- "unicorn/prefer-node-protocol": "error",
1237
- "unicorn/prefer-query-selector": "off",
1238
- "unicorn/prefer-number-properties": "error",
1239
- "unicorn/prefer-string-starts-ends-with": "error",
1240
- "unicorn/prefer-type-error": "error",
1241
- "unicorn/throw-new-error": "error",
1242
- ...overrides
1243
- }
1244
- }
1245
- ];
1246
- }
1247
-
1248
- // src/configs/imports.ts
1249
- import pluginImportX from "eslint-plugin-import-x";
1250
- import pluginUnusedImports from "eslint-plugin-unused-imports";
1251
- import pluginAntfu3 from "eslint-plugin-antfu";
1252
- import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
1253
- function imports(options = {}) {
1254
- const { overrides = {}, closeOrder = true } = options;
1255
- return [
1256
- {
1257
- name: `${RULE_PREFIX}/imports/customize`,
1258
- files: GLOB_SRC,
1259
- plugins: {
1260
- "antfu": pluginAntfu3,
1261
- "import-x": pluginImportX,
1262
- "unused-imports": pluginUnusedImports,
1263
- "simple-import-sort": pluginSimpleImportSort
1264
- },
1265
- rules: {
1266
- "sort-imports": "off",
1267
- "no-unused-vars": "off",
1268
- "no-duplicate-imports": "off",
1269
- "@typescript-eslint/no-unused-vars": "off",
1270
- "antfu/import-dedupe": "error",
1271
- "antfu/no-import-dist": "error",
1272
- "antfu/no-import-node-modules-by-path": "error",
1273
- "import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
1274
- "import-x/first": "error",
1275
- "import-x/no-duplicates": "error",
1276
- "import-x/no-mutable-exports": "error",
1277
- "import-x/no-named-default": "error",
1278
- "import-x/no-self-import": "error",
1279
- "import-x/no-webpack-loader-syntax": "error",
1280
- "import-x/order": "off",
1281
- "import-x/newline-after-import": [
1282
- "error",
1283
- {
1284
- count: 1
1285
- }
1286
- ],
1287
- "unused-imports/no-unused-imports": "warn",
1288
- "unused-imports/no-unused-vars": [
1289
- "error",
1290
- {
1291
- args: "after-used",
1292
- argsIgnorePattern: "^_",
1293
- ignoreRestSiblings: true,
1294
- vars: "all",
1295
- varsIgnorePattern: "^_"
1296
- }
1297
- ],
1298
- "simple-import-sort/imports": closeOrder ? "off" : "error",
1299
- "simple-import-sort/exports": closeOrder ? "off" : "error",
1300
- ...overrides
1301
- }
1302
- }
1303
- ];
1304
- }
1305
-
1306
- // src/configs/format.ts
1307
- import pluginFormat from "eslint-plugin-format";
1308
- var mergePrettierOptions = (options, overrides) => ({
1309
- ...options,
1310
- ...overrides,
1311
- plugins: [...overrides.plugins || []]
1312
- });
1313
- function format(options = {}) {
1314
- const {
1315
- enable = {
1316
- html: true,
1317
- css: true,
1318
- graphql: true,
1319
- xml: true,
1320
- svg: true
1321
- },
1322
- customPrettierOptions = {}
1323
- } = options;
1324
- const configs2 = [];
1325
- if (!enable) {
1326
- return configs2;
1327
- }
1328
- const prettierOptions = Object.assign(
1329
- {
1330
- printWidth: 120,
1331
- tabWidth: 2,
1332
- semi: true,
1333
- singleQuote: true,
1334
- quoteProps: "consistent",
1335
- jsxSingleQuote: false,
1336
- trailingComma: "all",
1337
- bracketSpacing: true,
1338
- bracketSameLine: false,
1339
- arrowParens: "always",
1340
- useTabs: false,
1341
- endOfLine: "lf",
1342
- singleAttributePerLine: false
1343
- },
1344
- customPrettierOptions
1345
- );
1346
- const prettierXmlOptions = {
1347
- xmlQuoteAttributes: "double",
1348
- xmlSelfClosingSpace: true,
1349
- xmlSortAttributesByKey: false,
1350
- xmlWhitespaceSensitivity: "ignore"
1351
- };
1352
- configs2.push({
1353
- name: `${RULE_PREFIX}/format`,
1354
- plugins: {
1355
- format: pluginFormat
1356
- }
1357
- });
1358
- if (enable.html) {
1359
- configs2.push({
1360
- name: `${RULE_PREFIX}/format/html`,
1361
- files: [GLOB_HTML],
1362
- languageOptions: {
1363
- parser: parserPlain
1364
- },
1365
- rules: {
1366
- "format/prettier": [
1367
- "error",
1368
- mergePrettierOptions(prettierOptions, {
1369
- parser: "html"
1370
- })
1371
- ]
1372
- }
1373
- });
1374
- }
1375
- if (enable.css) {
1376
- configs2.push(
1377
- {
1378
- name: `${RULE_PREFIX}/format/css`,
1379
- files: [GLOB_CSS, GLOB_POSTCSS],
1380
- languageOptions: {
1381
- parser: parserPlain
1382
- },
1383
- rules: {
1384
- "format/prettier": [
1385
- "error",
1386
- mergePrettierOptions(prettierOptions, {
1387
- parser: "css"
1388
- })
1389
- ]
1390
- }
1391
- },
1392
- {
1393
- name: `${RULE_PREFIX}/format/scss`,
1394
- files: [GLOB_SCSS],
1395
- languageOptions: {
1396
- parser: parserPlain
1397
- },
1398
- rules: {
1399
- "format/prettier": [
1400
- "error",
1401
- mergePrettierOptions(prettierOptions, {
1402
- parser: "scss"
1403
- })
1404
- ]
1405
- }
1406
- },
1407
- {
1408
- name: `${RULE_PREFIX}/format/less`,
1409
- files: [GLOB_LESS],
1410
- languageOptions: {
1411
- parser: parserPlain
1412
- },
1413
- rules: {
1414
- "format/prettier": [
1415
- "error",
1416
- mergePrettierOptions(prettierOptions, {
1417
- parser: "less"
1418
- })
1419
- ]
1420
- }
1421
- }
1422
- );
1423
- }
1424
- if (enable.graphql) {
1425
- configs2.push({
1426
- name: `${RULE_PREFIX}/format/graphql`,
1427
- files: [GLOB_GRAPHQL],
1428
- languageOptions: {
1429
- parser: parserPlain
1430
- },
1431
- rules: {
1432
- "format/prettier": [
1433
- "error",
1434
- mergePrettierOptions(prettierOptions, {
1435
- parser: "graphql"
1436
- })
1437
- ]
1438
- }
1439
- });
1440
- }
1441
- if (enable.xml) {
1442
- configs2.push({
1443
- name: `${RULE_PREFIX}/format/xml`,
1444
- files: [GLOB_XML],
1445
- languageOptions: {
1446
- parser: parserPlain
1447
- },
1448
- rules: {
1449
- "format/prettier": [
1450
- "error",
1451
- mergePrettierOptions(
1452
- {
1453
- ...prettierXmlOptions,
1454
- ...prettierOptions
1455
- },
1456
- {
1457
- parser: "xml",
1458
- plugins: ["@prettier/plugin-xml"]
1459
- }
1460
- )
1461
- ]
1462
- }
1463
- });
1464
- }
1465
- if (enable.svg) {
1466
- configs2.push({
1467
- name: `${RULE_PREFIX}/format/svg`,
1468
- files: [GLOB_SVG],
1469
- languageOptions: {
1470
- parser: parserPlain
1471
- },
1472
- rules: {
1473
- "format/prettier": [
1474
- "error",
1475
- mergePrettierOptions(
1476
- {
1477
- ...prettierXmlOptions,
1478
- ...prettierOptions
1479
- },
1480
- {
1481
- parser: "xml",
1482
- plugins: ["@prettier/plugin-xml"]
1483
- }
1484
- )
1485
- ]
1486
- }
1487
- });
1488
- }
1489
- return configs2;
1490
- }
1491
-
1492
- // src/configs/tailwindcss.ts
1493
- import pluginTailwindcss from "eslint-plugin-tailwindcss";
1494
- import { isPackageExists as isPackageExists2 } from "local-pkg";
1495
- function tailwindcss(options = {}) {
1496
- const { overrides = {} } = options;
1497
- return isPackageExists2("tailwindcss") ? [
1498
- ...pluginTailwindcss.configs["flat/recommended"].map((item) => ({
1499
- ...item,
1500
- name: `${RULE_PREFIX}/tailwindcss/shared/${item.name?.replace("tailwindcss:", "")}`,
1501
- files: GLOB_SRC
1502
- })),
1503
- {
1504
- name: `${RULE_PREFIX}/tailwindcss/customize`,
1505
- files: GLOB_SRC,
1506
- rules: {
1507
- "tailwindcss/no-custom-classname": "off",
1508
- ...overrides
1509
- }
1510
- }
1511
- ] : [];
1512
- }
1513
-
1514
- // src/configs/unocss.ts
1515
- import configUnocss from "@unocss/eslint-config/flat";
1516
- import { isPackageExists as isPackageExists3 } from "local-pkg";
1517
- function unocss(options = {}) {
1518
- const { overrides = {} } = options;
1519
- const isUnocssEnabled = isPackageExists3("unocss");
1520
- if (!isUnocssEnabled) {
1521
- return [];
1522
- }
1523
- return [
1524
- {
1525
- ...configUnocss,
1526
- name: `${RULE_PREFIX}/unocss/shared`,
1527
- files: GLOB_SRC
1528
- },
1529
- {
1530
- name: `${RULE_PREFIX}/unocss/customize`,
1531
- files: GLOB_SRC,
1532
- rules: overrides
1533
- }
1534
- ];
1535
- }
1536
-
1537
- // src/configs/yml.ts
1538
- import pluginYml from "eslint-plugin-yml";
1539
- function yml(options = {}) {
1540
- const { overrides = {}, indent = 2, quotes = "single" } = options;
1541
- return [
1542
- ...pluginYml.configs.recommended.map((item) => ({
1543
- ...item,
1544
- name: `${RULE_PREFIX}/yml/shared`,
1545
- files: [GLOB_YML]
1546
- })),
1547
- {
1548
- name: `${RULE_PREFIX}/yml/customize`,
1549
- files: [GLOB_YML],
1550
- rules: {
1551
- "yml/block-mapping": "error",
1552
- "yml/block-sequence": "error",
1553
- "yml/no-empty-key": "error",
1554
- "yml/no-empty-sequence-entry": "error",
1555
- "yml/no-irregular-whitespace": "error",
1556
- "yml/plain-scalar": "error",
1557
- "yml/block-mapping-question-indicator-newline": "error",
1558
- "yml/block-sequence-hyphen-indicator-newline": "error",
1559
- "yml/flow-mapping-curly-newline": "error",
1560
- "yml/flow-mapping-curly-spacing": "error",
1561
- "yml/flow-sequence-bracket-newline": "error",
1562
- "yml/flow-sequence-bracket-spacing": "error",
1563
- "yml/indent": ["error", indent],
1564
- "yml/key-spacing": "error",
1565
- "yml/no-tab-indent": "error",
1566
- "yml/quotes": [
1567
- "error",
1568
- {
1569
- avoidEscape: true,
1570
- prefer: quotes
1571
- }
1572
- ],
1573
- "yml/spaced-comment": "error",
1574
- ...overrides
1575
- }
1576
- },
1577
- {
1578
- name: `${RULE_PREFIX}/yml/customize/pnpm-workspace.yaml`,
1579
- files: ["pnpm-workspace.yaml"],
1580
- rules: {
1581
- "yml/sort-keys": [
1582
- "error",
1583
- {
1584
- order: [
1585
- "packages",
1586
- "overrides",
1587
- "patchedDependencies",
1588
- "hoistPattern",
1589
- "catalog",
1590
- "catalogs",
1591
- "allowedDeprecatedVersions",
1592
- "allowNonAppliedPatches",
1593
- "configDependencies",
1594
- "ignoredBuiltDependencies",
1595
- "ignoredOptionalDependencies",
1596
- "neverBuiltDependencies",
1597
- "onlyBuiltDependencies",
1598
- "onlyBuiltDependenciesFile",
1599
- "packageExtensions",
1600
- "peerDependencyRules",
1601
- "supportedArchitectures"
1602
- ],
1603
- pathPattern: "^$"
1604
- },
1605
- {
1606
- order: {
1607
- type: "asc"
1608
- },
1609
- pathPattern: ".*"
1610
- }
1611
- ]
1612
- }
1613
- }
1614
- ];
1615
- }
1616
-
1617
- // src/configs/toml.ts
1618
- import pluginToml from "eslint-plugin-toml";
1619
- import * as parserToml from "toml-eslint-parser";
1620
- function toml(options = {}) {
1621
- const { overrides = {}, indent = 2 } = options;
1622
- return [
1623
- ...pluginToml.configs.recommended.map((item) => ({
1624
- ...item,
1625
- name: `${RULE_PREFIX}/toml/shared`,
1626
- files: [GLOB_TOML]
1627
- })),
1628
- {
1629
- name: `${RULE_PREFIX}/toml/customize`,
1630
- files: [GLOB_TOML],
1631
- languageOptions: {
1632
- parser: parserToml
1633
- },
1634
- rules: {
1635
- "toml/comma-style": "error",
1636
- "toml/keys-order": "error",
1637
- "toml/no-space-dots": "error",
1638
- "toml/no-unreadable-number-separator": "error",
1639
- "toml/precision-of-fractional-seconds": "error",
1640
- "toml/precision-of-integer": "error",
1641
- "toml/tables-order": "error",
1642
- "toml/array-bracket-newline": "error",
1643
- "toml/array-bracket-spacing": "error",
1644
- "toml/array-element-newline": "error",
1645
- "toml/indent": ["error", indent],
1646
- "toml/inline-table-curly-spacing": "error",
1647
- "toml/key-spacing": "error",
1648
- "toml/padding-line-between-pairs": "error",
1649
- "toml/padding-line-between-tables": "error",
1650
- "toml/quoted-keys": "error",
1651
- "toml/spaced-comment": "error",
1652
- "toml/table-bracket-spacing": "error",
1653
- ...overrides
1654
- }
1655
- }
1656
- ];
1657
- }
1658
-
1659
- // src/configs/regexp.ts
1660
- import * as pluginRegexp from "eslint-plugin-regexp";
1661
- function regexp(options = {}) {
1662
- const { overrides = {} } = options;
1663
- return [
1664
- {
1665
- ...pluginRegexp.configs.recommended,
1666
- name: `${RULE_PREFIX}/regexp/shared`,
1667
- files: GLOB_SRC
1668
- },
1669
- {
1670
- name: `${RULE_PREFIX}/regexp/customize`,
1671
- files: GLOB_SRC,
1672
- rules: overrides
1673
- }
1674
- ];
1675
- }
1676
-
1677
- // src/configs/ignores.ts
1678
- function ignores(ignorePatterns) {
1679
- return [
1680
- {
1681
- name: `${RULE_PREFIX}/ignores`,
1682
- ignores: [
1683
- ...GLOB_EXCLUDE,
1684
- ...ignorePatterns
1685
- ]
1686
- }
1687
- ];
1688
- }
1689
-
1690
- // src/configs/eslint-comments.ts
1691
- import pluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments/configs";
1692
- function eslintComments(options = {}) {
1693
- const { overrides = {} } = options;
1694
- return [
1695
- {
1696
- ...pluginEslintComments.recommended,
1697
- name: `${RULE_PREFIX}/eslint-comments/shared`
1698
- },
1699
- {
1700
- name: `${RULE_PREFIX}/eslint-comments/customize`,
1701
- rules: overrides
1702
- }
1703
- ];
1704
- }
1705
-
1706
- // src/configs/disables.ts
1707
- function disables(options = {}) {
1708
- const { overrides = { scripts: {}, cli: {}, bin: {}, dts: {}, cjs: {}, config: {} } } = options;
1709
- return [
1710
- {
1711
- name: `${RULE_PREFIX}/disables/scripts`,
1712
- files: GLOB_SRC.map((item) => `**/scripts/${item}`),
1713
- rules: {
1714
- "antfu/no-top-level-await": "off",
1715
- "no-console": "off",
1716
- "@typescript-eslint/explicit-function-return-type": "off",
1717
- ...overrides.scripts
1718
- }
1719
- },
1720
- {
1721
- name: `${RULE_PREFIX}/disables/cli`,
1722
- files: [
1723
- ...GLOB_SRC.map((item) => `**/cli/${item}`),
1724
- ...GLOB_SRC_EXT.map((item) => `**/cli.${item}`)
1725
- ],
1726
- rules: {
1727
- "antfu/no-top-level-await": "off",
1728
- "no-console": "off",
1729
- ...overrides.cli
1730
- }
1731
- },
1732
- {
1733
- name: `${RULE_PREFIX}/disables/bin`,
1734
- files: [
1735
- "**/bin/**/*",
1736
- ...GLOB_SRC_EXT.map((item) => `**/bin.${item}`)
1737
- ],
1738
- rules: {
1739
- "antfu/no-import-dist": "off",
1740
- "antfu/no-import-node-modules-by-path": "off",
1741
- ...overrides.bin
1742
- }
1743
- },
1744
- {
1745
- name: `${RULE_PREFIX}/disables/dts`,
1746
- files: ["**/*.d.?([cm])ts"],
1747
- rules: {
1748
- "eslint-comments/no-unlimited-disable": "off",
1749
- "import/no-duplicates": "off",
1750
- "no-restricted-syntax": "off",
1751
- "unused-imports/no-unused-vars": "off",
1752
- ...overrides.dts
1753
- }
1754
- },
1755
- {
1756
- name: `${RULE_PREFIX}/disables/cjs`,
1757
- files: ["**/*.js", "**/*.cjs"],
1758
- rules: {
1759
- "ts/no-require-imports": "off",
1760
- ...overrides.cjs
1761
- }
1762
- },
1763
- {
1764
- name: `${RULE_PREFIX}/disables/config`,
1765
- files: [
1766
- ...GLOB_SRC_EXT.map((item) => `**/*.config.${item}`),
1767
- ...GLOB_SRC_EXT.map((item) => `**/*.config.*.${item}`)
1768
- ],
1769
- rules: {
1770
- "antfu/no-top-level-await": "off",
1771
- "no-console": "off",
1772
- "ts/explicit-function-return-type": "off",
1773
- ...overrides.config
1774
- }
1775
- }
1776
- ];
1777
- }
1778
-
1779
- // src/configs/language-options.ts
1780
- function languageOptions(options = {}) {
1781
- const { sourceType = "module" } = options;
1782
- return [
1783
- {
1784
- name: `${RULE_PREFIX}/language-options`,
1785
- files: GLOB_SRC,
1786
- languageOptions: {
1787
- sourceType
1788
- }
1789
- }
1790
- ];
1791
- }
1792
-
1793
- // src/index.ts
1794
- function defineConfig4(options = {}) {
1795
- const { configs: configs2 = {}, ignorePatterns = [], sourceType = "module" } = options;
1796
- return [
1797
- ...react(configs2.react),
1798
- ...vue(configs2.vue),
1799
- ...stylistic(configs2.stylistic),
1800
- ...typescript(configs2.typescript),
1801
- ...javascript(configs2.javascript),
1802
- ...node(configs2.node),
1803
- ...json(configs2.json),
1804
- ...unicorn(configs2.unicorn),
1805
- ...imports(configs2.imports),
1806
- ...format(configs2.format),
1807
- ...tailwindcss(configs2.tailwindcss),
1808
- ...unocss(configs2.unocss),
1809
- ...yml(configs2.yml),
1810
- ...toml(configs2.toml),
1811
- ...regexp(configs2.regexp),
1812
- ...ignores(ignorePatterns),
1813
- ...eslintComments(configs2.eslintComments),
1814
- ...disables(configs2.disables),
1815
- ...languageOptions({ sourceType })
1816
- ];
1817
- }
1818
- export {
1819
- defineConfig4 as defineConfig
1820
- };