@fast-china/eslint-config 1.0.25 → 1.0.26

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.
@@ -45,76 +45,6 @@ var commonRules = {
45
45
  "prefer-exponentiation-operator": "error"
46
46
  };
47
47
 
48
- // src/flat/configs/common.ts
49
- var commonConfigs = tseslint.config([
50
- {
51
- name: "@fast-china/common",
52
- rules: commonRules
53
- }
54
- ]);
55
-
56
- // src/flat/configs/ignores.ts
57
- import eslintConfigFlatGitignore from "eslint-config-flat-gitignore";
58
- import tseslint2 from "typescript-eslint";
59
-
60
- // src/constants/index.ts
61
- var CONST_JS = "**/*.?([cm])js";
62
- var CONST_JSX = "**/*.?([cm])jsx";
63
- var CONST_TS = "**/*.?([cm])ts";
64
- var CONST_TSX = "**/*.?([cm])tsx";
65
- var CONST_DTS = "**/*.d.ts";
66
- var CONST_JSON = "**/*.json";
67
- var CONST_JSONC = "**/*.jsonc";
68
- var CONST_JSON5 = "**/*.json5";
69
- var CONST_JSON6 = "**/*.json6";
70
- var CONST_MD = "**/*.md";
71
- var CONST_VUE = "**/*.vue";
72
- var CONST_YAML = "**/*.y?(a)ml";
73
- var CONST_NODE_MODULES = "**/node_modules";
74
- var CONST_DIST = "**/dist";
75
- var CONST_LOCKFILE = ["**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/bun.lockb"];
76
- var CONST_PUBLIC = "**/public";
77
- var CONST_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
78
-
79
- // src/flat/configs/ignores.ts
80
- var ignoresConfigs = tseslint2.config([
81
- {
82
- name: "@fast-china/ignores/global",
83
- ignores: [
84
- CONST_NODE_MODULES,
85
- CONST_DIST,
86
- CONST_PUBLIC,
87
- ...CONST_LOCKFILE,
88
- "**/output",
89
- "**/coverage",
90
- "**/temp",
91
- "**/fixtures",
92
- "**/.vitepress/cache",
93
- "**/.nuxt",
94
- "**/.vercel",
95
- "**/.changeset",
96
- "**/.idea",
97
- "**/.output",
98
- "**/.vite-inspect",
99
- "**/.nitro",
100
- "**/CHANGELOG*.md",
101
- "**/*.min.*",
102
- "**/LICENSE*",
103
- "**/__snapshots__",
104
- "**/auto-import?(s).d.ts",
105
- "**/components.d.ts"
106
- ]
107
- },
108
- {
109
- name: "@fast-china/ignores/git",
110
- ...eslintConfigFlatGitignore({ strict: false })
111
- }
112
- ]);
113
-
114
- // src/flat/configs/import.ts
115
- import eslintPluginImport from "eslint-plugin-import";
116
- import tseslint3 from "typescript-eslint";
117
-
118
48
  // src/rules/import.ts
119
49
  var importUseLodashUnifiedRules = {
120
50
  // 限制某些模块导入
@@ -222,32 +152,6 @@ var importRules = {
222
152
  "import/named": "off"
223
153
  };
224
154
 
225
- // src/flat/configs/import.ts
226
- var importConfigs = tseslint3.config([
227
- {
228
- name: "@fast-china/import",
229
- // 继承某些已有的规则
230
- extends: [eslintPluginImport.flatConfigs.recommended],
231
- settings: {
232
- // 确保 ESLint 和 eslint-plugin-import 能够正确解析项目中的所有相关文件类型
233
- "import/resolver": {
234
- node: {
235
- extensions: [CONST_JS, CONST_JSX, CONST_TS, CONST_TSX, CONST_DTS]
236
- }
237
- }
238
- },
239
- rules: {
240
- ...importRules,
241
- ...importUseLodashUnifiedRules
242
- }
243
- }
244
- ]);
245
-
246
- // src/flat/configs/javascript.ts
247
- import eslint from "@eslint/js";
248
- import globals from "globals";
249
- import tseslint4 from "typescript-eslint";
250
-
251
155
  // src/rules/javascript.ts
252
156
  var javascriptRules = {
253
157
  // JS/TS (http://eslint.cn/docs/rules)
@@ -342,120 +246,6 @@ var javascriptRules = {
342
246
  "no-redeclare": "error"
343
247
  };
344
248
 
345
- // src/flat/configs/javascript.ts
346
- var javascriptConfigs = tseslint4.config([
347
- {
348
- name: "@fast-china/javascript",
349
- // 继承某些已有的规则
350
- extends: [eslint.configs.recommended],
351
- languageOptions: {
352
- // 允许使用最新的 ECMAScript 语法特性
353
- ecmaVersion: "latest",
354
- globals: {
355
- ...globals.browser,
356
- ...globals.es2022,
357
- ...globals.node
358
- },
359
- parserOptions: {
360
- ecmaFeatures: {
361
- // 允许使用 JSX 语法,适用于 Vue 组件中的 JSX 代码。
362
- jsx: true
363
- },
364
- sourceType: "module"
365
- }
366
- },
367
- rules: javascriptRules
368
- },
369
- {
370
- name: "@fast-china/javascript/md/js",
371
- files: ["**/*.md/*.js"],
372
- rules: {
373
- // 使用使用控制台
374
- "no-console": "off",
375
- // 关闭 - 禁止使用未声明的变量,除非/*global *\/注释中提到
376
- "no-undef": "off",
377
- // 关闭 - 禁用对无法解析的模块导入的检查
378
- "import/no-unresolved": "off",
379
- // 关闭 - 禁止在文件中重复导入相同的模块
380
- "import/no-duplicates": "off"
381
- }
382
- },
383
- {
384
- name: "@fast-china/javascript/script",
385
- files: ["**/scripts/*", "**/cli.*"],
386
- rules: {
387
- // 使用使用控制台
388
- "no-console": "off"
389
- }
390
- }
391
- ]);
392
-
393
- // src/flat/configs/json.ts
394
- import eslintPluginJsonc from "eslint-plugin-jsonc";
395
- import jsoncEslintParser from "jsonc-eslint-parser";
396
- import tseslint5 from "typescript-eslint";
397
- var jsonConfigs = tseslint5.config([
398
- {
399
- name: "@fast-china/json",
400
- files: [CONST_JSON, CONST_JSONC, CONST_JSON5, CONST_JSON6],
401
- // 继承某些已有的规则
402
- extends: [...eslintPluginJsonc.configs["flat/recommended-with-jsonc"]],
403
- languageOptions: {
404
- parser: jsoncEslintParser
405
- },
406
- plugins: {
407
- jsonc: eslintPluginJsonc
408
- }
409
- }
410
- ]);
411
-
412
- // src/flat/configs/markdown.ts
413
- import eslintPluginMarkdown from "eslint-plugin-markdown";
414
- import tseslint6 from "typescript-eslint";
415
- var markdownConfigs = tseslint6.config([
416
- {
417
- name: "@fast-china/markdown",
418
- files: [CONST_MD]
419
- },
420
- ...eslintPluginMarkdown.configs.recommended.map((config) => ({
421
- ...config,
422
- name: `@fast-china/${config.name || "markdown/anonymous"}`
423
- }))
424
- ]);
425
-
426
- // src/flat/configs/prettier.ts
427
- import eslintConfigPrettierFlat from "eslint-config-prettier/flat";
428
- import eslintPluginPrettier from "eslint-plugin-prettier";
429
- import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
430
- import tseslint7 from "typescript-eslint";
431
- var prettierConfigs = tseslint7.config([
432
- {
433
- name: "@fast-china/prettier",
434
- // 继承某些已有的规则
435
- extends: [eslintConfigPrettierFlat, eslintPluginPrettierRecommended],
436
- plugins: {
437
- prettier: eslintPluginPrettier
438
- },
439
- rules: {
440
- // 确保 Prettier 错误被 ESLint 捕获
441
- "prettier/prettier": "error"
442
- }
443
- }
444
- ]);
445
-
446
- // src/flat/configs/regexp.ts
447
- import eslintPluginRegexp from "eslint-plugin-regexp";
448
- import tseslint8 from "typescript-eslint";
449
- var regexpConfigs = tseslint8.config([
450
- {
451
- name: "@fast-china/regexp",
452
- ...eslintPluginRegexp.configs["flat/recommended"]
453
- }
454
- ]);
455
-
456
- // src/flat/configs/sort-package.ts
457
- import tseslint9 from "typescript-eslint";
458
-
459
249
  // src/rules/sort-package.ts
460
250
  var packageJsonSortRules = {
461
251
  "jsonc/sort-array-values": [
@@ -529,18 +319,6 @@ var packageJsonSortRules = {
529
319
  ]
530
320
  };
531
321
 
532
- // src/flat/configs/sort-package.ts
533
- var packageJsonSortConfigs = tseslint9.config([
534
- {
535
- name: "@fast-china/sort/package",
536
- files: ["**/package.json"],
537
- rules: packageJsonSortRules
538
- }
539
- ]);
540
-
541
- // src/flat/configs/sort-tsconfig.ts
542
- import tseslint10 from "typescript-eslint";
543
-
544
322
  // src/rules/sort-tsconfig.ts
545
323
  var tsconfigJsonSortRules = {
546
324
  "jsonc/sort-keys": [
@@ -654,18 +432,6 @@ var tsconfigJsonSortRules = {
654
432
  ]
655
433
  };
656
434
 
657
- // src/flat/configs/sort-tsconfig.ts
658
- var tsconfigJsonSortConfigs = tseslint10.config([
659
- {
660
- name: "@fast-china/sort/tsconfig",
661
- files: CONST_TSCONFIG,
662
- rules: tsconfigJsonSortRules
663
- }
664
- ]);
665
-
666
- // src/flat/configs/typescript.ts
667
- import tseslint11 from "typescript-eslint";
668
-
669
435
  // src/rules/typescript.ts
670
436
  var typescriptRules = {
671
437
  // TS (https://typescript-eslint.io/rules)
@@ -718,72 +484,6 @@ var typescriptRules = {
718
484
  ]
719
485
  };
720
486
 
721
- // src/flat/configs/typescript.ts
722
- var typescriptCoreConfigs = tseslint11.config([
723
- {
724
- name: "@fast-china/typescript",
725
- files: [CONST_TS, CONST_TSX],
726
- // 继承某些已有的规则
727
- extends: [tseslint11.configs.recommended],
728
- languageOptions: {
729
- // 允许使用最新的 ECMAScript 语法特性
730
- ecmaVersion: "latest",
731
- parser: tseslint11.parser,
732
- parserOptions: {
733
- ecmaFeatures: {
734
- // 允许使用 TSX 语法,适用于 Vue 组件中的 TSX 代码。
735
- tsx: true
736
- },
737
- sourceType: "module"
738
- }
739
- },
740
- rules: typescriptRules
741
- }
742
- ]);
743
- var typescriptConfigs = tseslint11.config([
744
- ...typescriptCoreConfigs,
745
- {
746
- name: "@fast-china/typescript/dts",
747
- files: [CONST_DTS],
748
- rules: {
749
- // 关闭 - 一致地使用 TypeScript 类型导入
750
- "@typescript-eslint/consistent-type-imports": "off"
751
- }
752
- },
753
- {
754
- name: "@fast-china/typescript/vite",
755
- files: ["**/vite.config.*"],
756
- rules: {
757
- // 关闭 - 要求在 TypeScript 函数和方法中显式地指定返回类型
758
- "@typescript-eslint/explicit-function-return-type": "off"
759
- }
760
- },
761
- {
762
- name: "@fast-china/typescript/md/js",
763
- files: ["**/*.md/*.ts"],
764
- rules: {
765
- // 允许定义未使用的变量
766
- "@typescript-eslint/no-unused-vars": "off"
767
- }
768
- }
769
- ]);
770
-
771
- // src/flat/configs/vue.ts
772
- import eslintPluginVue from "eslint-plugin-vue";
773
- import tseslint12 from "typescript-eslint";
774
- import vueEslintParser from "vue-eslint-parser";
775
-
776
- // src/env/index.ts
777
- import { getPackageInfoSync } from "local-pkg";
778
- var getVueVersion = () => {
779
- const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
780
- if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
781
- return +pkg.version[0];
782
- }
783
- return 3;
784
- };
785
- var isVue3 = getVueVersion() === 3;
786
-
787
487
  // src/rules/vue.ts
788
488
  var vueRules = {
789
489
  // vue (https://eslint.vuejs.org/rules)
@@ -841,6 +541,296 @@ var vueRules = {
841
541
  ]
842
542
  };
843
543
 
544
+ // src/flat/configs/common.ts
545
+ var commonConfigs = tseslint.config([
546
+ {
547
+ name: "@fast-china/common",
548
+ rules: commonRules
549
+ }
550
+ ]);
551
+
552
+ // src/flat/configs/ignores.ts
553
+ import eslintConfigFlatGitignore from "eslint-config-flat-gitignore";
554
+ import tseslint2 from "typescript-eslint";
555
+
556
+ // src/constants/index.ts
557
+ var CONST_JS = "**/*.?([cm])js";
558
+ var CONST_JSX = "**/*.?([cm])jsx";
559
+ var CONST_TS = "**/*.?([cm])ts";
560
+ var CONST_TSX = "**/*.?([cm])tsx";
561
+ var CONST_DTS = "**/*.d.ts";
562
+ var CONST_JSON = "**/*.json";
563
+ var CONST_JSONC = "**/*.jsonc";
564
+ var CONST_JSON5 = "**/*.json5";
565
+ var CONST_JSON6 = "**/*.json6";
566
+ var CONST_MD = "**/*.md";
567
+ var CONST_VUE = "**/*.vue";
568
+ var CONST_YAML = "**/*.y?(a)ml";
569
+ var CONST_NODE_MODULES = "**/node_modules";
570
+ var CONST_DIST = "**/dist";
571
+ var CONST_LOCKFILE = ["**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/bun.lockb"];
572
+ var CONST_PUBLIC = "**/public";
573
+ var CONST_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
574
+
575
+ // src/flat/configs/ignores.ts
576
+ var ignoresConfigs = tseslint2.config([
577
+ {
578
+ name: "@fast-china/ignores/global",
579
+ ignores: [
580
+ CONST_NODE_MODULES,
581
+ CONST_DIST,
582
+ CONST_PUBLIC,
583
+ ...CONST_LOCKFILE,
584
+ "**/output",
585
+ "**/coverage",
586
+ "**/temp",
587
+ "**/fixtures",
588
+ "**/.vitepress/cache",
589
+ "**/.nuxt",
590
+ "**/.vercel",
591
+ "**/.changeset",
592
+ "**/.idea",
593
+ "**/.output",
594
+ "**/.vite-inspect",
595
+ "**/.nitro",
596
+ "**/CHANGELOG*.md",
597
+ "**/*.min.*",
598
+ "**/LICENSE*",
599
+ "**/__snapshots__",
600
+ "**/auto-import?(s).d.ts",
601
+ "**/components.d.ts"
602
+ ]
603
+ },
604
+ {
605
+ name: "@fast-china/ignores/git",
606
+ ...eslintConfigFlatGitignore({ strict: false })
607
+ }
608
+ ]);
609
+
610
+ // src/flat/configs/import.ts
611
+ import eslintPluginImport from "eslint-plugin-import";
612
+ import tseslint3 from "typescript-eslint";
613
+ var importConfigs = tseslint3.config([
614
+ {
615
+ name: "@fast-china/import",
616
+ // 继承某些已有的规则
617
+ extends: [eslintPluginImport.flatConfigs.recommended],
618
+ settings: {
619
+ // 确保 ESLint 和 eslint-plugin-import 能够正确解析项目中的所有相关文件类型
620
+ "import/resolver": {
621
+ node: {
622
+ extensions: [CONST_JS, CONST_JSX, CONST_TS, CONST_TSX, CONST_DTS]
623
+ }
624
+ }
625
+ },
626
+ rules: {
627
+ ...importRules,
628
+ ...importUseLodashUnifiedRules
629
+ }
630
+ }
631
+ ]);
632
+
633
+ // src/flat/configs/javascript.ts
634
+ import eslint from "@eslint/js";
635
+ import globals from "globals";
636
+ import tseslint4 from "typescript-eslint";
637
+ var javascriptConfigs = tseslint4.config([
638
+ {
639
+ name: "@fast-china/javascript",
640
+ // 继承某些已有的规则
641
+ extends: [eslint.configs.recommended],
642
+ languageOptions: {
643
+ // 允许使用最新的 ECMAScript 语法特性
644
+ ecmaVersion: "latest",
645
+ globals: {
646
+ ...globals.browser,
647
+ ...globals.es2022,
648
+ ...globals.node
649
+ },
650
+ parserOptions: {
651
+ ecmaFeatures: {
652
+ // 允许使用 JSX 语法,适用于 Vue 组件中的 JSX 代码。
653
+ jsx: true
654
+ },
655
+ sourceType: "module"
656
+ }
657
+ },
658
+ rules: javascriptRules
659
+ },
660
+ {
661
+ name: "@fast-china/javascript/md/js",
662
+ files: ["**/*.md/*.js"],
663
+ rules: {
664
+ // 使用使用控制台
665
+ "no-console": "off",
666
+ // 关闭 - 禁止使用未声明的变量,除非/*global *\/注释中提到
667
+ "no-undef": "off",
668
+ // 关闭 - 禁用对无法解析的模块导入的检查
669
+ "import/no-unresolved": "off",
670
+ // 关闭 - 禁止在文件中重复导入相同的模块
671
+ "import/no-duplicates": "off"
672
+ }
673
+ },
674
+ {
675
+ name: "@fast-china/javascript/script",
676
+ files: ["**/scripts/*", "**/cli.*"],
677
+ rules: {
678
+ // 使用使用控制台
679
+ "no-console": "off"
680
+ }
681
+ }
682
+ ]);
683
+
684
+ // src/flat/configs/json.ts
685
+ import eslintPluginJsonc from "eslint-plugin-jsonc";
686
+ import jsoncEslintParser from "jsonc-eslint-parser";
687
+ import tseslint5 from "typescript-eslint";
688
+ var jsonConfigs = tseslint5.config([
689
+ {
690
+ name: "@fast-china/json",
691
+ files: [CONST_JSON, CONST_JSONC, CONST_JSON5, CONST_JSON6],
692
+ // 继承某些已有的规则
693
+ extends: [...eslintPluginJsonc.configs["flat/recommended-with-jsonc"]],
694
+ languageOptions: {
695
+ parser: jsoncEslintParser
696
+ },
697
+ plugins: {
698
+ jsonc: eslintPluginJsonc
699
+ }
700
+ }
701
+ ]);
702
+
703
+ // src/flat/configs/markdown.ts
704
+ import eslintPluginMarkdown from "eslint-plugin-markdown";
705
+ import tseslint6 from "typescript-eslint";
706
+ var markdownConfigs = tseslint6.config([
707
+ {
708
+ name: "@fast-china/markdown",
709
+ files: [CONST_MD]
710
+ },
711
+ ...eslintPluginMarkdown.configs.recommended.map((config) => ({
712
+ ...config,
713
+ name: `@fast-china/${config.name || "markdown/anonymous"}`
714
+ }))
715
+ ]);
716
+
717
+ // src/flat/configs/prettier.ts
718
+ import eslintConfigPrettierFlat from "eslint-config-prettier/flat";
719
+ import eslintPluginPrettier from "eslint-plugin-prettier";
720
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
721
+ import tseslint7 from "typescript-eslint";
722
+ var prettierConfigs = tseslint7.config([
723
+ {
724
+ name: "@fast-china/prettier",
725
+ // 继承某些已有的规则
726
+ extends: [eslintConfigPrettierFlat, eslintPluginPrettierRecommended],
727
+ plugins: {
728
+ prettier: eslintPluginPrettier
729
+ },
730
+ rules: {
731
+ // 确保 Prettier 错误被 ESLint 捕获
732
+ "prettier/prettier": "error"
733
+ }
734
+ }
735
+ ]);
736
+
737
+ // src/flat/configs/regexp.ts
738
+ import eslintPluginRegexp from "eslint-plugin-regexp";
739
+ import tseslint8 from "typescript-eslint";
740
+ var regexpConfigs = tseslint8.config([
741
+ {
742
+ name: "@fast-china/regexp",
743
+ ...eslintPluginRegexp.configs["flat/recommended"]
744
+ }
745
+ ]);
746
+
747
+ // src/flat/configs/sort-package.ts
748
+ import tseslint9 from "typescript-eslint";
749
+ var packageJsonSortConfigs = tseslint9.config([
750
+ {
751
+ name: "@fast-china/sort/package",
752
+ files: ["**/package.json"],
753
+ rules: packageJsonSortRules
754
+ }
755
+ ]);
756
+
757
+ // src/flat/configs/sort-tsconfig.ts
758
+ import tseslint10 from "typescript-eslint";
759
+ var tsconfigJsonSortConfigs = tseslint10.config([
760
+ {
761
+ name: "@fast-china/sort/tsconfig",
762
+ files: CONST_TSCONFIG,
763
+ rules: tsconfigJsonSortRules
764
+ }
765
+ ]);
766
+
767
+ // src/flat/configs/typescript.ts
768
+ import tseslint11 from "typescript-eslint";
769
+ var typescriptCoreConfigs = tseslint11.config([
770
+ {
771
+ name: "@fast-china/typescript",
772
+ files: [CONST_TS, CONST_TSX],
773
+ // 继承某些已有的规则
774
+ extends: [tseslint11.configs.recommended],
775
+ languageOptions: {
776
+ // 允许使用最新的 ECMAScript 语法特性
777
+ ecmaVersion: "latest",
778
+ parser: tseslint11.parser,
779
+ parserOptions: {
780
+ ecmaFeatures: {
781
+ // 允许使用 TSX 语法,适用于 Vue 组件中的 TSX 代码。
782
+ tsx: true
783
+ },
784
+ sourceType: "module"
785
+ }
786
+ },
787
+ rules: typescriptRules
788
+ }
789
+ ]);
790
+ var typescriptConfigs = tseslint11.config([
791
+ ...typescriptCoreConfigs,
792
+ {
793
+ name: "@fast-china/typescript/dts",
794
+ files: [CONST_DTS],
795
+ rules: {
796
+ // 关闭 - 一致地使用 TypeScript 类型导入
797
+ "@typescript-eslint/consistent-type-imports": "off"
798
+ }
799
+ },
800
+ {
801
+ name: "@fast-china/typescript/vite",
802
+ files: ["**/vite.config.*"],
803
+ rules: {
804
+ // 关闭 - 要求在 TypeScript 函数和方法中显式地指定返回类型
805
+ "@typescript-eslint/explicit-function-return-type": "off"
806
+ }
807
+ },
808
+ {
809
+ name: "@fast-china/typescript/md/js",
810
+ files: ["**/*.md/*.ts"],
811
+ rules: {
812
+ // 允许定义未使用的变量
813
+ "@typescript-eslint/no-unused-vars": "off"
814
+ }
815
+ }
816
+ ]);
817
+
818
+ // src/flat/configs/vue.ts
819
+ import eslintPluginVue from "eslint-plugin-vue";
820
+ import tseslint12 from "typescript-eslint";
821
+ import vueEslintParser from "vue-eslint-parser";
822
+
823
+ // src/env/index.ts
824
+ import { getPackageInfoSync } from "local-pkg";
825
+ var getVueVersion = () => {
826
+ const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
827
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
828
+ return +pkg.version[0];
829
+ }
830
+ return 3;
831
+ };
832
+ var isVue3 = getVueVersion() === 3;
833
+
844
834
  // src/flat/configs/vue.ts
845
835
  var vueConfigs = tseslint12.config([
846
836
  {