@fast-china/eslint-config 1.0.7 → 1.0.9

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.
@@ -0,0 +1,972 @@
1
+ // src/configs/common.ts
2
+ import tseslint from "typescript-eslint";
3
+ var commonConfigs = tseslint.config([
4
+ {
5
+ name: "@fast-china/common",
6
+ rules: {
7
+ // 确保数组的回调函数(如 Array.prototype.map、Array.prototype.filter、Array.prototype.reduce 等)总是有一个返回值
8
+ "array-callback-return": "error",
9
+ // 强制使用块级作用域变量(let 或 const),避免使用函数作用域变量(var)
10
+ "block-scoped-var": "error",
11
+ // 禁止使用 alert、confirm 和 prompt 等浏览器弹出对话框
12
+ "no-alert": "warn",
13
+ // 禁止在 switch 语句的 case 或 default 子句中声明变量
14
+ "no-case-declarations": "error",
15
+ // 禁止使用多行字符串,即不允许使用反斜杠 \ 来连接多行字符串
16
+ "no-multi-str": "error",
17
+ // 禁止使用 with 语句
18
+ "no-with": "error",
19
+ // 禁止使用 void 操作符
20
+ "no-void": "error",
21
+ // 禁止多个空行
22
+ "no-multiple-empty-lines": [
23
+ "error",
24
+ {
25
+ // 最多允许1行
26
+ max: 1
27
+ }
28
+ ],
29
+ // import 排序
30
+ "sort-imports": [
31
+ "warn",
32
+ {
33
+ // 不忽略导入语句中模块名的大小写
34
+ ignoreCase: false,
35
+ // 忽略导入声明的排序
36
+ ignoreDeclarationSort: true,
37
+ // 不忽略导入成员的排序
38
+ ignoreMemberSort: false,
39
+ // 成员语法排序顺序
40
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
41
+ // 不允许分组导入
42
+ allowSeparatedGroups: false
43
+ }
44
+ ],
45
+ // 强制在数学运算中使用 ** 运算符代替 Math.pow()
46
+ "prefer-exponentiation-operator": "error"
47
+ }
48
+ }
49
+ ]);
50
+
51
+ // src/configs/ignores.ts
52
+ import tseslint2 from "typescript-eslint";
53
+
54
+ // src/constants/index.ts
55
+ var CONST_JS = "**/*.?([cm])js";
56
+ var CONST_JSX = "**/*.?([cm])jsx";
57
+ var CONST_TS = "**/*.?([cm])ts";
58
+ var CONST_TSX = "**/*.?([cm])tsx";
59
+ var CONST_JSON = "**/*.json";
60
+ var CONST_JSONC = "**/*.jsonc";
61
+ var CONST_JSON5 = "**/*.json5";
62
+ var CONST_JSON6 = "**/*.json6";
63
+ var CONST_MD = "**/*.md";
64
+ var CONST_VUE = "**/*.vue";
65
+ var CONST_YAML = "**/*.y?(a)ml";
66
+ var CONST_NODE_MODULES = "**/node_modules";
67
+ var CONST_DIST = "**/dist";
68
+ var CONST_LOCKFILE = [
69
+ "**/package-lock.json",
70
+ "**/yarn.lock",
71
+ "**/pnpm-lock.yaml",
72
+ "**/bun.lockb"
73
+ ];
74
+ var CONST_PUBLIC = "**/public";
75
+ var CONST_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
76
+
77
+ // src/configs/ignores.ts
78
+ import eslintConfigFlatGitignore from "eslint-config-flat-gitignore";
79
+ var ignoresConfigs = tseslint2.config([
80
+ {
81
+ name: "@fast-china/ignores/global",
82
+ ignores: [
83
+ CONST_NODE_MODULES,
84
+ CONST_DIST,
85
+ CONST_PUBLIC,
86
+ ...CONST_LOCKFILE,
87
+ "**/output",
88
+ "**/coverage",
89
+ "**/temp",
90
+ "**/fixtures",
91
+ "**/.vitepress/cache",
92
+ "**/.nuxt",
93
+ "**/.vercel",
94
+ "**/.changeset",
95
+ "**/.idea",
96
+ "**/.output",
97
+ "**/.vite-inspect",
98
+ "**/.nitro",
99
+ "**/CHANGELOG*.md",
100
+ "**/*.min.*",
101
+ "**/LICENSE*",
102
+ "**/__snapshots__",
103
+ "**/auto-import?(s).d.ts",
104
+ "**/components.d.ts"
105
+ ]
106
+ },
107
+ {
108
+ name: "@fast-china/ignores/git",
109
+ ...eslintConfigFlatGitignore({ strict: false })
110
+ }
111
+ ]);
112
+
113
+ // src/configs/import.ts
114
+ import tseslint3 from "typescript-eslint";
115
+ import eslintPluginImport from "eslint-plugin-import";
116
+ var importUseLodashUnifiedRules = {
117
+ // 限制某些模块导入
118
+ "no-restricted-imports": [
119
+ "error",
120
+ {
121
+ paths: [
122
+ { name: "lodash", message: "Use lodash-unified instead." },
123
+ { name: "lodash-es", message: "Use lodash-unified instead." }
124
+ ],
125
+ patterns: [
126
+ {
127
+ group: ["lodash/*", "lodash-es/*"],
128
+ message: "Use lodash-unified instead."
129
+ }
130
+ ]
131
+ }
132
+ ]
133
+ };
134
+ var importUseLodashRules = {
135
+ // 限制某些模块导入
136
+ "no-restricted-imports": [
137
+ "error",
138
+ {
139
+ paths: [
140
+ { name: "lodash-es", message: "Use lodash instead." },
141
+ { name: "lodash-unified", message: "Use lodash instead." }
142
+ ],
143
+ patterns: [
144
+ {
145
+ group: ["lodash-es/*", "lodash-unified/*"],
146
+ message: "Use lodash instead."
147
+ }
148
+ ]
149
+ }
150
+ ]
151
+ };
152
+ var importConfigs = tseslint3.config([
153
+ {
154
+ name: "@fast-china/import",
155
+ // 继承某些已有的规则
156
+ extends: [eslintPluginImport.flatConfigs.recommended],
157
+ settings: {
158
+ // 确保 ESLint 和 eslint-plugin-import 能够正确解析项目中的所有相关文件类型
159
+ "import/resolver": {
160
+ node: {
161
+ extensions: [CONST_JS, CONST_JSX, CONST_TS, CONST_TSX, ".d.ts"]
162
+ }
163
+ }
164
+ },
165
+ rules: {
166
+ // 确保所有的 import 语句位于文件的顶部,紧接在文件的开头部分,且在任何其他代码之前
167
+ "import/first": "error",
168
+ // 禁止在同一文件中出现重复的 import 语句
169
+ "import/no-duplicates": "error",
170
+ // 导入模块排序风格
171
+ "import/order": [
172
+ "error",
173
+ {
174
+ // 导入模块分组
175
+ groups: [
176
+ // Node.js 内置模块
177
+ "builtin",
178
+ // 第三方模块
179
+ "external",
180
+ // 项目内部模块
181
+ "internal",
182
+ // 父级目录中的模块
183
+ "parent",
184
+ // 具有相同父级的模块
185
+ "sibling",
186
+ // 当前目录的 index.js 或 index.ts 文件
187
+ "index",
188
+ "object",
189
+ "type",
190
+ "unknown"
191
+ ],
192
+ pathGroups: [
193
+ {
194
+ pattern: "vue",
195
+ group: "external",
196
+ position: "before"
197
+ },
198
+ {
199
+ pattern: "@vue/**",
200
+ group: "external",
201
+ position: "before"
202
+ },
203
+ {
204
+ pattern: "element-plus",
205
+ group: "external",
206
+ position: "before"
207
+ },
208
+ {
209
+ pattern: "@element-plus/**",
210
+ group: "external",
211
+ position: "before"
212
+ },
213
+ {
214
+ pattern: "fast-element-plus",
215
+ group: "external",
216
+ position: "before"
217
+ },
218
+ {
219
+ pattern: "@fast-element-plus/**",
220
+ group: "external",
221
+ position: "before"
222
+ },
223
+ {
224
+ pattern: "@fast-china/**",
225
+ group: "external",
226
+ position: "before"
227
+ }
228
+ ],
229
+ pathGroupsExcludedImportTypes: ["type"],
230
+ // 禁止不同组之间进行换行
231
+ "newlines-between": "never",
232
+ //根据字母顺序对每个组内的顺序进行排序
233
+ alphabetize: {
234
+ order: "asc",
235
+ caseInsensitive: true
236
+ }
237
+ }
238
+ ],
239
+ // 关闭 - 禁用对无法解析的模块导入的检查
240
+ "import/no-unresolved": "off",
241
+ // 关闭 - 禁用对命名空间导入(例如,import * as)的检查
242
+ "import/namespace": "off",
243
+ // 关闭 - 禁用对默认导入的检查
244
+ "import/default": "off",
245
+ // 关闭 - 禁用对以默认导出方式作为命名导入的检查
246
+ "import/no-named-as-default": "off",
247
+ // 关闭 - 禁用对将默认导出成员当作命名导入的检查
248
+ "import/no-named-as-default-member": "off",
249
+ // 关闭 - 禁用对命名导入(即从模块中导入特定命名的内容)的检查
250
+ "import/named": "off",
251
+ ...importUseLodashUnifiedRules
252
+ }
253
+ }
254
+ ]);
255
+
256
+ // src/configs/javascript.ts
257
+ import tseslint4 from "typescript-eslint";
258
+ import globals from "globals";
259
+ import eslint from "@eslint/js";
260
+ var javascriptConfigs = tseslint4.config([
261
+ {
262
+ name: "@fast-china/javascript",
263
+ // 继承某些已有的规则
264
+ extends: [eslint.configs.recommended],
265
+ languageOptions: {
266
+ // 允许使用最新的 ECMAScript 语法特性
267
+ ecmaVersion: "latest",
268
+ globals: {
269
+ ...globals.browser,
270
+ ...globals.es2022,
271
+ ...globals.node
272
+ },
273
+ parserOptions: {
274
+ // 允许使用 JSX 语法,适用于 Vue 组件中的 JSX 代码。
275
+ ecmaFeatures: {
276
+ jsx: true
277
+ },
278
+ sourceType: "module"
279
+ }
280
+ },
281
+ rules: {
282
+ // JS/TS (http://eslint.cn/docs/rules)
283
+ // 强制使用 camelCase 命名风格
284
+ camelcase: [
285
+ "error",
286
+ {
287
+ // 允许对象属性使用非 camelCase 风格
288
+ properties: "never"
289
+ }
290
+ ],
291
+ // 禁止使用控制台
292
+ "no-console": [
293
+ "warn",
294
+ {
295
+ // 允许除 warn/error 之外的其他 console.xx 方法
296
+ allow: ["warn", "error"]
297
+ }
298
+ ],
299
+ // 禁止使用 debugger
300
+ "no-debugger": "warn",
301
+ // 禁止在条件语句中使用常量条件
302
+ "no-constant-condition": [
303
+ "error",
304
+ {
305
+ // 允许在循环语句中使用常量条件
306
+ checkLoops: false
307
+ }
308
+ ],
309
+ // 禁止使用某些特定的语法
310
+ "no-restricted-syntax": [
311
+ "error",
312
+ // 禁止使用标记语句(labeled statements)
313
+ "LabeledStatement",
314
+ // 禁止使用 with 语句
315
+ "WithStatement"
316
+ ],
317
+ // 禁止在 return 语句中使用 await
318
+ "no-return-await": "error",
319
+ // 禁止使用 var 关键字,强制使用 let 或 const
320
+ "no-var": "error",
321
+ // 禁止使用空的块语句
322
+ "no-empty": [
323
+ "error",
324
+ {
325
+ // 允许空的 catch 块
326
+ allowEmptyCatch: true
327
+ }
328
+ ],
329
+ // 该规则禁止使用不规则或不标准的空白字符
330
+ "no-irregular-whitespace": "error",
331
+ // 禁止在函数或变量定义之前使用它们
332
+ "no-use-before-define": "warn",
333
+ // 强制使用 const 声明不被修改的变量
334
+ "prefer-const": [
335
+ "warn",
336
+ {
337
+ // 在解构赋值时也推荐使用 const
338
+ destructuring: "all",
339
+ // 允许在变量首次赋值前读取变量的值
340
+ ignoreReadBeforeAssign: true
341
+ }
342
+ ],
343
+ // 强制使用箭头函数而非普通函数
344
+ "prefer-arrow-callback": [
345
+ "error",
346
+ {
347
+ // 不允许使用命名函数作为回调函数
348
+ allowNamedFunctions: false,
349
+ // 允许在箭头函数中使用 this 绑定的上下文
350
+ allowUnboundThis: true
351
+ }
352
+ ],
353
+ // 强制使用对象字面量的方法和属性简写语法
354
+ "object-shorthand": [
355
+ "error",
356
+ "always",
357
+ {
358
+ // 不忽略构造函数中的属性简写
359
+ ignoreConstructors: false,
360
+ // 强制避免在属性名中使用引号
361
+ avoidQuotes: true
362
+ }
363
+ ],
364
+ // 强制使用 rest 参数代替 arguments 对象
365
+ "prefer-rest-params": "error",
366
+ // 强制使用展开运算符(...)代替 Function.prototype.apply
367
+ "prefer-spread": "error",
368
+ // 强制使用模板字面量代替字符串连接
369
+ "prefer-template": "error",
370
+ // 禁止在同一作用域中重新声明变量
371
+ "no-redeclare": "error"
372
+ }
373
+ },
374
+ {
375
+ name: "@fast-china/javascript/jsx",
376
+ files: [CONST_JSX],
377
+ rules: {
378
+ // 关闭 - 禁止使用未声明的变量,除非/*global *\/注释中提到
379
+ "no-undef": "off"
380
+ }
381
+ },
382
+ {
383
+ name: "@fast-china/javascript/md/js",
384
+ files: ["**/*.md/*.js"],
385
+ rules: {
386
+ // 使用使用控制台
387
+ "no-console": "off",
388
+ // 关闭 - 禁用对无法解析的模块导入的检查
389
+ "import/no-unresolved": "off"
390
+ }
391
+ },
392
+ {
393
+ name: "@fast-china/javascript/script",
394
+ files: ["**/scripts/*", "**/cli.*"],
395
+ rules: {
396
+ // 使用使用控制台
397
+ "no-console": "off"
398
+ }
399
+ }
400
+ ]);
401
+
402
+ // src/configs/json.ts
403
+ import tseslint5 from "typescript-eslint";
404
+ import eslintPluginJsonc from "eslint-plugin-jsonc";
405
+ import jsoncEslintParser from "jsonc-eslint-parser";
406
+ var jsonConfigs = tseslint5.config([
407
+ {
408
+ name: "@fast-china/json",
409
+ files: [CONST_JSON, CONST_JSONC, CONST_JSON5, CONST_JSON6],
410
+ // 继承某些已有的规则
411
+ extends: [...eslintPluginJsonc.configs["flat/recommended-with-jsonc"]],
412
+ languageOptions: {
413
+ parser: jsoncEslintParser
414
+ },
415
+ plugins: {
416
+ jsonc: eslintPluginJsonc
417
+ },
418
+ rules: {}
419
+ }
420
+ ]);
421
+
422
+ // src/configs/markdown.ts
423
+ import tseslint6 from "typescript-eslint";
424
+ import eslintPluginMarkdown from "eslint-plugin-markdown";
425
+ var markdownConfigs = tseslint6.config([
426
+ {
427
+ name: "@fast-china/markdown",
428
+ files: [CONST_MD],
429
+ rules: {}
430
+ },
431
+ ...eslintPluginMarkdown.configs.recommended.map((config) => ({
432
+ ...config,
433
+ name: `@fast-china/${config.name || "markdown/anonymous"}`
434
+ }))
435
+ ]);
436
+
437
+ // src/configs/prettier.ts
438
+ import tseslint7 from "typescript-eslint";
439
+ import eslintConfigPrettier from "eslint-config-prettier";
440
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
441
+ var prettierConfigs = tseslint7.config([
442
+ {
443
+ name: "@fast-china/prettier",
444
+ // 继承某些已有的规则
445
+ extends: [eslintPluginPrettierRecommended],
446
+ plugins: {
447
+ prettier: eslintConfigPrettier
448
+ },
449
+ rules: {
450
+ // 确保 Prettier 错误被 ESLint 捕获
451
+ "prettier/prettier": "error"
452
+ }
453
+ }
454
+ ]);
455
+
456
+ // src/configs/regexp.ts
457
+ import tseslint8 from "typescript-eslint";
458
+ import eslintPluginRegexp from "eslint-plugin-regexp";
459
+ var regexpConfigs = tseslint8.config([
460
+ {
461
+ name: "@fast-china/regexp",
462
+ ...eslintPluginRegexp.configs["flat/recommended"]
463
+ }
464
+ ]);
465
+
466
+ // src/configs/sort-package.ts
467
+ import tseslint9 from "typescript-eslint";
468
+ var packageJsonSortConfigs = tseslint9.config([
469
+ {
470
+ name: "@fast-china/sort/package",
471
+ files: ["**/package.json"],
472
+ rules: {
473
+ "jsonc/sort-array-values": [
474
+ "error",
475
+ {
476
+ order: { type: "asc" },
477
+ pathPattern: "^files$"
478
+ }
479
+ ],
480
+ "jsonc/sort-keys": [
481
+ "error",
482
+ {
483
+ order: [
484
+ "name",
485
+ "version",
486
+ "private",
487
+ "packageManager",
488
+ "description",
489
+ "type",
490
+ "keywords",
491
+ "license",
492
+ "homepage",
493
+ "bugs",
494
+ "repository",
495
+ "author",
496
+ "contributors",
497
+ "funding",
498
+ "files",
499
+ "main",
500
+ "module",
501
+ "types",
502
+ "exports",
503
+ "typesVersions",
504
+ "sideEffects",
505
+ "unpkg",
506
+ "jsdelivr",
507
+ "browser",
508
+ "bin",
509
+ "man",
510
+ "directories",
511
+ "publishConfig",
512
+ "scripts",
513
+ "peerDependencies",
514
+ "peerDependenciesMeta",
515
+ "optionalDependencies",
516
+ "dependencies",
517
+ "devDependencies",
518
+ "engines",
519
+ "config",
520
+ "overrides",
521
+ "pnpm",
522
+ "husky",
523
+ "lint-staged",
524
+ "eslintConfig",
525
+ "prettier"
526
+ ],
527
+ pathPattern: "^$"
528
+ },
529
+ {
530
+ order: { type: "asc" },
531
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
532
+ },
533
+ {
534
+ order: ["types", "require", "import", "default"],
535
+ pathPattern: "^exports.*$"
536
+ },
537
+ {
538
+ order: { type: "asc" },
539
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
540
+ }
541
+ ]
542
+ }
543
+ }
544
+ ]);
545
+
546
+ // src/configs/sort-tsconfig.ts
547
+ import tseslint10 from "typescript-eslint";
548
+ var tsconfigJsonSortConfigs = tseslint10.config([
549
+ {
550
+ name: "@fast-china/sort/tsconfig",
551
+ files: [CONST_TSCONFIG],
552
+ rules: {
553
+ "jsonc/sort-keys": [
554
+ "error",
555
+ {
556
+ order: [
557
+ "extends",
558
+ "compilerOptions",
559
+ "references",
560
+ "files",
561
+ "include",
562
+ "exclude"
563
+ ],
564
+ pathPattern: "^$"
565
+ },
566
+ {
567
+ order: [
568
+ /* Projects */
569
+ "incremental",
570
+ "composite",
571
+ "tsBuildInfoFile",
572
+ "disableSourceOfProjectReferenceRedirect",
573
+ "disableSolutionSearching",
574
+ "disableReferencedProjectLoad",
575
+ /* Language and Environment */
576
+ "target",
577
+ "jsx",
578
+ "jsxFactory",
579
+ "jsxFragmentFactory",
580
+ "jsxImportSource",
581
+ "lib",
582
+ "moduleDetection",
583
+ "noLib",
584
+ "reactNamespace",
585
+ "useDefineForClassFields",
586
+ "emitDecoratorMetadata",
587
+ "experimentalDecorators",
588
+ /* Modules */
589
+ "baseUrl",
590
+ "rootDir",
591
+ "rootDirs",
592
+ "customConditions",
593
+ "module",
594
+ "moduleResolution",
595
+ "moduleSuffixes",
596
+ "noResolve",
597
+ "paths",
598
+ "resolveJsonModule",
599
+ "resolvePackageJsonExports",
600
+ "resolvePackageJsonImports",
601
+ "typeRoots",
602
+ "types",
603
+ "allowArbitraryExtensions",
604
+ "allowImportingTsExtensions",
605
+ "allowUmdGlobalAccess",
606
+ /* JavaScript Support */
607
+ "allowJs",
608
+ "checkJs",
609
+ "maxNodeModuleJsDepth",
610
+ /* Type Checking */
611
+ "strict",
612
+ "strictBindCallApply",
613
+ "strictFunctionTypes",
614
+ "strictNullChecks",
615
+ "strictPropertyInitialization",
616
+ "allowUnreachableCode",
617
+ "allowUnusedLabels",
618
+ "alwaysStrict",
619
+ "exactOptionalPropertyTypes",
620
+ "noFallthroughCasesInSwitch",
621
+ "noImplicitAny",
622
+ "noImplicitOverride",
623
+ "noImplicitReturns",
624
+ "noImplicitThis",
625
+ "noPropertyAccessFromIndexSignature",
626
+ "noUncheckedIndexedAccess",
627
+ "noUnusedLocals",
628
+ "noUnusedParameters",
629
+ "useUnknownInCatchVariables",
630
+ /* Emit */
631
+ "declaration",
632
+ "declarationDir",
633
+ "declarationMap",
634
+ "downlevelIteration",
635
+ "emitBOM",
636
+ "emitDeclarationOnly",
637
+ "importHelpers",
638
+ "importsNotUsedAsValues",
639
+ "inlineSourceMap",
640
+ "inlineSources",
641
+ "isolatedDeclarations",
642
+ "mapRoot",
643
+ "newLine",
644
+ "noEmit",
645
+ "noEmitHelpers",
646
+ "noEmitOnError",
647
+ "outDir",
648
+ "outFile",
649
+ "preserveConstEnums",
650
+ "preserveValueImports",
651
+ "removeComments",
652
+ "sourceMap",
653
+ "sourceRoot",
654
+ "stripInternal",
655
+ /* Interop Constraints */
656
+ "allowSyntheticDefaultImports",
657
+ "esModuleInterop",
658
+ "forceConsistentCasingInFileNames",
659
+ "isolatedModules",
660
+ "preserveSymlinks",
661
+ "verbatimModuleSyntax",
662
+ /* Completeness */
663
+ "skipDefaultLibCheck",
664
+ "skipLibCheck"
665
+ ],
666
+ pathPattern: "^compilerOptions$"
667
+ }
668
+ ]
669
+ }
670
+ }
671
+ ]);
672
+
673
+ // src/configs/typescript.ts
674
+ import tseslint11 from "typescript-eslint";
675
+ var typescriptCoreConfigs = tseslint11.config([
676
+ {
677
+ name: "@fast-china/typescript",
678
+ files: [CONST_TS, CONST_TSX],
679
+ // 继承某些已有的规则
680
+ extends: [tseslint11.configs.recommended],
681
+ languageOptions: {
682
+ // 允许使用最新的 ECMAScript 语法特性
683
+ ecmaVersion: "latest",
684
+ parser: tseslint11.parser,
685
+ parserOptions: {
686
+ // 允许使用 TSX 语法,适用于 Vue 组件中的 TSX 代码。
687
+ ecmaFeatures: {
688
+ tsx: true
689
+ },
690
+ sourceType: "module"
691
+ }
692
+ },
693
+ rules: {
694
+ // TS (https://typescript-eslint.io/rules)
695
+ // 要求在导出函数和类的公共方法上显式声明返回类型
696
+ "@typescript-eslint/explicit-module-boundary-types": "off",
697
+ // 要求在 TypeScript 函数和方法中显式地指定返回类型
698
+ "@typescript-eslint/explicit-function-return-type": "error",
699
+ // 禁止在同一作用域中重新声明 TypeScript 变量
700
+ "@typescript-eslint/no-redeclare": "error",
701
+ // 允许定义未使用的变量
702
+ "@typescript-eslint/no-unused-vars": "off",
703
+ // 允许使用自定义TypeScript模块和命名空间
704
+ "@typescript-eslint/no-namespace": "off",
705
+ // 允许使用 any 类型
706
+ "@typescript-eslint/no-explicit-any": "off",
707
+ // 禁止在 TypeScript 文件中使用 require 函数进行模块导入
708
+ "@typescript-eslint/no-var-requires": "error",
709
+ // 禁止定义空函数
710
+ "@typescript-eslint/no-empty-function": "error",
711
+ // 禁止无用的表达式
712
+ "@typescript-eslint/no-unused-expressions": [
713
+ "error",
714
+ {
715
+ // 允许短路操作符(&& 和 ||)中的无副作用表达式
716
+ allowShortCircuit: true,
717
+ // 允许三元操作符中的无副作用表达式
718
+ allowTernary: true
719
+ }
720
+ ],
721
+ // 禁止在 TypeScript 代码中对类型已经可以被推断的变量或参数进行显式的类型注解
722
+ "@typescript-eslint/no-inferrable-types": "error",
723
+ // 禁止使用后缀运算符的非空断言(!)
724
+ "@typescript-eslint/no-non-null-assertion": "error",
725
+ // 禁止在可选链(?)后使用非空断言(!)
726
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
727
+ // 禁止在代码中使用 @ts-ignore 注释
728
+ "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": false }],
729
+ // 一致地使用 TypeScript 类型导入
730
+ "@typescript-eslint/consistent-type-imports": [
731
+ "error",
732
+ {
733
+ // 允许使用类型注解
734
+ disallowTypeAnnotations: false
735
+ }
736
+ ]
737
+ }
738
+ }
739
+ ]);
740
+ var typescriptConfigs = tseslint11.config([
741
+ ...typescriptCoreConfigs,
742
+ {
743
+ name: "@fast-china/typescript/dts",
744
+ files: ["**/*.d.ts"],
745
+ rules: {
746
+ // 关闭 - 禁止在文件中重复导入相同的模块
747
+ "import/no-duplicates": "off",
748
+ // 关闭 - 一致地使用 TypeScript 类型导入
749
+ "@typescript-eslint/consistent-type-imports": "off"
750
+ }
751
+ },
752
+ {
753
+ name: "@fast-china/typescript/tsx",
754
+ files: [CONST_TSX],
755
+ rules: {
756
+ // 关闭 - 要求在 TypeScript 函数和方法中显式地指定返回类型
757
+ // "@typescript-eslint/explicit-function-return-type": "off",
758
+ }
759
+ },
760
+ {
761
+ name: "@fast-china/typescript/cjs",
762
+ files: [CONST_JS],
763
+ rules: {
764
+ // 关闭 - 不允许使用 require 语句
765
+ "@typescript-eslint/no-var-requires": "off",
766
+ "@typescript-eslint/no-require-imports": "off"
767
+ }
768
+ },
769
+ {
770
+ name: "@fast-china/typescript/md/js",
771
+ files: ["**/*.md/*.ts"],
772
+ rules: {
773
+ // 允许定义未使用的变量
774
+ "@typescript-eslint/no-unused-vars": "off"
775
+ }
776
+ }
777
+ ]);
778
+
779
+ // src/configs/vue.ts
780
+ import tseslint12 from "typescript-eslint";
781
+ import eslintPluginVue from "eslint-plugin-vue";
782
+ import vueEslintParser from "vue-eslint-parser";
783
+
784
+ // src/env/index.ts
785
+ import process from "node:process";
786
+ import { getPackageInfoSync } from "local-pkg";
787
+ import { isPackageExists } from "local-pkg";
788
+ var getVueVersion = () => {
789
+ const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
790
+ if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
791
+ return +pkg.version[0];
792
+ }
793
+ return 3;
794
+ };
795
+ var hasVue = isPackageExists("vue") || isPackageExists("nuxt");
796
+ var isVue3 = getVueVersion() === 3;
797
+
798
+ // src/configs/vue.ts
799
+ var vueConfigs = tseslint12.config([
800
+ {
801
+ name: "@fast-china/vue",
802
+ files: [CONST_VUE],
803
+ // 继承某些已有的规则
804
+ extends: [
805
+ ...isVue3 ? eslintPluginVue.configs["flat/recommended"] : eslintPluginVue.configs["flat/vue2-recommended"]
806
+ ],
807
+ languageOptions: {
808
+ parser: vueEslintParser,
809
+ parserOptions: {
810
+ // 允许在 Vue 文件中的脚本部分使用 TypeScript 语法
811
+ parser: "@typescript-eslint/parser",
812
+ // 指定额外的文件扩展名,告诉解析器 .vue 文件也需要处理
813
+ extraFileExtensions: [".vue"],
814
+ // 允许使用最新的 ECMAScript 语法特性
815
+ ecmaVersion: "latest",
816
+ // 允许使用 JSX/TSX 语法,适用于 Vue 组件中的 JSX/TSX 代码。
817
+ ecmaFeatures: {
818
+ jsx: true,
819
+ tsx: true
820
+ },
821
+ sourceType: "module"
822
+ }
823
+ },
824
+ plugins: {
825
+ "@typescript-eslint": tseslint12.plugin,
826
+ vue: vueEslintParser
827
+ },
828
+ processor: eslintPluginVue.processors[".vue"],
829
+ rules: {
830
+ // vue (https://eslint.vuejs.org/rules)
831
+ // 关闭 - 禁止使用未声明的变量,以避免在 .vue 文件中出现关于未定义变量的警告,这在 Vue 单文件组件中可能不适用或会导致不必要的警告
832
+ "no-undef": "off",
833
+ // 允许使用 v-html
834
+ "vue/no-v-html": "off",
835
+ // 禁用所有 props 必填时,必须提供默认值
836
+ "vue/require-default-prop": "off",
837
+ // 强制组件中必须使用 emits 选项声明事件
838
+ "vue/require-explicit-emits": "error",
839
+ // 禁用组件名称必须是多单词
840
+ "vue/multi-word-component-names": "off",
841
+ // 关闭 - 强制从 vue 中导入 Vue相关 API
842
+ "vue/prefer-import-from-vue": "off",
843
+ // 强制 HTML 属性使用 camelCase 风格
844
+ "vue/attribute-hyphenation": [
845
+ "error",
846
+ "always",
847
+ {
848
+ ignore: [
849
+ // 忽略 Element-Plus 加载文案"element-loading-text"
850
+ ]
851
+ }
852
+ ],
853
+ // 禁止重复的字段名
854
+ "vue/no-dupe-keys": "error",
855
+ // 禁止直接修改 props 的值
856
+ "vue/no-mutating-props": "error",
857
+ // 禁止使用 Vue.js 内置的保留组件名称(如 transition、keep-alive 等)作为自定义组件名称
858
+ "vue/no-reserved-component-names": "error",
859
+ // 禁止在自定义组件上使用 v-text 或 v-html 指令
860
+ "vue/no-v-text-v-html-on-component": "off",
861
+ // 防止<script setup>使用的变量<template>被标记为未使用,此规则仅在启用该no-unused-vars规则时有效。
862
+ // "vue/script-setup-uses-vars": "error",
863
+ // 强制自定义事件名称使用 camelCase 风格命名
864
+ "vue/custom-event-name-casing": ["error", "camelCase"],
865
+ // 强制每个 Vue 文件中只包含一个 Vue 组件
866
+ "vue/one-component-per-file": "off",
867
+ // 闭合标签换行风格
868
+ "vue/html-closing-bracket-newline": [
869
+ "error",
870
+ {
871
+ // 强制要求当 HTML 元素跨多行时,闭合标签必须出现在新的一行上
872
+ multiline: "always",
873
+ // 强制要求当 HTML 元素只有一行时,闭合标签应与开始标签在同一行上
874
+ singleline: "never"
875
+ }
876
+ ],
877
+ // 强制 Vue 模板中 HTML 元素的属性按照指定的顺序排列
878
+ "vue/attributes-order": [
879
+ "error",
880
+ {
881
+ order: [
882
+ "DEFINITION",
883
+ "LIST_RENDERING",
884
+ "CONDITIONALS",
885
+ "RENDER_MODIFIERS",
886
+ "GLOBAL",
887
+ "UNIQUE",
888
+ "OTHER_ATTR",
889
+ "EVENTS",
890
+ "CONTENT"
891
+ ]
892
+ }
893
+ ]
894
+ }
895
+ },
896
+ {
897
+ name: "@fast-china/vue/ts",
898
+ files: [CONST_VUE],
899
+ // 继承某些已有的规则
900
+ extends: [...typescriptCoreConfigs]
901
+ },
902
+ {
903
+ name: "@fast-china/reactivity",
904
+ languageOptions: {
905
+ globals: {
906
+ $: "readonly",
907
+ $$: "readonly",
908
+ $computed: "readonly",
909
+ $customRef: "readonly",
910
+ $ref: "readonly",
911
+ $shallowRef: "readonly",
912
+ $toRef: "readonly"
913
+ }
914
+ },
915
+ plugins: {
916
+ vue: eslintPluginVue
917
+ }
918
+ }
919
+ ]);
920
+
921
+ // src/flat/index.ts
922
+ var index_default = [
923
+ ...ignoresConfigs,
924
+ ...commonConfigs,
925
+ ...regexpConfigs,
926
+ ...javascriptConfigs,
927
+ ...typescriptConfigs,
928
+ ...importConfigs,
929
+ ...prettierConfigs,
930
+ ...packageJsonSortConfigs,
931
+ ...tsconfigJsonSortConfigs,
932
+ ...vueConfigs,
933
+ ...jsonConfigs,
934
+ ...markdownConfigs
935
+ ];
936
+ export {
937
+ CONST_DIST,
938
+ CONST_JS,
939
+ CONST_JSON,
940
+ CONST_JSON5,
941
+ CONST_JSON6,
942
+ CONST_JSONC,
943
+ CONST_JSX,
944
+ CONST_LOCKFILE,
945
+ CONST_MD,
946
+ CONST_NODE_MODULES,
947
+ CONST_PUBLIC,
948
+ CONST_TS,
949
+ CONST_TSCONFIG,
950
+ CONST_TSX,
951
+ CONST_VUE,
952
+ CONST_YAML,
953
+ commonConfigs,
954
+ index_default as default,
955
+ hasVue,
956
+ ignoresConfigs,
957
+ importConfigs,
958
+ importUseLodashRules,
959
+ importUseLodashUnifiedRules,
960
+ isVue3,
961
+ javascriptConfigs,
962
+ jsonConfigs,
963
+ markdownConfigs,
964
+ packageJsonSortConfigs,
965
+ prettierConfigs,
966
+ regexpConfigs,
967
+ tsconfigJsonSortConfigs,
968
+ typescriptConfigs,
969
+ typescriptCoreConfigs,
970
+ vueConfigs
971
+ };
972
+ //# sourceMappingURL=index.js.map