@fast-china/eslint-config 1.0.16 → 1.0.18

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