@fast-china/eslint-config 1.0.23 → 1.0.24

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