@fast-china/eslint-config 2.1.7 → 2.1.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.
- package/CHANGELOG.md +31 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +103 -144
- package/README.zh.md +101 -144
- package/dist/configs/environment.mjs +2 -0
- package/dist/configs/environment.mjs.map +1 -1
- package/dist/configs/ignores.mjs +0 -1
- package/dist/configs/ignores.mjs.map +1 -1
- package/dist/configs/import.mjs +4 -1
- package/dist/configs/import.mjs.map +1 -1
- package/dist/configs/index.d.mts +2 -2
- package/dist/configs/index.mjs +2 -2
- package/dist/configs/javascript.mjs +3 -1
- package/dist/configs/javascript.mjs.map +1 -1
- package/dist/configs/json.mjs +3 -1
- package/dist/configs/json.mjs.map +1 -1
- package/dist/configs/markdown.d.mts +2 -1
- package/dist/configs/markdown.mjs +4 -2
- package/dist/configs/markdown.mjs.map +1 -1
- package/dist/configs/prettier.mjs +1 -1
- package/dist/configs/prettier.mjs.map +1 -1
- package/dist/configs/sort-package.d.mts +1 -1
- package/dist/configs/sort-package.mjs +1 -1
- package/dist/configs/sort-package.mjs.map +1 -1
- package/dist/configs/sort-tsconfig.d.mts +2 -2
- package/dist/configs/sort-tsconfig.mjs +2 -2
- package/dist/configs/sort-tsconfig.mjs.map +1 -1
- package/dist/configs/typescript.d.mts +11 -7
- package/dist/configs/typescript.mjs +25 -22
- package/dist/configs/typescript.mjs.map +1 -1
- package/dist/configs/uniapp.mjs +19 -13
- package/dist/configs/uniapp.mjs.map +1 -1
- package/dist/configs/vue.d.mts +18 -3
- package/dist/configs/vue.mjs +61 -9
- package/dist/configs/vue.mjs.map +1 -1
- package/dist/constants/index.d.mts +4 -0
- package/dist/constants/index.mjs +5 -1
- package/dist/constants/index.mjs.map +1 -1
- package/dist/index.d.mts +37 -58
- package/dist/index.mjs +43 -47
- package/dist/index.mjs.map +1 -1
- package/dist/rules/angular.d.mts +28 -0
- package/dist/rules/angular.mjs +28 -0
- package/dist/rules/angular.mjs.map +1 -1
- package/dist/rules/common.d.mts +16 -6
- package/dist/rules/common.mjs +16 -13
- package/dist/rules/common.mjs.map +1 -1
- package/dist/rules/import.d.mts +9 -0
- package/dist/rules/import.mjs +24 -0
- package/dist/rules/import.mjs.map +1 -1
- package/dist/rules/index.d.mts +2 -2
- package/dist/rules/index.mjs +2 -2
- package/dist/rules/javascript.d.mts +18 -0
- package/dist/rules/javascript.mjs +18 -0
- package/dist/rules/javascript.mjs.map +1 -1
- package/dist/rules/lodash.d.mts +2 -0
- package/dist/rules/lodash.mjs +6 -2
- package/dist/rules/lodash.mjs.map +1 -1
- package/dist/rules/react.d.mts +13 -0
- package/dist/rules/react.mjs +13 -0
- package/dist/rules/react.mjs.map +1 -1
- package/dist/rules/regexp.d.mts +25 -0
- package/dist/rules/regexp.mjs +25 -0
- package/dist/rules/regexp.mjs.map +1 -1
- package/dist/rules/sort-package.d.mts +3 -1
- package/dist/rules/sort-package.mjs +3 -1
- package/dist/rules/sort-package.mjs.map +1 -1
- package/dist/rules/sort-tsconfig.d.mts +3 -1
- package/dist/rules/sort-tsconfig.mjs +3 -1
- package/dist/rules/sort-tsconfig.mjs.map +1 -1
- package/dist/rules/typescript.d.mts +81 -13
- package/dist/rules/typescript.mjs +83 -15
- package/dist/rules/typescript.mjs.map +1 -1
- package/dist/rules/vue.d.mts +65 -10
- package/dist/rules/vue.mjs +41 -14
- package/dist/rules/vue.mjs.map +1 -1
- package/docs/engineering-audit.zh.md +45 -49
- package/docs/rules/angular.zh.md +721 -0
- package/docs/rules/core.zh.md +3031 -0
- package/docs/rules/index.zh.md +38 -0
- package/docs/rules/json.zh.md +784 -0
- package/docs/rules/markdown.zh.md +449 -0
- package/docs/rules/react.zh.md +2091 -0
- package/docs/rules/typescript.zh.md +2052 -0
- package/docs/rules/vue.zh.md +3016 -0
- package/docs/rules-risk.md +85 -91
- package/docs/rules-risk.zh.md +76 -82
- package/package.json +4 -2
|
@@ -3,19 +3,23 @@
|
|
|
3
3
|
* TypeScript 本地覆写规则。
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* `.ts`、`.mts` 与 `.cts` 导出成员视为模块公共 API,参数与返回类型必须显式声明;
|
|
7
|
+
* 内部实现和内联回调保留类型推断。TSX 由配置末尾覆写保留组件返回类型推断。
|
|
8
8
|
*/
|
|
9
9
|
export declare const typescriptRules: {
|
|
10
|
+
/** 单独组合 `createTypeScriptConfigs()` 时也禁止用 `void` 操作符标记被忽略的 Promise。 */
|
|
10
11
|
"no-void": "error";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/** TypeScript 重载与声明合并由扩展规则识别,关闭会把合法重载误判为重复声明的核心规则。 */
|
|
13
|
+
"no-redeclare": "off";
|
|
14
|
+
/** [默认关闭] 内部函数依赖 TypeScript 推断;公共导出边界由模块边界规则单独检查。 */
|
|
15
|
+
"@typescript-eslint/explicit-function-return-type": "off";
|
|
16
|
+
/** 导出函数和类的公共方法必须显式声明参数与返回类型,使公共 API 不依赖实现细节推断;参数不允许显式 `any`。 */
|
|
15
17
|
"@typescript-eslint/explicit-module-boundary-types": ["error", {
|
|
16
18
|
allowArgumentsExplicitlyTypedAsAny: false;
|
|
17
19
|
}];
|
|
20
|
+
/** 使用 TypeScript 版本避免核心规则误判声明合并、类型和值的同名声明。 */
|
|
18
21
|
"@typescript-eslint/no-redeclare": "error";
|
|
22
|
+
/** 未使用符号视为错误;仅参数和异常可用下划线明确表示有意忽略。 */
|
|
19
23
|
"@typescript-eslint/no-unused-vars": ["error", {
|
|
20
24
|
args: "after-used";
|
|
21
25
|
argsIgnorePattern: string;
|
|
@@ -23,55 +27,119 @@ export declare const typescriptRules: {
|
|
|
23
27
|
caughtErrorsIgnorePattern: string;
|
|
24
28
|
ignoreRestSiblings: true;
|
|
25
29
|
}];
|
|
30
|
+
/** [默认关闭] 声明文件、全局扩展和部分 SDK 仍需要 `namespace`。 */
|
|
26
31
|
"@typescript-eslint/no-namespace": "off";
|
|
32
|
+
/** `any` 会绕过类型检查,但第三方边界和渐进迁移仍可能需要,因此只警告。 */
|
|
27
33
|
"@typescript-eslint/no-explicit-any": "warn";
|
|
34
|
+
/** TypeScript 源码统一使用 ESM `import`;Node.js 工具文件由末尾覆写单独放开。 */
|
|
28
35
|
"@typescript-eslint/no-require-imports": "error";
|
|
36
|
+
/** 禁止普通空函数,避免遗漏实现;仅允许无函数体逻辑的构造器和有意留空的重写方法。 */
|
|
29
37
|
"@typescript-eslint/no-empty-function": ["error", {
|
|
30
38
|
allow: ("constructors" | "overrideMethods")[];
|
|
31
39
|
}];
|
|
40
|
+
/** 使用 TypeScript 版本识别类型断言等语法;允许常见的短路和三元表达式调用模式。 */
|
|
32
41
|
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
33
42
|
allowShortCircuit: true;
|
|
34
43
|
allowTernary: true;
|
|
35
44
|
}];
|
|
36
|
-
|
|
37
|
-
"@typescript-eslint/no-
|
|
45
|
+
/** 删除局部变量中可直接推断的原始类型;参数和属性允许保留公共契约与文档信息。 */
|
|
46
|
+
"@typescript-eslint/no-inferrable-types": ["error", {
|
|
47
|
+
ignoreParameters: true;
|
|
48
|
+
ignoreProperties: true;
|
|
49
|
+
}];
|
|
50
|
+
/** [默认关闭] 已知运行时不变量可使用标准非空断言;矛盾、重复和无效断言仍由专项规则检查。 */
|
|
51
|
+
"@typescript-eslint/no-non-null-assertion": "off";
|
|
52
|
+
/** 可选链之后再做非空断言逻辑矛盾,通常表示边界条件设计有误。 */
|
|
38
53
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "error";
|
|
54
|
+
/** 纯类型依赖必须使用独立的 `import type`,避免生成无用运行时导入并统一导入声明结构。 */
|
|
39
55
|
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
40
56
|
disallowTypeAnnotations: false;
|
|
41
57
|
fixStyle: "separate-type-imports";
|
|
42
58
|
prefer: "type-imports";
|
|
43
59
|
}];
|
|
60
|
+
/** 禁止 `import { type Foo }` 产生仅用于类型的运行时导入,统一提升为独立的 `import type`。 */
|
|
44
61
|
"@typescript-eslint/no-import-type-side-effects": "error";
|
|
45
62
|
};
|
|
46
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* TypeScript 类型感知规则覆写。
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* 这些规则只在 Project Service 提供完整类型信息后应用。覆写优先保留真实 Bug 与类型安全检查,
|
|
68
|
+
* 同时关闭会改变业务语义、强制单一语法形式或给通用 SDK 代码带来明显噪声的规则。
|
|
69
|
+
*/
|
|
47
70
|
export declare const typescriptTypeCheckedRules: {
|
|
71
|
+
/** [默认关闭] 是否等待、返回或处理 Promise 由开发者根据业务顺序和异常语义决定。 */
|
|
48
72
|
"@typescript-eslint/no-floating-promises": "off";
|
|
73
|
+
/** [默认关闭] 不限制框架生命周期和事件回调的返回写法。 */
|
|
49
74
|
"@typescript-eslint/strict-void-return": "off";
|
|
75
|
+
/** [默认关闭] 核心 `no-void` 已禁止全部 `void` 操作符,关闭类型感知的重复诊断。 */
|
|
50
76
|
"@typescript-eslint/no-meaningless-void-operator": "off";
|
|
77
|
+
/** 保留简洁的 `() => notify()` 回调,其他容易混淆 `void` 值与返回值的用法继续检查。 */
|
|
51
78
|
"@typescript-eslint/no-confusing-void-expression": ["error", {
|
|
52
79
|
ignoreArrowShorthand: true;
|
|
53
80
|
}];
|
|
81
|
+
/** 数字和布尔值是模板字符串的常见安全插值;对象、`any` 和空值仍需显式处理。 */
|
|
54
82
|
"@typescript-eslint/restrict-template-expressions": ["error", {
|
|
83
|
+
allowBoolean: true;
|
|
55
84
|
allowNumber: true;
|
|
56
85
|
}];
|
|
86
|
+
/** [默认关闭] 动态删除对象字段是表单和字典的正常操作;数组 `delete` 仍由专项规则禁止。 */
|
|
57
87
|
"@typescript-eslint/no-dynamic-delete": "off";
|
|
88
|
+
/** [默认关闭] 纯静态工具类可能是 SDK 的有意 API 设计,不强制改写为函数或对象。 */
|
|
58
89
|
"@typescript-eslint/no-extraneous-class": "off";
|
|
90
|
+
/** 弃用 API 需要可见,但兼容多个依赖版本时不应直接阻断构建。 */
|
|
59
91
|
"@typescript-eslint/no-deprecated": "warn";
|
|
60
|
-
|
|
92
|
+
/** [默认关闭] TypeScript 类型不一定覆盖外部输入的真实运行时,允许保留防御性条件。 */
|
|
93
|
+
"@typescript-eslint/no-unnecessary-condition": "off";
|
|
94
|
+
/** [默认关闭] 不强制使用 `interface` 或 `type` 的单一类型定义形式。 */
|
|
61
95
|
"@typescript-eslint/consistent-type-definitions": "off";
|
|
96
|
+
/** [默认关闭] 不强制使用索引签名、`Record` 或映射类型中的某一种固定写法。 */
|
|
62
97
|
"@typescript-eslint/consistent-indexed-object-style": "off";
|
|
98
|
+
/** [默认关闭] 不强制类的只读字面量属性改写为 getter 或字段中的某一种固定形式。 */
|
|
63
99
|
"@typescript-eslint/class-literal-property-style": "off";
|
|
100
|
+
/** [默认关闭] 不强制使用 `RegExp#exec` 取代字符串匹配 API。 */
|
|
64
101
|
"@typescript-eslint/prefer-regexp-exec": "off";
|
|
102
|
+
/** 纯类型导出必须使用 `export type`,避免生成或暗示不存在的运行时导出。 */
|
|
65
103
|
"@typescript-eslint/consistent-type-exports": "error";
|
|
104
|
+
/** 只在构造阶段赋值且之后保持不变的私有成员应声明为 `readonly`。 */
|
|
66
105
|
"@typescript-eslint/prefer-readonly": "error";
|
|
106
|
+
/** 原始类型的 `||` 与 `??` 可能承载不同业务语义,不为了风格强制互换。 */
|
|
67
107
|
"@typescript-eslint/prefer-nullish-coalescing": ["error", {
|
|
68
108
|
ignorePrimitives: true;
|
|
69
109
|
}];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
110
|
+
/** 仅在类型明确包含 `null` 或 `undefined` 时要求使用可选链,避免改变其他假值的业务语义。 */
|
|
111
|
+
"@typescript-eslint/prefer-optional-chain": ["error", {
|
|
112
|
+
requireNullish: true;
|
|
73
113
|
}];
|
|
114
|
+
/** [默认关闭] 公共重载会影响类型查询与调用契约,不为减少声明行数强制合并。 */
|
|
115
|
+
"@typescript-eslint/unified-signatures": "off";
|
|
116
|
+
/** 联合类型和枚举新增成员时,`switch` 必须覆盖全部分支或显式提供 `default`。 */
|
|
74
117
|
"@typescript-eslint/switch-exhaustiveness-check": "error";
|
|
118
|
+
/** 禁止展开静态可知不可迭代或语义不匹配的值。 */
|
|
119
|
+
"@typescript-eslint/no-misused-spread": "error";
|
|
120
|
+
/** 禁止把不同类别的值混入同一枚举,避免比较和序列化语义不稳定。 */
|
|
121
|
+
"@typescript-eslint/no-mixed-enums": "error";
|
|
122
|
+
/** 非空断言与空值合并同时出现时逻辑矛盾。 */
|
|
123
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error";
|
|
124
|
+
/** 删除不会改变条件结果的布尔字面量比较。 */
|
|
125
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error";
|
|
126
|
+
/** 删除模板字符串中没有插值语义的冗余表达式。 */
|
|
127
|
+
"@typescript-eslint/no-unnecessary-template-expression": "error";
|
|
128
|
+
/** 删除可由调用参数直接推断的显式泛型实参。 */
|
|
129
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error";
|
|
130
|
+
/** 禁止不会改变运行时值或静态类型的冗余转换。 */
|
|
131
|
+
"@typescript-eslint/no-unnecessary-type-conversion": "error";
|
|
132
|
+
/** 默认参数已经表达回退值,不再重复传入 `undefined`。 */
|
|
133
|
+
"@typescript-eslint/no-useless-default-assignment": "error";
|
|
134
|
+
/** getter 与 setter 必须使用相互兼容的类型。 */
|
|
135
|
+
"@typescript-eslint/related-getter-setter-pairs": "error";
|
|
136
|
+
/** 只在错误处理语义需要时要求 `return await`,不增加纯风格 `await`。 */
|
|
137
|
+
"@typescript-eslint/return-await": ["error", "error-handling-correctness-only"];
|
|
138
|
+
/** Promise `catch` 回调接收未知拒绝原因,使用 `unknown` 后再显式收窄。 */
|
|
139
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error";
|
|
140
|
+
/** 无 `await` 的 `async` 会改变返回值和异常语义,应删除 `async` 或返回真实 Promise。 */
|
|
141
|
+
"@typescript-eslint/require-await": "error";
|
|
142
|
+
/** 允许透明转发外部 Promise 的未知拒绝原因;静态可知的 `string`、`number` 等仍会被报告。 */
|
|
75
143
|
"@typescript-eslint/prefer-promise-reject-errors": ["error", {
|
|
76
144
|
allowThrowingUnknown: true;
|
|
77
145
|
}];
|
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
* TypeScript 本地覆写规则。
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* `.ts`、`.mts` 与 `.cts` 导出成员视为模块公共 API,参数与返回类型必须显式声明;
|
|
7
|
+
* 内部实现和内联回调保留类型推断。TSX 由配置末尾覆写保留组件返回类型推断。
|
|
8
8
|
*/
|
|
9
9
|
const typescriptRules = {
|
|
10
|
+
/** 单独组合 `createTypeScriptConfigs()` 时也禁止用 `void` 操作符标记被忽略的 Promise。 */
|
|
10
11
|
"no-void": "error",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/** TypeScript 重载与声明合并由扩展规则识别,关闭会把合法重载误判为重复声明的核心规则。 */
|
|
13
|
+
"no-redeclare": "off",
|
|
14
|
+
/** [默认关闭] 内部函数依赖 TypeScript 推断;公共导出边界由模块边界规则单独检查。 */
|
|
15
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
16
|
+
/** 导出函数和类的公共方法必须显式声明参数与返回类型,使公共 API 不依赖实现细节推断;参数不允许显式 `any`。 */
|
|
15
17
|
"@typescript-eslint/explicit-module-boundary-types": ["error", { allowArgumentsExplicitlyTypedAsAny: false }],
|
|
18
|
+
/** 使用 TypeScript 版本避免核心规则误判声明合并、类型和值的同名声明。 */
|
|
16
19
|
"@typescript-eslint/no-redeclare": "error",
|
|
20
|
+
/** 未使用符号视为错误;仅参数和异常可用下划线明确表示有意忽略。 */
|
|
17
21
|
"@typescript-eslint/no-unused-vars": ["error", {
|
|
18
22
|
args: "after-used",
|
|
19
23
|
argsIgnorePattern: "^_",
|
|
@@ -21,47 +25,111 @@ const typescriptRules = {
|
|
|
21
25
|
caughtErrorsIgnorePattern: "^_",
|
|
22
26
|
ignoreRestSiblings: true
|
|
23
27
|
}],
|
|
28
|
+
/** [默认关闭] 声明文件、全局扩展和部分 SDK 仍需要 `namespace`。 */
|
|
24
29
|
"@typescript-eslint/no-namespace": "off",
|
|
30
|
+
/** `any` 会绕过类型检查,但第三方边界和渐进迁移仍可能需要,因此只警告。 */
|
|
25
31
|
"@typescript-eslint/no-explicit-any": "warn",
|
|
32
|
+
/** TypeScript 源码统一使用 ESM `import`;Node.js 工具文件由末尾覆写单独放开。 */
|
|
26
33
|
"@typescript-eslint/no-require-imports": "error",
|
|
34
|
+
/** 禁止普通空函数,避免遗漏实现;仅允许无函数体逻辑的构造器和有意留空的重写方法。 */
|
|
27
35
|
"@typescript-eslint/no-empty-function": ["error", { allow: ["constructors", "overrideMethods"] }],
|
|
36
|
+
/** 使用 TypeScript 版本识别类型断言等语法;允许常见的短路和三元表达式调用模式。 */
|
|
28
37
|
"@typescript-eslint/no-unused-expressions": ["error", {
|
|
29
38
|
allowShortCircuit: true,
|
|
30
39
|
allowTernary: true
|
|
31
40
|
}],
|
|
32
|
-
|
|
33
|
-
"@typescript-eslint/no-
|
|
41
|
+
/** 删除局部变量中可直接推断的原始类型;参数和属性允许保留公共契约与文档信息。 */
|
|
42
|
+
"@typescript-eslint/no-inferrable-types": ["error", {
|
|
43
|
+
ignoreParameters: true,
|
|
44
|
+
ignoreProperties: true
|
|
45
|
+
}],
|
|
46
|
+
/** [默认关闭] 已知运行时不变量可使用标准非空断言;矛盾、重复和无效断言仍由专项规则检查。 */
|
|
47
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
48
|
+
/** 可选链之后再做非空断言逻辑矛盾,通常表示边界条件设计有误。 */
|
|
34
49
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
50
|
+
/** 纯类型依赖必须使用独立的 `import type`,避免生成无用运行时导入并统一导入声明结构。 */
|
|
35
51
|
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
36
52
|
disallowTypeAnnotations: false,
|
|
37
53
|
fixStyle: "separate-type-imports",
|
|
38
54
|
prefer: "type-imports"
|
|
39
55
|
}],
|
|
56
|
+
/** 禁止 `import { type Foo }` 产生仅用于类型的运行时导入,统一提升为独立的 `import type`。 */
|
|
40
57
|
"@typescript-eslint/no-import-type-side-effects": "error"
|
|
41
58
|
};
|
|
42
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* TypeScript 类型感知规则覆写。
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* 这些规则只在 Project Service 提供完整类型信息后应用。覆写优先保留真实 Bug 与类型安全检查,
|
|
64
|
+
* 同时关闭会改变业务语义、强制单一语法形式或给通用 SDK 代码带来明显噪声的规则。
|
|
65
|
+
*/
|
|
43
66
|
const typescriptTypeCheckedRules = {
|
|
67
|
+
/** [默认关闭] 是否等待、返回或处理 Promise 由开发者根据业务顺序和异常语义决定。 */
|
|
44
68
|
"@typescript-eslint/no-floating-promises": "off",
|
|
69
|
+
/** [默认关闭] 不限制框架生命周期和事件回调的返回写法。 */
|
|
45
70
|
"@typescript-eslint/strict-void-return": "off",
|
|
71
|
+
/** [默认关闭] 核心 `no-void` 已禁止全部 `void` 操作符,关闭类型感知的重复诊断。 */
|
|
46
72
|
"@typescript-eslint/no-meaningless-void-operator": "off",
|
|
73
|
+
/** 保留简洁的 `() => notify()` 回调,其他容易混淆 `void` 值与返回值的用法继续检查。 */
|
|
47
74
|
"@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
|
|
48
|
-
|
|
75
|
+
/** 数字和布尔值是模板字符串的常见安全插值;对象、`any` 和空值仍需显式处理。 */
|
|
76
|
+
"@typescript-eslint/restrict-template-expressions": ["error", {
|
|
77
|
+
allowBoolean: true,
|
|
78
|
+
allowNumber: true
|
|
79
|
+
}],
|
|
80
|
+
/** [默认关闭] 动态删除对象字段是表单和字典的正常操作;数组 `delete` 仍由专项规则禁止。 */
|
|
49
81
|
"@typescript-eslint/no-dynamic-delete": "off",
|
|
82
|
+
/** [默认关闭] 纯静态工具类可能是 SDK 的有意 API 设计,不强制改写为函数或对象。 */
|
|
50
83
|
"@typescript-eslint/no-extraneous-class": "off",
|
|
84
|
+
/** 弃用 API 需要可见,但兼容多个依赖版本时不应直接阻断构建。 */
|
|
51
85
|
"@typescript-eslint/no-deprecated": "warn",
|
|
52
|
-
|
|
86
|
+
/** [默认关闭] TypeScript 类型不一定覆盖外部输入的真实运行时,允许保留防御性条件。 */
|
|
87
|
+
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
88
|
+
/** [默认关闭] 不强制使用 `interface` 或 `type` 的单一类型定义形式。 */
|
|
53
89
|
"@typescript-eslint/consistent-type-definitions": "off",
|
|
90
|
+
/** [默认关闭] 不强制使用索引签名、`Record` 或映射类型中的某一种固定写法。 */
|
|
54
91
|
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
92
|
+
/** [默认关闭] 不强制类的只读字面量属性改写为 getter 或字段中的某一种固定形式。 */
|
|
55
93
|
"@typescript-eslint/class-literal-property-style": "off",
|
|
94
|
+
/** [默认关闭] 不强制使用 `RegExp#exec` 取代字符串匹配 API。 */
|
|
56
95
|
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
96
|
+
/** 纯类型导出必须使用 `export type`,避免生成或暗示不存在的运行时导出。 */
|
|
57
97
|
"@typescript-eslint/consistent-type-exports": "error",
|
|
98
|
+
/** 只在构造阶段赋值且之后保持不变的私有成员应声明为 `readonly`。 */
|
|
58
99
|
"@typescript-eslint/prefer-readonly": "error",
|
|
100
|
+
/** 原始类型的 `||` 与 `??` 可能承载不同业务语义,不为了风格强制互换。 */
|
|
59
101
|
"@typescript-eslint/prefer-nullish-coalescing": ["error", { ignorePrimitives: true }],
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
102
|
+
/** 仅在类型明确包含 `null` 或 `undefined` 时要求使用可选链,避免改变其他假值的业务语义。 */
|
|
103
|
+
"@typescript-eslint/prefer-optional-chain": ["error", { requireNullish: true }],
|
|
104
|
+
/** [默认关闭] 公共重载会影响类型查询与调用契约,不为减少声明行数强制合并。 */
|
|
105
|
+
"@typescript-eslint/unified-signatures": "off",
|
|
106
|
+
/** 联合类型和枚举新增成员时,`switch` 必须覆盖全部分支或显式提供 `default`。 */
|
|
64
107
|
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
108
|
+
/** 禁止展开静态可知不可迭代或语义不匹配的值。 */
|
|
109
|
+
"@typescript-eslint/no-misused-spread": "error",
|
|
110
|
+
/** 禁止把不同类别的值混入同一枚举,避免比较和序列化语义不稳定。 */
|
|
111
|
+
"@typescript-eslint/no-mixed-enums": "error",
|
|
112
|
+
/** 非空断言与空值合并同时出现时逻辑矛盾。 */
|
|
113
|
+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
|
|
114
|
+
/** 删除不会改变条件结果的布尔字面量比较。 */
|
|
115
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
116
|
+
/** 删除模板字符串中没有插值语义的冗余表达式。 */
|
|
117
|
+
"@typescript-eslint/no-unnecessary-template-expression": "error",
|
|
118
|
+
/** 删除可由调用参数直接推断的显式泛型实参。 */
|
|
119
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
120
|
+
/** 禁止不会改变运行时值或静态类型的冗余转换。 */
|
|
121
|
+
"@typescript-eslint/no-unnecessary-type-conversion": "error",
|
|
122
|
+
/** 默认参数已经表达回退值,不再重复传入 `undefined`。 */
|
|
123
|
+
"@typescript-eslint/no-useless-default-assignment": "error",
|
|
124
|
+
/** getter 与 setter 必须使用相互兼容的类型。 */
|
|
125
|
+
"@typescript-eslint/related-getter-setter-pairs": "error",
|
|
126
|
+
/** 只在错误处理语义需要时要求 `return await`,不增加纯风格 `await`。 */
|
|
127
|
+
"@typescript-eslint/return-await": ["error", "error-handling-correctness-only"],
|
|
128
|
+
/** Promise `catch` 回调接收未知拒绝原因,使用 `unknown` 后再显式收窄。 */
|
|
129
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": "error",
|
|
130
|
+
/** 无 `await` 的 `async` 会改变返回值和异常语义,应删除 `async` 或返回真实 Promise。 */
|
|
131
|
+
"@typescript-eslint/require-await": "error",
|
|
132
|
+
/** 允许透明转发外部 Promise 的未知拒绝原因;静态可知的 `string`、`number` 等仍会被报告。 */
|
|
65
133
|
"@typescript-eslint/prefer-promise-reject-errors": ["error", { allowThrowingUnknown: true }]
|
|
66
134
|
};
|
|
67
135
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.mjs","names":[],"sources":["../../src/rules/typescript.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * TypeScript 本地覆写规则。\n *\n * @remarks\n *
|
|
1
|
+
{"version":3,"file":"typescript.mjs","names":[],"sources":["../../src/rules/typescript.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * TypeScript 本地覆写规则。\n *\n * @remarks\n * `.ts`、`.mts` 与 `.cts` 导出成员视为模块公共 API,参数与返回类型必须显式声明;\n * 内部实现和内联回调保留类型推断。TSX 由配置末尾覆写保留组件返回类型推断。\n */\nexport const typescriptRules = {\n\t/** 单独组合 `createTypeScriptConfigs()` 时也禁止用 `void` 操作符标记被忽略的 Promise。 */\n\t\"no-void\": \"error\",\n\t/** TypeScript 重载与声明合并由扩展规则识别,关闭会把合法重载误判为重复声明的核心规则。 */\n\t\"no-redeclare\": \"off\",\n\t/** [默认关闭] 内部函数依赖 TypeScript 推断;公共导出边界由模块边界规则单独检查。 */\n\t\"@typescript-eslint/explicit-function-return-type\": \"off\",\n\t/** 导出函数和类的公共方法必须显式声明参数与返回类型,使公共 API 不依赖实现细节推断;参数不允许显式 `any`。 */\n\t\"@typescript-eslint/explicit-module-boundary-types\": [\"error\", { allowArgumentsExplicitlyTypedAsAny: false }],\n\t/** 使用 TypeScript 版本避免核心规则误判声明合并、类型和值的同名声明。 */\n\t\"@typescript-eslint/no-redeclare\": \"error\",\n\t/** 未使用符号视为错误;仅参数和异常可用下划线明确表示有意忽略。 */\n\t\"@typescript-eslint/no-unused-vars\": [\n\t\t\"error\",\n\t\t{\n\t\t\targs: \"after-used\",\n\t\t\targsIgnorePattern: \"^_\",\n\t\t\tcaughtErrors: \"all\",\n\t\t\tcaughtErrorsIgnorePattern: \"^_\",\n\t\t\tignoreRestSiblings: true,\n\t\t},\n\t],\n\t/** [默认关闭] 声明文件、全局扩展和部分 SDK 仍需要 `namespace`。 */\n\t\"@typescript-eslint/no-namespace\": \"off\",\n\t/** `any` 会绕过类型检查,但第三方边界和渐进迁移仍可能需要,因此只警告。 */\n\t\"@typescript-eslint/no-explicit-any\": \"warn\",\n\t/** TypeScript 源码统一使用 ESM `import`;Node.js 工具文件由末尾覆写单独放开。 */\n\t\"@typescript-eslint/no-require-imports\": \"error\",\n\t/** 禁止普通空函数,避免遗漏实现;仅允许无函数体逻辑的构造器和有意留空的重写方法。 */\n\t\"@typescript-eslint/no-empty-function\": [\"error\", { allow: [\"constructors\", \"overrideMethods\"] }],\n\t/** 使用 TypeScript 版本识别类型断言等语法;允许常见的短路和三元表达式调用模式。 */\n\t\"@typescript-eslint/no-unused-expressions\": [\n\t\t\"error\",\n\t\t{\n\t\t\tallowShortCircuit: true,\n\t\t\tallowTernary: true,\n\t\t},\n\t],\n\t/** 删除局部变量中可直接推断的原始类型;参数和属性允许保留公共契约与文档信息。 */\n\t\"@typescript-eslint/no-inferrable-types\": [\"error\", { ignoreParameters: true, ignoreProperties: true }],\n\t/** [默认关闭] 已知运行时不变量可使用标准非空断言;矛盾、重复和无效断言仍由专项规则检查。 */\n\t\"@typescript-eslint/no-non-null-assertion\": \"off\",\n\t/** 可选链之后再做非空断言逻辑矛盾,通常表示边界条件设计有误。 */\n\t\"@typescript-eslint/no-non-null-asserted-optional-chain\": \"error\",\n\t/** 纯类型依赖必须使用独立的 `import type`,避免生成无用运行时导入并统一导入声明结构。 */\n\t\"@typescript-eslint/consistent-type-imports\": [\n\t\t\"error\",\n\t\t{\n\t\t\tdisallowTypeAnnotations: false,\n\t\t\tfixStyle: \"separate-type-imports\",\n\t\t\tprefer: \"type-imports\",\n\t\t},\n\t],\n\t/** 禁止 `import { type Foo }` 产生仅用于类型的运行时导入,统一提升为独立的 `import type`。 */\n\t\"@typescript-eslint/no-import-type-side-effects\": \"error\",\n} satisfies RuleOptions;\n\n/**\n * TypeScript 类型感知规则覆写。\n *\n * @remarks\n * 这些规则只在 Project Service 提供完整类型信息后应用。覆写优先保留真实 Bug 与类型安全检查,\n * 同时关闭会改变业务语义、强制单一语法形式或给通用 SDK 代码带来明显噪声的规则。\n */\nexport const typescriptTypeCheckedRules = {\n\t/** [默认关闭] 是否等待、返回或处理 Promise 由开发者根据业务顺序和异常语义决定。 */\n\t\"@typescript-eslint/no-floating-promises\": \"off\",\n\t/** [默认关闭] 不限制框架生命周期和事件回调的返回写法。 */\n\t\"@typescript-eslint/strict-void-return\": \"off\",\n\t/** [默认关闭] 核心 `no-void` 已禁止全部 `void` 操作符,关闭类型感知的重复诊断。 */\n\t\"@typescript-eslint/no-meaningless-void-operator\": \"off\",\n\t/** 保留简洁的 `() => notify()` 回调,其他容易混淆 `void` 值与返回值的用法继续检查。 */\n\t\"@typescript-eslint/no-confusing-void-expression\": [\"error\", { ignoreArrowShorthand: true }],\n\t/** 数字和布尔值是模板字符串的常见安全插值;对象、`any` 和空值仍需显式处理。 */\n\t\"@typescript-eslint/restrict-template-expressions\": [\"error\", { allowBoolean: true, allowNumber: true }],\n\t/** [默认关闭] 动态删除对象字段是表单和字典的正常操作;数组 `delete` 仍由专项规则禁止。 */\n\t\"@typescript-eslint/no-dynamic-delete\": \"off\",\n\t/** [默认关闭] 纯静态工具类可能是 SDK 的有意 API 设计,不强制改写为函数或对象。 */\n\t\"@typescript-eslint/no-extraneous-class\": \"off\",\n\t/** 弃用 API 需要可见,但兼容多个依赖版本时不应直接阻断构建。 */\n\t\"@typescript-eslint/no-deprecated\": \"warn\",\n\t/** [默认关闭] TypeScript 类型不一定覆盖外部输入的真实运行时,允许保留防御性条件。 */\n\t\"@typescript-eslint/no-unnecessary-condition\": \"off\",\n\t/** [默认关闭] 不强制使用 `interface` 或 `type` 的单一类型定义形式。 */\n\t\"@typescript-eslint/consistent-type-definitions\": \"off\",\n\t/** [默认关闭] 不强制使用索引签名、`Record` 或映射类型中的某一种固定写法。 */\n\t\"@typescript-eslint/consistent-indexed-object-style\": \"off\",\n\t/** [默认关闭] 不强制类的只读字面量属性改写为 getter 或字段中的某一种固定形式。 */\n\t\"@typescript-eslint/class-literal-property-style\": \"off\",\n\t/** [默认关闭] 不强制使用 `RegExp#exec` 取代字符串匹配 API。 */\n\t\"@typescript-eslint/prefer-regexp-exec\": \"off\",\n\t/** 纯类型导出必须使用 `export type`,避免生成或暗示不存在的运行时导出。 */\n\t\"@typescript-eslint/consistent-type-exports\": \"error\",\n\t/** 只在构造阶段赋值且之后保持不变的私有成员应声明为 `readonly`。 */\n\t\"@typescript-eslint/prefer-readonly\": \"error\",\n\t/** 原始类型的 `||` 与 `??` 可能承载不同业务语义,不为了风格强制互换。 */\n\t\"@typescript-eslint/prefer-nullish-coalescing\": [\"error\", { ignorePrimitives: true }],\n\t/** 仅在类型明确包含 `null` 或 `undefined` 时要求使用可选链,避免改变其他假值的业务语义。 */\n\t\"@typescript-eslint/prefer-optional-chain\": [\"error\", { requireNullish: true }],\n\t/** [默认关闭] 公共重载会影响类型查询与调用契约,不为减少声明行数强制合并。 */\n\t\"@typescript-eslint/unified-signatures\": \"off\",\n\t/** 联合类型和枚举新增成员时,`switch` 必须覆盖全部分支或显式提供 `default`。 */\n\t\"@typescript-eslint/switch-exhaustiveness-check\": \"error\",\n\t/** 禁止展开静态可知不可迭代或语义不匹配的值。 */\n\t\"@typescript-eslint/no-misused-spread\": \"error\",\n\t/** 禁止把不同类别的值混入同一枚举,避免比较和序列化语义不稳定。 */\n\t\"@typescript-eslint/no-mixed-enums\": \"error\",\n\t/** 非空断言与空值合并同时出现时逻辑矛盾。 */\n\t\"@typescript-eslint/no-non-null-asserted-nullish-coalescing\": \"error\",\n\t/** 删除不会改变条件结果的布尔字面量比较。 */\n\t\"@typescript-eslint/no-unnecessary-boolean-literal-compare\": \"error\",\n\t/** 删除模板字符串中没有插值语义的冗余表达式。 */\n\t\"@typescript-eslint/no-unnecessary-template-expression\": \"error\",\n\t/** 删除可由调用参数直接推断的显式泛型实参。 */\n\t\"@typescript-eslint/no-unnecessary-type-arguments\": \"error\",\n\t/** 禁止不会改变运行时值或静态类型的冗余转换。 */\n\t\"@typescript-eslint/no-unnecessary-type-conversion\": \"error\",\n\t/** 默认参数已经表达回退值,不再重复传入 `undefined`。 */\n\t\"@typescript-eslint/no-useless-default-assignment\": \"error\",\n\t/** getter 与 setter 必须使用相互兼容的类型。 */\n\t\"@typescript-eslint/related-getter-setter-pairs\": \"error\",\n\t/** 只在错误处理语义需要时要求 `return await`,不增加纯风格 `await`。 */\n\t\"@typescript-eslint/return-await\": [\"error\", \"error-handling-correctness-only\"],\n\t/** Promise `catch` 回调接收未知拒绝原因,使用 `unknown` 后再显式收窄。 */\n\t\"@typescript-eslint/use-unknown-in-catch-callback-variable\": \"error\",\n\t/** 无 `await` 的 `async` 会改变返回值和异常语义,应删除 `async` 或返回真实 Promise。 */\n\t\"@typescript-eslint/require-await\": \"error\",\n\t/** 允许透明转发外部 Promise 的未知拒绝原因;静态可知的 `string`、`number` 等仍会被报告。 */\n\t\"@typescript-eslint/prefer-promise-reject-errors\": [\"error\", { allowThrowingUnknown: true }],\n} satisfies RuleOptions;\n"],"mappings":";;;;;;;;AASA,MAAa,kBAAkB;;CAE9B,WAAW;;CAEX,gBAAgB;;CAEhB,oDAAoD;;CAEpD,qDAAqD,CAAC,SAAS,EAAE,oCAAoC,MAAM,CAAC;;CAE5G,mCAAmC;;CAEnC,qCAAqC,CACpC,SACA;EACC,MAAM;EACN,mBAAmB;EACnB,cAAc;EACd,2BAA2B;EAC3B,oBAAoB;CACrB,CACD;;CAEA,mCAAmC;;CAEnC,sCAAsC;;CAEtC,yCAAyC;;CAEzC,wCAAwC,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,iBAAiB,EAAE,CAAC;;CAEhG,4CAA4C,CAC3C,SACA;EACC,mBAAmB;EACnB,cAAc;CACf,CACD;;CAEA,0CAA0C,CAAC,SAAS;EAAE,kBAAkB;EAAM,kBAAkB;CAAK,CAAC;;CAEtG,4CAA4C;;CAE5C,0DAA0D;;CAE1D,8CAA8C,CAC7C,SACA;EACC,yBAAyB;EACzB,UAAU;EACV,QAAQ;CACT,CACD;;CAEA,kDAAkD;AACnD;;;;;;;;AASA,MAAa,6BAA6B;;CAEzC,2CAA2C;;CAE3C,yCAAyC;;CAEzC,mDAAmD;;CAEnD,mDAAmD,CAAC,SAAS,EAAE,sBAAsB,KAAK,CAAC;;CAE3F,oDAAoD,CAAC,SAAS;EAAE,cAAc;EAAM,aAAa;CAAK,CAAC;;CAEvG,wCAAwC;;CAExC,0CAA0C;;CAE1C,oCAAoC;;CAEpC,+CAA+C;;CAE/C,kDAAkD;;CAElD,sDAAsD;;CAEtD,mDAAmD;;CAEnD,yCAAyC;;CAEzC,8CAA8C;;CAE9C,sCAAsC;;CAEtC,gDAAgD,CAAC,SAAS,EAAE,kBAAkB,KAAK,CAAC;;CAEpF,4CAA4C,CAAC,SAAS,EAAE,gBAAgB,KAAK,CAAC;;CAE9E,yCAAyC;;CAEzC,kDAAkD;;CAElD,wCAAwC;;CAExC,qCAAqC;;CAErC,8DAA8D;;CAE9D,6DAA6D;;CAE7D,yDAAyD;;CAEzD,oDAAoD;;CAEpD,qDAAqD;;CAErD,oDAAoD;;CAEpD,kDAAkD;;CAElD,mCAAmC,CAAC,SAAS,iCAAiC;;CAE9E,6DAA6D;;CAE7D,oCAAoC;;CAEpC,mDAAmD,CAAC,SAAS,EAAE,sBAAsB,KAAK,CAAC;AAC5F"}
|
package/dist/rules/vue.d.mts
CHANGED
|
@@ -1,33 +1,88 @@
|
|
|
1
1
|
//#region src/rules/vue.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Vue
|
|
3
|
+
* Vue 组件脚本语义规则。
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* 这些规则可以检查 SFC 脚本以及使用 `defineComponent()`、Options API 或 `setup()` 的
|
|
7
|
+
* 独立 JSX/TSX 组件。纯模板语法规则由 {@link vueTemplateRules} 单独维护。
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
9
|
+
export declare const vueScriptRules: {
|
|
10
|
+
/** [默认关闭] TypeScript 类型 props 和 `required` 声明已能表达可选性,不强制每个可选 prop 提供默认值。 */
|
|
11
11
|
"vue/require-default-prop": "off";
|
|
12
|
+
/** 组件事件必须显式声明,形成可检查的对外事件契约。 */
|
|
12
13
|
"vue/require-explicit-emits": "error";
|
|
14
|
+
/** [默认关闭] 允许 `App`、`Layout` 等约定俗成的单词组件名。 */
|
|
13
15
|
"vue/multi-word-component-names": "off";
|
|
16
|
+
/** [默认关闭] 允许直接使用 Vue 子包入口,兼容编译器与运行时等明确子模块导入。 */
|
|
14
17
|
"vue/prefer-import-from-vue": "off";
|
|
15
|
-
|
|
18
|
+
/** `props`、`data`、`computed`、`methods` 等选项中禁止同名键,避免成员互相遮蔽。 */
|
|
16
19
|
"vue/no-dupe-keys": "error";
|
|
20
|
+
/** Props 属于父组件只读输入,子组件应通过 emit 或本地状态更新。 */
|
|
17
21
|
"vue/no-mutating-props": "error";
|
|
22
|
+
/** `setup` 中直接解构 props 会丢失响应性,要求保留 props 引用或使用 `toRefs` 等响应式转换。 */
|
|
18
23
|
"vue/no-setup-props-reactivity-loss": "error";
|
|
24
|
+
/** 禁止以会丢失响应性的方式解构或传递 ref 对象,确保后续更新仍能被 Vue 追踪。 */
|
|
19
25
|
"vue/no-ref-object-reactivity-loss": "error";
|
|
26
|
+
/** 组件名不能占用 Vue 内置组件或平台保留名称。 */
|
|
20
27
|
"vue/no-reserved-component-names": "error";
|
|
21
|
-
|
|
28
|
+
/** `emit`、`emits` 和事件处理引用中的自定义事件名称统一使用 camelCase,原生 DOM 事件不受影响。 */
|
|
22
29
|
"vue/custom-event-name-casing": ["error", "camelCase"];
|
|
30
|
+
/** [默认关闭] 允许在一个 SFC 中声明仅供当前文件使用的小型辅助组件。 */
|
|
23
31
|
"vue/one-component-per-file": "off";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Vue 模板语法规则。
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* 这些规则依赖 `vue-eslint-parser` 生成的模板节点,只应用于 `.vue` 与 `.nvue`。
|
|
38
|
+
* JSX 属性遵循 JavaScript 标识符和运行时约定,不能套用模板的 kebab-case 与属性排序。
|
|
39
|
+
*/
|
|
40
|
+
export declare const vueTemplateRules: {
|
|
41
|
+
/** `v-html` 可能引入 XSS;保留警告以兼容经过净化的富文本场景。 */
|
|
42
|
+
"vue/no-v-html": "warn";
|
|
43
|
+
/** 自定义组件的模板属性统一使用 kebab-case;脚本中的 Props 与 JSX 属性仍使用 camelCase。 */
|
|
44
|
+
"vue/attribute-hyphenation": ["error", "always"];
|
|
45
|
+
/** 禁止在组件节点使用 `v-text` 或 `v-html`,避免覆盖组件内容并模糊数据边界。 */
|
|
46
|
+
"vue/no-v-text-v-html-on-component": "error";
|
|
47
|
+
/** 模板属性按定义、循环、条件、修饰、唯一属性、全局属性、普通属性、事件和内容排序。 */
|
|
48
|
+
"vue/attributes-order": ["error", {
|
|
49
|
+
order: ("DEFINITION" | "LIST_RENDERING" | "CONDITIONALS" | "RENDER_MODIFIERS" | "GLOBAL" | "UNIQUE" | "OTHER_ATTR" | "EVENTS" | "CONTENT")[];
|
|
27
50
|
}];
|
|
51
|
+
};
|
|
52
|
+
/** Vue SFC 同时使用组件脚本语义规则与模板语法规则。 */
|
|
53
|
+
export declare const vueRules: {
|
|
54
|
+
/** `v-html` 可能引入 XSS;保留警告以兼容经过净化的富文本场景。 */
|
|
55
|
+
"vue/no-v-html": "warn";
|
|
56
|
+
/** 自定义组件的模板属性统一使用 kebab-case;脚本中的 Props 与 JSX 属性仍使用 camelCase。 */
|
|
57
|
+
"vue/attribute-hyphenation": ["error", "always"];
|
|
58
|
+
/** 禁止在组件节点使用 `v-text` 或 `v-html`,避免覆盖组件内容并模糊数据边界。 */
|
|
59
|
+
"vue/no-v-text-v-html-on-component": "error";
|
|
60
|
+
/** 模板属性按定义、循环、条件、修饰、唯一属性、全局属性、普通属性、事件和内容排序。 */
|
|
28
61
|
"vue/attributes-order": ["error", {
|
|
29
62
|
order: ("DEFINITION" | "LIST_RENDERING" | "CONDITIONALS" | "RENDER_MODIFIERS" | "GLOBAL" | "UNIQUE" | "OTHER_ATTR" | "EVENTS" | "CONTENT")[];
|
|
30
63
|
}];
|
|
64
|
+
/** [默认关闭] TypeScript 类型 props 和 `required` 声明已能表达可选性,不强制每个可选 prop 提供默认值。 */
|
|
65
|
+
"vue/require-default-prop": "off";
|
|
66
|
+
/** 组件事件必须显式声明,形成可检查的对外事件契约。 */
|
|
67
|
+
"vue/require-explicit-emits": "error";
|
|
68
|
+
/** [默认关闭] 允许 `App`、`Layout` 等约定俗成的单词组件名。 */
|
|
69
|
+
"vue/multi-word-component-names": "off";
|
|
70
|
+
/** [默认关闭] 允许直接使用 Vue 子包入口,兼容编译器与运行时等明确子模块导入。 */
|
|
71
|
+
"vue/prefer-import-from-vue": "off";
|
|
72
|
+
/** `props`、`data`、`computed`、`methods` 等选项中禁止同名键,避免成员互相遮蔽。 */
|
|
73
|
+
"vue/no-dupe-keys": "error";
|
|
74
|
+
/** Props 属于父组件只读输入,子组件应通过 emit 或本地状态更新。 */
|
|
75
|
+
"vue/no-mutating-props": "error";
|
|
76
|
+
/** `setup` 中直接解构 props 会丢失响应性,要求保留 props 引用或使用 `toRefs` 等响应式转换。 */
|
|
77
|
+
"vue/no-setup-props-reactivity-loss": "error";
|
|
78
|
+
/** 禁止以会丢失响应性的方式解构或传递 ref 对象,确保后续更新仍能被 Vue 追踪。 */
|
|
79
|
+
"vue/no-ref-object-reactivity-loss": "error";
|
|
80
|
+
/** 组件名不能占用 Vue 内置组件或平台保留名称。 */
|
|
81
|
+
"vue/no-reserved-component-names": "error";
|
|
82
|
+
/** `emit`、`emits` 和事件处理引用中的自定义事件名称统一使用 camelCase,原生 DOM 事件不受影响。 */
|
|
83
|
+
"vue/custom-event-name-casing": ["error", "camelCase"];
|
|
84
|
+
/** [默认关闭] 允许在一个 SFC 中声明仅供当前文件使用的小型辅助组件。 */
|
|
85
|
+
"vue/one-component-per-file": "off";
|
|
31
86
|
};
|
|
32
87
|
//#endregion
|
|
33
88
|
//# sourceMappingURL=vue.d.mts.map
|
package/dist/rules/vue.mjs
CHANGED
|
@@ -1,43 +1,70 @@
|
|
|
1
1
|
//#region src/rules/vue.ts
|
|
2
2
|
/**
|
|
3
|
-
* Vue
|
|
3
|
+
* Vue 组件脚本语义规则。
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* 这些规则可以检查 SFC 脚本以及使用 `defineComponent()`、Options API 或 `setup()` 的
|
|
7
|
+
* 独立 JSX/TSX 组件。纯模板语法规则由 {@link vueTemplateRules} 单独维护。
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const vueScriptRules = {
|
|
10
|
+
/** [默认关闭] TypeScript 类型 props 和 `required` 声明已能表达可选性,不强制每个可选 prop 提供默认值。 */
|
|
11
11
|
"vue/require-default-prop": "off",
|
|
12
|
+
/** 组件事件必须显式声明,形成可检查的对外事件契约。 */
|
|
12
13
|
"vue/require-explicit-emits": "error",
|
|
14
|
+
/** [默认关闭] 允许 `App`、`Layout` 等约定俗成的单词组件名。 */
|
|
13
15
|
"vue/multi-word-component-names": "off",
|
|
16
|
+
/** [默认关闭] 允许直接使用 Vue 子包入口,兼容编译器与运行时等明确子模块导入。 */
|
|
14
17
|
"vue/prefer-import-from-vue": "off",
|
|
15
|
-
|
|
18
|
+
/** `props`、`data`、`computed`、`methods` 等选项中禁止同名键,避免成员互相遮蔽。 */
|
|
16
19
|
"vue/no-dupe-keys": "error",
|
|
20
|
+
/** Props 属于父组件只读输入,子组件应通过 emit 或本地状态更新。 */
|
|
17
21
|
"vue/no-mutating-props": "error",
|
|
22
|
+
/** `setup` 中直接解构 props 会丢失响应性,要求保留 props 引用或使用 `toRefs` 等响应式转换。 */
|
|
18
23
|
"vue/no-setup-props-reactivity-loss": "error",
|
|
24
|
+
/** 禁止以会丢失响应性的方式解构或传递 ref 对象,确保后续更新仍能被 Vue 追踪。 */
|
|
19
25
|
"vue/no-ref-object-reactivity-loss": "error",
|
|
26
|
+
/** 组件名不能占用 Vue 内置组件或平台保留名称。 */
|
|
20
27
|
"vue/no-reserved-component-names": "error",
|
|
21
|
-
|
|
28
|
+
/** `emit`、`emits` 和事件处理引用中的自定义事件名称统一使用 camelCase,原生 DOM 事件不受影响。 */
|
|
22
29
|
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
23
|
-
|
|
24
|
-
"vue/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
/** [默认关闭] 允许在一个 SFC 中声明仅供当前文件使用的小型辅助组件。 */
|
|
31
|
+
"vue/one-component-per-file": "off"
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Vue 模板语法规则。
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* 这些规则依赖 `vue-eslint-parser` 生成的模板节点,只应用于 `.vue` 与 `.nvue`。
|
|
38
|
+
* JSX 属性遵循 JavaScript 标识符和运行时约定,不能套用模板的 kebab-case 与属性排序。
|
|
39
|
+
*/
|
|
40
|
+
const vueTemplateRules = {
|
|
41
|
+
/** `v-html` 可能引入 XSS;保留警告以兼容经过净化的富文本场景。 */
|
|
42
|
+
"vue/no-v-html": "warn",
|
|
43
|
+
/** 自定义组件的模板属性统一使用 kebab-case;脚本中的 Props 与 JSX 属性仍使用 camelCase。 */
|
|
44
|
+
"vue/attribute-hyphenation": ["error", "always"],
|
|
45
|
+
/** 禁止在组件节点使用 `v-text` 或 `v-html`,避免覆盖组件内容并模糊数据边界。 */
|
|
46
|
+
"vue/no-v-text-v-html-on-component": "error",
|
|
47
|
+
/** 模板属性按定义、循环、条件、修饰、唯一属性、全局属性、普通属性、事件和内容排序。 */
|
|
28
48
|
"vue/attributes-order": ["error", { order: [
|
|
29
49
|
"DEFINITION",
|
|
30
50
|
"LIST_RENDERING",
|
|
31
51
|
"CONDITIONALS",
|
|
32
52
|
"RENDER_MODIFIERS",
|
|
33
|
-
"GLOBAL",
|
|
34
53
|
"UNIQUE",
|
|
54
|
+
"GLOBAL",
|
|
35
55
|
"OTHER_ATTR",
|
|
36
56
|
"EVENTS",
|
|
37
57
|
"CONTENT"
|
|
38
58
|
] }]
|
|
39
59
|
};
|
|
60
|
+
/** Vue SFC 同时使用组件脚本语义规则与模板语法规则。 */
|
|
61
|
+
const vueRules = {
|
|
62
|
+
/** 复用可在 SFC 与独立 JSX/TSX 中检查的 Vue 组件脚本语义规则。 */
|
|
63
|
+
...vueScriptRules,
|
|
64
|
+
/** 叠加仅对 Vue 模板节点有效的语法规则。 */
|
|
65
|
+
...vueTemplateRules
|
|
66
|
+
};
|
|
40
67
|
//#endregion
|
|
41
|
-
export { vueRules };
|
|
68
|
+
export { vueRules, vueScriptRules, vueTemplateRules };
|
|
42
69
|
|
|
43
70
|
//# sourceMappingURL=vue.mjs.map
|
package/dist/rules/vue.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.mjs","names":[],"sources":["../../src/rules/vue.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * Vue
|
|
1
|
+
{"version":3,"file":"vue.mjs","names":[],"sources":["../../src/rules/vue.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * Vue 组件脚本语义规则。\n *\n * @remarks\n * 这些规则可以检查 SFC 脚本以及使用 `defineComponent()`、Options API 或 `setup()` 的\n * 独立 JSX/TSX 组件。纯模板语法规则由 {@link vueTemplateRules} 单独维护。\n */\nexport const vueScriptRules = {\n\t/** [默认关闭] TypeScript 类型 props 和 `required` 声明已能表达可选性,不强制每个可选 prop 提供默认值。 */\n\t\"vue/require-default-prop\": \"off\",\n\t/** 组件事件必须显式声明,形成可检查的对外事件契约。 */\n\t\"vue/require-explicit-emits\": \"error\",\n\t/** [默认关闭] 允许 `App`、`Layout` 等约定俗成的单词组件名。 */\n\t\"vue/multi-word-component-names\": \"off\",\n\t/** [默认关闭] 允许直接使用 Vue 子包入口,兼容编译器与运行时等明确子模块导入。 */\n\t\"vue/prefer-import-from-vue\": \"off\",\n\t/** `props`、`data`、`computed`、`methods` 等选项中禁止同名键,避免成员互相遮蔽。 */\n\t\"vue/no-dupe-keys\": \"error\",\n\t/** Props 属于父组件只读输入,子组件应通过 emit 或本地状态更新。 */\n\t\"vue/no-mutating-props\": \"error\",\n\t/** `setup` 中直接解构 props 会丢失响应性,要求保留 props 引用或使用 `toRefs` 等响应式转换。 */\n\t\"vue/no-setup-props-reactivity-loss\": \"error\",\n\t/** 禁止以会丢失响应性的方式解构或传递 ref 对象,确保后续更新仍能被 Vue 追踪。 */\n\t\"vue/no-ref-object-reactivity-loss\": \"error\",\n\t/** 组件名不能占用 Vue 内置组件或平台保留名称。 */\n\t\"vue/no-reserved-component-names\": \"error\",\n\t/** `emit`、`emits` 和事件处理引用中的自定义事件名称统一使用 camelCase,原生 DOM 事件不受影响。 */\n\t\"vue/custom-event-name-casing\": [\"error\", \"camelCase\"],\n\t/** [默认关闭] 允许在一个 SFC 中声明仅供当前文件使用的小型辅助组件。 */\n\t\"vue/one-component-per-file\": \"off\",\n} satisfies RuleOptions;\n\n/**\n * Vue 模板语法规则。\n *\n * @remarks\n * 这些规则依赖 `vue-eslint-parser` 生成的模板节点,只应用于 `.vue` 与 `.nvue`。\n * JSX 属性遵循 JavaScript 标识符和运行时约定,不能套用模板的 kebab-case 与属性排序。\n */\nexport const vueTemplateRules = {\n\t/** `v-html` 可能引入 XSS;保留警告以兼容经过净化的富文本场景。 */\n\t\"vue/no-v-html\": \"warn\",\n\t/** 自定义组件的模板属性统一使用 kebab-case;脚本中的 Props 与 JSX 属性仍使用 camelCase。 */\n\t\"vue/attribute-hyphenation\": [\"error\", \"always\"],\n\t/** 禁止在组件节点使用 `v-text` 或 `v-html`,避免覆盖组件内容并模糊数据边界。 */\n\t\"vue/no-v-text-v-html-on-component\": \"error\",\n\t/** 模板属性按定义、循环、条件、修饰、唯一属性、全局属性、普通属性、事件和内容排序。 */\n\t\"vue/attributes-order\": [\n\t\t\"error\",\n\t\t{\n\t\t\torder: [\"DEFINITION\", \"LIST_RENDERING\", \"CONDITIONALS\", \"RENDER_MODIFIERS\", \"UNIQUE\", \"GLOBAL\", \"OTHER_ATTR\", \"EVENTS\", \"CONTENT\"],\n\t\t},\n\t],\n} satisfies RuleOptions;\n\n/** Vue SFC 同时使用组件脚本语义规则与模板语法规则。 */\nexport const vueRules = {\n\t/** 复用可在 SFC 与独立 JSX/TSX 中检查的 Vue 组件脚本语义规则。 */\n\t...vueScriptRules,\n\t/** 叠加仅对 Vue 模板节点有效的语法规则。 */\n\t...vueTemplateRules,\n} satisfies RuleOptions;\n"],"mappings":";;;;;;;;AASA,MAAa,iBAAiB;;CAE7B,4BAA4B;;CAE5B,8BAA8B;;CAE9B,kCAAkC;;CAElC,8BAA8B;;CAE9B,oBAAoB;;CAEpB,yBAAyB;;CAEzB,sCAAsC;;CAEtC,qCAAqC;;CAErC,mCAAmC;;CAEnC,gCAAgC,CAAC,SAAS,WAAW;;CAErD,8BAA8B;AAC/B;;;;;;;;AASA,MAAa,mBAAmB;;CAE/B,iBAAiB;;CAEjB,6BAA6B,CAAC,SAAS,QAAQ;;CAE/C,qCAAqC;;CAErC,wBAAwB,CACvB,SACA,EACC,OAAO;EAAC;EAAc;EAAkB;EAAgB;EAAoB;EAAU;EAAU;EAAc;EAAU;CAAS,EAClI,CACD;AACD;;AAGA,MAAa,WAAW;;CAEvB,GAAG;;CAEH,GAAG;AACJ"}
|