@fast-china/eslint-config 2.1.7 → 2.1.8
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 +25 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +66 -142
- package/README.zh.md +64 -142
- 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 +59 -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 +2051 -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
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GLOBS_CODE, GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT, GLOB_NVUE } from "./constants/index.mjs";
|
|
1
|
+
import { GLOBS_CODE, GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT, GLOB_NVUE, GLOB_VUE } from "./constants/index.mjs";
|
|
2
2
|
import { createCommonConfigs } from "./configs/common.mjs";
|
|
3
3
|
import { createEnvironmentConfigs, createNodeToolingConfigs } from "./configs/environment.mjs";
|
|
4
4
|
import { createGitignoreConfigs, createGlobalIgnores } from "./configs/ignores.mjs";
|
|
@@ -11,30 +11,38 @@ import { createPackageJsonSortConfigs } from "./configs/sort-package.mjs";
|
|
|
11
11
|
import { createTsconfigSortConfigs } from "./configs/sort-tsconfig.mjs";
|
|
12
12
|
import { createTypeScriptConfigs } from "./configs/typescript.mjs";
|
|
13
13
|
import { createUniAppConfigs } from "./configs/uniapp.mjs";
|
|
14
|
-
import { createVueConfigs } from "./configs/vue.mjs";
|
|
14
|
+
import { createVueConfigs, createVueJsxConfigs } from "./configs/vue.mjs";
|
|
15
15
|
import { defineConfig } from "eslint/config";
|
|
16
16
|
//#region src/index.ts
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* 根入口提供彼此独立的 Vue 3 与 UniApp 完整 ESLint 配置。
|
|
19
19
|
*
|
|
20
20
|
* 配置片段、glob 常量与原始规则分别由 `./configs`、`./constants` 与 `./rules` 子路径提供。
|
|
21
21
|
*
|
|
22
22
|
* @packageDocumentation
|
|
23
23
|
*/
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* 定义带有完整规则名与选项类型检查的 ESLint 规则记录。
|
|
26
26
|
*
|
|
27
27
|
* @remarks
|
|
28
|
-
*
|
|
28
|
+
* 该辅助函数只提供 TypeScript 类型约束,不会克隆、规范化或修改传入对象。规则记录可以
|
|
29
|
+
* 直接放入 Flat Config 的 `rules` 字段,也可以与本包导出的规则记录组合。
|
|
29
30
|
*
|
|
30
|
-
* @typeParam Rules -
|
|
31
|
-
* @param rules -
|
|
32
|
-
* @returns
|
|
31
|
+
* @typeParam Rules - 基于生成规则 schema 推断出的具体规则记录类型。
|
|
32
|
+
* @param rules - 需要验证的 ESLint 规则记录;未知规则名和无效规则选项会产生类型错误。
|
|
33
|
+
* @returns 原样返回传入的规则记录,并补充 ESLint `RulesRecord` 兼容类型。
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const rules = defineRules({
|
|
38
|
+
* eqeqeq: ["error", "always"],
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
33
41
|
*/
|
|
34
42
|
const defineRules = (rules) => rules;
|
|
35
43
|
const SCRIPT_FILES = [...GLOBS_JAVASCRIPT, ...GLOBS_TYPESCRIPT];
|
|
36
|
-
const
|
|
37
|
-
const createProjectConfigs = (environment, codeFiles, frameworkConfigs = []) => defineConfig([
|
|
44
|
+
const UNIAPP_PROJECT_FILES = [...GLOBS_CODE, GLOB_NVUE];
|
|
45
|
+
const createProjectConfigs = (environment, codeFiles, extraFileExtensions = [], frameworkConfigs = []) => defineConfig([
|
|
38
46
|
...createGlobalIgnores(),
|
|
39
47
|
...createGitignoreConfigs(),
|
|
40
48
|
...createEnvironmentConfigs({
|
|
@@ -46,7 +54,7 @@ const createProjectConfigs = (environment, codeFiles, frameworkConfigs = []) =>
|
|
|
46
54
|
...createJavaScriptConfigs(),
|
|
47
55
|
...createImportConfigs(codeFiles),
|
|
48
56
|
...createRegexpConfigs(codeFiles),
|
|
49
|
-
...createTypeScriptConfigs(),
|
|
57
|
+
...createTypeScriptConfigs(GLOBS_TYPESCRIPT, extraFileExtensions),
|
|
50
58
|
...createJsonConfigs(),
|
|
51
59
|
...createPackageJsonSortConfigs(),
|
|
52
60
|
...createTsconfigSortConfigs(),
|
|
@@ -55,53 +63,41 @@ const createProjectConfigs = (environment, codeFiles, frameworkConfigs = []) =>
|
|
|
55
63
|
...createNodeToolingConfigs(SCRIPT_FILES)
|
|
56
64
|
]);
|
|
57
65
|
/**
|
|
58
|
-
*
|
|
66
|
+
* 创建不绑定前端框架的 JavaScript 与 TypeScript 完整配置。
|
|
59
67
|
*
|
|
60
68
|
* @remarks
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* React、Angular、Markdown 与 Lodash 等能力由调用方从 `./configs` 子路径继续组合。
|
|
69
|
+
* TypeScript 模块的导出成员按 SDK 公共 API 检查,内部实现保留类型推断。
|
|
70
|
+
* React、Angular、Markdown 与 Lodash 等能力从 `./configs` 子路径按需组合。
|
|
64
71
|
*
|
|
65
|
-
* @param options -
|
|
66
|
-
* @returns
|
|
72
|
+
* @param options - 应用源码的运行环境;默认仅注入浏览器全局变量。
|
|
73
|
+
* @returns 可直接传给 `eslint.config.*` 的 Flat Config 数组。
|
|
67
74
|
*/
|
|
68
75
|
const createBaseConfigs = ({ environment = "browser" } = {}) => createProjectConfigs(environment, SCRIPT_FILES);
|
|
69
|
-
const createVueProjectConfigs = ({ environment = "browser" } = {}) => createProjectConfigs(environment, VUE_PROJECT_FILES, [...createVueConfigs(), ...createUniAppConfigs(VUE_PROJECT_FILES)]);
|
|
70
76
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* 除运行环境外,根入口不提供能力启停开关。TypeScript 和 Vue 始终使用
|
|
75
|
-
* `strictTypeChecked`、`stylisticTypeChecked` 与 Project Service;被检查文件必须属于可发现的 tsconfig。
|
|
76
|
-
* 额外配置会放在全部内置片段之后,因此可以覆盖项目规则、globals、ignores 或解析器选项。
|
|
77
|
+
* 创建处理 `.vue`、Vue JSX 与 Vue TSX,且不注入任何 UniApp 能力的 Vue 3 完整配置。
|
|
77
78
|
*
|
|
78
|
-
* @param options -
|
|
79
|
-
* @param overrides -
|
|
80
|
-
* @returns
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* import { defineRules, fastConfig } from "@fast-china/eslint-config";
|
|
85
|
-
*
|
|
86
|
-
* export default fastConfig(
|
|
87
|
-
* { environment: "browser" },
|
|
88
|
-
* {
|
|
89
|
-
* files: ["src/generated/*.ts"],
|
|
90
|
-
* rules: defineRules({ "@typescript-eslint/no-unused-vars": "off" }),
|
|
91
|
-
* },
|
|
92
|
-
* );
|
|
93
|
-
* ```
|
|
79
|
+
* @param options - 应用源码的运行环境;默认仅注入浏览器全局变量。
|
|
80
|
+
* @param overrides - 追加在内置配置之后的项目级 Flat Config 覆写。
|
|
81
|
+
* @returns Vue 3 项目可直接使用的 Flat Config 数组。
|
|
94
82
|
*/
|
|
95
|
-
const
|
|
83
|
+
const createVueProjectConfigs = ({ environment = "browser" } = {}, ...overrides) => defineConfig([...createProjectConfigs(environment, GLOBS_CODE, [".vue"], [...createVueConfigs([GLOB_VUE], [".vue"]), ...createVueJsxConfigs([".vue"])]), ...overrides]);
|
|
96
84
|
/**
|
|
97
|
-
*
|
|
85
|
+
* 创建处理 `.vue`、`.nvue`、Vue JSX/TSX、UniApp globals 与应用清单的完整配置。
|
|
98
86
|
*
|
|
99
|
-
* @
|
|
100
|
-
*
|
|
101
|
-
*
|
|
87
|
+
* @param options - 应用源码的运行环境;默认仅注入浏览器全局变量。
|
|
88
|
+
* @param overrides - 追加在内置配置之后的项目级 Flat Config 覆写。
|
|
89
|
+
* @returns UniApp 项目可直接使用的 Flat Config 数组。
|
|
102
90
|
*/
|
|
103
|
-
const
|
|
91
|
+
const createUniAppProjectConfigs = ({ environment = "browser" } = {}, ...overrides) => defineConfig([...createProjectConfigs(environment, UNIAPP_PROJECT_FILES, [".vue", ".nvue"], [
|
|
92
|
+
...createVueConfigs([GLOB_VUE, GLOB_NVUE], [".vue", ".nvue"]),
|
|
93
|
+
...createVueJsxConfigs([".vue", ".nvue"]),
|
|
94
|
+
...createUniAppConfigs(UNIAPP_PROJECT_FILES)
|
|
95
|
+
]), ...overrides]);
|
|
96
|
+
/** 不带项目级覆写、可直接导入使用的 Vue 3 默认配置。 */
|
|
97
|
+
const vueConfig = createVueProjectConfigs();
|
|
98
|
+
/** 不带项目级覆写、可直接导入使用的 UniApp 默认配置。 */
|
|
99
|
+
const uniAppConfig = createUniAppProjectConfigs();
|
|
104
100
|
//#endregion
|
|
105
|
-
export { createBaseConfigs,
|
|
101
|
+
export { createBaseConfigs, createUniAppProjectConfigs, createVueProjectConfigs, defineRules, uniAppConfig, vueConfig };
|
|
106
102
|
|
|
107
103
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * 根入口提供彼此独立的 Vue 3 与 UniApp 完整 ESLint 配置。\n *\n * 配置片段、glob 常量与原始规则分别由 `./configs`、`./constants` 与 `./rules` 子路径提供。\n *\n * @packageDocumentation\n */\nimport { defineConfig } from \"eslint/config\";\nimport { createCommonConfigs } from \"./configs/common\";\nimport { createEnvironmentConfigs, createNodeToolingConfigs } from \"./configs/environment\";\nimport { createGitignoreConfigs, createGlobalIgnores } from \"./configs/ignores\";\nimport { createImportConfigs } from \"./configs/import\";\nimport { createJavaScriptConfigs } from \"./configs/javascript\";\nimport { createJsonConfigs } from \"./configs/json\";\nimport { createPrettierConfigs } from \"./configs/prettier\";\nimport { createRegexpConfigs } from \"./configs/regexp\";\nimport { createPackageJsonSortConfigs } from \"./configs/sort-package\";\nimport { createTsconfigSortConfigs } from \"./configs/sort-tsconfig\";\nimport { createTypeScriptConfigs } from \"./configs/typescript\";\nimport { createUniAppConfigs } from \"./configs/uniapp\";\nimport { createVueConfigs, createVueJsxConfigs } from \"./configs/vue\";\nimport { GLOBS_CODE, GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT, GLOB_NVUE, GLOB_VUE } from \"./constants\";\nimport type { Linter } from \"eslint\";\nimport type { Config } from \"eslint/config\";\nimport type { RuntimeEnvironment } from \"./configs/environment\";\nimport type { RuleOptions } from \"./typegen\";\n\ntype RejectUnknownRuleNames<Rules extends RuleOptions> = Rules & Record<Exclude<keyof Rules, keyof RuleOptions>, never>;\n\n/**\n * 定义带有完整规则名与选项类型检查的 ESLint 规则记录。\n *\n * @remarks\n * 该辅助函数只提供 TypeScript 类型约束,不会克隆、规范化或修改传入对象。规则记录可以\n * 直接放入 Flat Config 的 `rules` 字段,也可以与本包导出的规则记录组合。\n *\n * @typeParam Rules - 基于生成规则 schema 推断出的具体规则记录类型。\n * @param rules - 需要验证的 ESLint 规则记录;未知规则名和无效规则选项会产生类型错误。\n * @returns 原样返回传入的规则记录,并补充 ESLint `RulesRecord` 兼容类型。\n *\n * @example\n * ```ts\n * const rules = defineRules({\n * eqeqeq: [\"error\", \"always\"],\n * });\n * ```\n */\nexport const defineRules = <const Rules extends RuleOptions>(rules: RejectUnknownRuleNames<Rules>): Rules & Linter.RulesRecord => rules;\n\nexport type { RuleOptions } from \"./typegen\";\n\n/** Vue、UniApp 与框架无关项目完整配置共享的运行环境选项。 */\nexport interface ProjectConfigOptions {\n\t/**\n\t * 应用代码实际运行的环境。配置、脚本、测试和 CLI 文件始终单独获得 Node.js globals。\n\t * @defaultValue `\"browser\"`\n\t */\n\tenvironment?: RuntimeEnvironment;\n}\n\nconst SCRIPT_FILES = [...GLOBS_JAVASCRIPT, ...GLOBS_TYPESCRIPT];\nconst UNIAPP_PROJECT_FILES = [...GLOBS_CODE, GLOB_NVUE];\n\nconst createProjectConfigs = (\n\tenvironment: RuntimeEnvironment,\n\tcodeFiles: readonly string[],\n\textraFileExtensions: readonly string[] = [],\n\tframeworkConfigs: readonly Config[] = []\n): Config[] =>\n\tdefineConfig([\n\t\t...createGlobalIgnores(),\n\t\t...createGitignoreConfigs(),\n\t\t...createEnvironmentConfigs({\n\t\t\tenvironment,\n\t\t\tfiles: codeFiles,\n\t\t\tnodeFiles: SCRIPT_FILES,\n\t\t}),\n\t\t...createCommonConfigs(codeFiles),\n\t\t...createJavaScriptConfigs(),\n\t\t...createImportConfigs(codeFiles),\n\t\t...createRegexpConfigs(codeFiles),\n\t\t...createTypeScriptConfigs(GLOBS_TYPESCRIPT, extraFileExtensions),\n\t\t...createJsonConfigs(),\n\t\t...createPackageJsonSortConfigs(),\n\t\t...createTsconfigSortConfigs(),\n\t\t...frameworkConfigs,\n\t\t...createPrettierConfigs(),\n\t\t...createNodeToolingConfigs(SCRIPT_FILES),\n\t]);\n\n/**\n * 创建不绑定前端框架的 JavaScript 与 TypeScript 完整配置。\n *\n * @remarks\n * TypeScript 模块的导出成员按 SDK 公共 API 检查,内部实现保留类型推断。\n * React、Angular、Markdown 与 Lodash 等能力从 `./configs` 子路径按需组合。\n *\n * @param options - 应用源码的运行环境;默认仅注入浏览器全局变量。\n * @returns 可直接传给 `eslint.config.*` 的 Flat Config 数组。\n */\nexport const createBaseConfigs = ({ environment = \"browser\" }: ProjectConfigOptions = {}): Config[] =>\n\tcreateProjectConfigs(environment, SCRIPT_FILES);\n\n/**\n * 创建处理 `.vue`、Vue JSX 与 Vue TSX,且不注入任何 UniApp 能力的 Vue 3 完整配置。\n *\n * @param options - 应用源码的运行环境;默认仅注入浏览器全局变量。\n * @param overrides - 追加在内置配置之后的项目级 Flat Config 覆写。\n * @returns Vue 3 项目可直接使用的 Flat Config 数组。\n */\nexport const createVueProjectConfigs = ({ environment = \"browser\" }: ProjectConfigOptions = {}, ...overrides: Config[]): Config[] =>\n\tdefineConfig([\n\t\t...createProjectConfigs(environment, GLOBS_CODE, [\".vue\"], [...createVueConfigs([GLOB_VUE], [\".vue\"]), ...createVueJsxConfigs([\".vue\"])]),\n\t\t...overrides,\n\t]);\n\n/**\n * 创建处理 `.vue`、`.nvue`、Vue JSX/TSX、UniApp globals 与应用清单的完整配置。\n *\n * @param options - 应用源码的运行环境;默认仅注入浏览器全局变量。\n * @param overrides - 追加在内置配置之后的项目级 Flat Config 覆写。\n * @returns UniApp 项目可直接使用的 Flat Config 数组。\n */\nexport const createUniAppProjectConfigs = ({ environment = \"browser\" }: ProjectConfigOptions = {}, ...overrides: Config[]): Config[] =>\n\tdefineConfig([\n\t\t...createProjectConfigs(\n\t\t\tenvironment,\n\t\t\tUNIAPP_PROJECT_FILES,\n\t\t\t[\".vue\", \".nvue\"],\n\t\t\t[\n\t\t\t\t...createVueConfigs([GLOB_VUE, GLOB_NVUE], [\".vue\", \".nvue\"]),\n\t\t\t\t...createVueJsxConfigs([\".vue\", \".nvue\"]),\n\t\t\t\t...createUniAppConfigs(UNIAPP_PROJECT_FILES),\n\t\t\t]\n\t\t),\n\t\t...overrides,\n\t]);\n\n/** 不带项目级覆写、可直接导入使用的 Vue 3 默认配置。 */\nexport const vueConfig: Config[] = createVueProjectConfigs();\n\n/** 不带项目级覆写、可直接导入使用的 UniApp 默认配置。 */\nexport const uniAppConfig: Config[] = createUniAppProjectConfigs();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,eAAgD,UAAqE;AAalI,MAAM,eAAe,CAAC,GAAG,kBAAkB,GAAG,gBAAgB;AAC9D,MAAM,uBAAuB,CAAC,GAAG,YAAY,SAAS;AAEtD,MAAM,wBACL,aACA,WACA,sBAAyC,CAAC,GAC1C,mBAAsC,CAAC,MAEvC,aAAa;CACZ,GAAG,oBAAoB;CACvB,GAAG,uBAAuB;CAC1B,GAAG,yBAAyB;EAC3B;EACA,OAAO;EACP,WAAW;CACZ,CAAC;CACD,GAAG,oBAAoB,SAAS;CAChC,GAAG,wBAAwB;CAC3B,GAAG,oBAAoB,SAAS;CAChC,GAAG,oBAAoB,SAAS;CAChC,GAAG,wBAAwB,kBAAkB,mBAAmB;CAChE,GAAG,kBAAkB;CACrB,GAAG,6BAA6B;CAChC,GAAG,0BAA0B;CAC7B,GAAG;CACH,GAAG,sBAAsB;CACzB,GAAG,yBAAyB,YAAY;AACzC,CAAC;;;;;;;;;;;AAYF,MAAa,qBAAqB,EAAE,cAAc,cAAoC,CAAC,MACtF,qBAAqB,aAAa,YAAY;;;;;;;;AAS/C,MAAa,2BAA2B,EAAE,cAAc,cAAoC,CAAC,GAAG,GAAG,cAClG,aAAa,CACZ,GAAG,qBAAqB,aAAa,YAAY,CAAC,MAAM,GAAG,CAAC,GAAG,iBAAiB,CAAC,QAAQ,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,GACxI,GAAG,SACJ,CAAC;;;;;;;;AASF,MAAa,8BAA8B,EAAE,cAAc,cAAoC,CAAC,GAAG,GAAG,cACrG,aAAa,CACZ,GAAG,qBACF,aACA,sBACA,CAAC,QAAQ,OAAO,GAChB;CACC,GAAG,iBAAiB,CAAC,UAAU,SAAS,GAAG,CAAC,QAAQ,OAAO,CAAC;CAC5D,GAAG,oBAAoB,CAAC,QAAQ,OAAO,CAAC;CACxC,GAAG,oBAAoB,oBAAoB;AAC5C,CACD,GACA,GAAG,SACJ,CAAC;;AAGF,MAAa,YAAsB,wBAAwB;;AAG3D,MAAa,eAAyB,2BAA2B"}
|
package/dist/rules/angular.d.mts
CHANGED
|
@@ -7,18 +7,31 @@
|
|
|
7
7
|
* 22.x 的 `tsRecommended` 保持一致,并逐条说明启用理由。
|
|
8
8
|
*/
|
|
9
9
|
export declare const angularRules: {
|
|
10
|
+
/** 生命周期方法只能出现在对应的 Angular 组件或指令上下文中,避免无效钩子。 */
|
|
10
11
|
"@angular-eslint/contextual-lifecycle": "error";
|
|
12
|
+
/** 空生命周期方法没有行为且容易误导维护者,应直接移除。 */
|
|
11
13
|
"@angular-eslint/no-empty-lifecycle-method": "error";
|
|
14
|
+
/** Input 别名会让模板 API 与类属性名称分离,增加搜索和重构成本。 */
|
|
12
15
|
"@angular-eslint/no-input-rename": "error";
|
|
16
|
+
/** 统一使用 `input()` 或 `@Input` 声明输入,避免与 metadata 数组混用两套 API。 */
|
|
13
17
|
"@angular-eslint/no-inputs-metadata-property": "error";
|
|
18
|
+
/** 输出名称不得覆盖原生 DOM 事件,否则模板事件含义容易混淆。 */
|
|
14
19
|
"@angular-eslint/no-output-native": "error";
|
|
20
|
+
/** 输出本身已经表达事件语义,不使用 `on` 前缀以保持 Angular 公共 API 约定。 */
|
|
15
21
|
"@angular-eslint/no-output-on-prefix": "error";
|
|
22
|
+
/** Output 别名会让模板 API 与类属性名称分离,增加搜索和重构成本。 */
|
|
16
23
|
"@angular-eslint/no-output-rename": "error";
|
|
24
|
+
/** 统一使用 `output()` 或 `@Output` 声明输出,避免与 metadata 数组混用两套 API。 */
|
|
17
25
|
"@angular-eslint/no-outputs-metadata-property": "error";
|
|
26
|
+
/** Angular 推荐使用 `inject()` 统一依赖注入写法。 */
|
|
18
27
|
"@angular-eslint/prefer-inject": "error";
|
|
28
|
+
/** Angular 22 默认采用 `OnPush`,禁止组件显式退回 `Eager` 或旧的 `Default` 策略。 */
|
|
19
29
|
"@angular-eslint/prefer-on-push-component-change-detection": "error";
|
|
30
|
+
/** 独立组件是现代 Angular 的默认模型。 */
|
|
20
31
|
"@angular-eslint/prefer-standalone": "error";
|
|
32
|
+
/** Pipe 类实现接口后可由 TypeScript 检查 `transform` 签名,避免运行时才发现不一致。 */
|
|
21
33
|
"@angular-eslint/use-pipe-transform-interface": "error";
|
|
34
|
+
/** 生命周期接口让方法拼写和签名可由 TypeScript 验证;警告级别便于渐进补齐旧代码。 */
|
|
22
35
|
"@angular-eslint/use-lifecycle-interface": "warn";
|
|
23
36
|
};
|
|
24
37
|
/**
|
|
@@ -29,9 +42,13 @@ export declare const angularRules: {
|
|
|
29
42
|
* 控制流约束。它同时应用于外部模板与 processor 提取的内联模板。
|
|
30
43
|
*/
|
|
31
44
|
export declare const angularTemplateRules: {
|
|
45
|
+
/** 双向绑定必须使用 `[(...)]` 顺序,反写的“香蕉盒”通常是模板笔误。 */
|
|
32
46
|
"@angular-eslint/template/banana-in-box": "error";
|
|
47
|
+
/** 模板比较使用严格等号,避免 Angular 表达式中的隐式类型转换。 */
|
|
33
48
|
"@angular-eslint/template/eqeqeq": "error";
|
|
49
|
+
/** 对 `async` pipe 结果直接取反会让初始 `null` 状态产生反直觉分支。 */
|
|
34
50
|
"@angular-eslint/template/no-negated-async": "error";
|
|
51
|
+
/** 采用现代 `@if` 和 `@for` 控制流,与 Angular 推荐模板语法保持一致。 */
|
|
35
52
|
"@angular-eslint/template/prefer-control-flow": "error";
|
|
36
53
|
};
|
|
37
54
|
/**
|
|
@@ -42,16 +59,27 @@ export declare const angularTemplateRules: {
|
|
|
42
59
|
* `createAngularConfigs({ templateAccessibility: false })` 整组关闭而不影响模板基础正确性规则。
|
|
43
60
|
*/
|
|
44
61
|
export declare const angularTemplateAccessibilityRules: {
|
|
62
|
+
/** 图片和图像型元素需要替代文本,确保非视觉用户能获得等价信息。 */
|
|
45
63
|
"@angular-eslint/template/alt-text": "error";
|
|
64
|
+
/** `click` 交互需要键盘等价入口,避免仅鼠标用户可操作。 */
|
|
46
65
|
"@angular-eslint/template/click-events-have-key-events": "error";
|
|
66
|
+
/** 需要可访问名称的元素不得为空,避免读屏软件播报无意义控件。 */
|
|
47
67
|
"@angular-eslint/template/elements-content": "error";
|
|
68
|
+
/** 具有交互语义的元素必须可聚焦,确保键盘导航能够到达。 */
|
|
48
69
|
"@angular-eslint/template/interactive-supports-focus": "error";
|
|
70
|
+
/** 表单 `label` 必须关联控件,扩大可点击区域并为辅助技术提供名称。 */
|
|
49
71
|
"@angular-eslint/template/label-has-associated-control": "error";
|
|
72
|
+
/** `mouseover` 和 `mouseout` 行为需要对应键盘焦点事件,保持输入方式等价。 */
|
|
50
73
|
"@angular-eslint/template/mouse-events-have-key-events": "error";
|
|
74
|
+
/** `autofocus` 会突然移动焦点并干扰读屏流程,默认禁止。 */
|
|
51
75
|
"@angular-eslint/template/no-autofocus": "error";
|
|
76
|
+
/** 禁止 `marquee`、`blink` 等干扰性元素,避免可读性和可访问性问题。 */
|
|
52
77
|
"@angular-eslint/template/no-distracting-elements": "error";
|
|
78
|
+
/** ARIA role 必须提供该角色要求的属性,避免声明不完整的语义。 */
|
|
53
79
|
"@angular-eslint/template/role-has-required-aria": "error";
|
|
80
|
+
/** `scope` 只能用于表头 `<th>`,避免在普通单元格上声明无效的表头范围。 */
|
|
54
81
|
"@angular-eslint/template/table-scope": "error";
|
|
82
|
+
/** ARIA 属性名和值必须有效,避免浏览器静默忽略错误语义。 */
|
|
55
83
|
"@angular-eslint/template/valid-aria": "error";
|
|
56
84
|
};
|
|
57
85
|
//#endregion
|
package/dist/rules/angular.mjs
CHANGED
|
@@ -7,18 +7,31 @@
|
|
|
7
7
|
* 22.x 的 `tsRecommended` 保持一致,并逐条说明启用理由。
|
|
8
8
|
*/
|
|
9
9
|
const angularRules = {
|
|
10
|
+
/** 生命周期方法只能出现在对应的 Angular 组件或指令上下文中,避免无效钩子。 */
|
|
10
11
|
"@angular-eslint/contextual-lifecycle": "error",
|
|
12
|
+
/** 空生命周期方法没有行为且容易误导维护者,应直接移除。 */
|
|
11
13
|
"@angular-eslint/no-empty-lifecycle-method": "error",
|
|
14
|
+
/** Input 别名会让模板 API 与类属性名称分离,增加搜索和重构成本。 */
|
|
12
15
|
"@angular-eslint/no-input-rename": "error",
|
|
16
|
+
/** 统一使用 `input()` 或 `@Input` 声明输入,避免与 metadata 数组混用两套 API。 */
|
|
13
17
|
"@angular-eslint/no-inputs-metadata-property": "error",
|
|
18
|
+
/** 输出名称不得覆盖原生 DOM 事件,否则模板事件含义容易混淆。 */
|
|
14
19
|
"@angular-eslint/no-output-native": "error",
|
|
20
|
+
/** 输出本身已经表达事件语义,不使用 `on` 前缀以保持 Angular 公共 API 约定。 */
|
|
15
21
|
"@angular-eslint/no-output-on-prefix": "error",
|
|
22
|
+
/** Output 别名会让模板 API 与类属性名称分离,增加搜索和重构成本。 */
|
|
16
23
|
"@angular-eslint/no-output-rename": "error",
|
|
24
|
+
/** 统一使用 `output()` 或 `@Output` 声明输出,避免与 metadata 数组混用两套 API。 */
|
|
17
25
|
"@angular-eslint/no-outputs-metadata-property": "error",
|
|
26
|
+
/** Angular 推荐使用 `inject()` 统一依赖注入写法。 */
|
|
18
27
|
"@angular-eslint/prefer-inject": "error",
|
|
28
|
+
/** Angular 22 默认采用 `OnPush`,禁止组件显式退回 `Eager` 或旧的 `Default` 策略。 */
|
|
19
29
|
"@angular-eslint/prefer-on-push-component-change-detection": "error",
|
|
30
|
+
/** 独立组件是现代 Angular 的默认模型。 */
|
|
20
31
|
"@angular-eslint/prefer-standalone": "error",
|
|
32
|
+
/** Pipe 类实现接口后可由 TypeScript 检查 `transform` 签名,避免运行时才发现不一致。 */
|
|
21
33
|
"@angular-eslint/use-pipe-transform-interface": "error",
|
|
34
|
+
/** 生命周期接口让方法拼写和签名可由 TypeScript 验证;警告级别便于渐进补齐旧代码。 */
|
|
22
35
|
"@angular-eslint/use-lifecycle-interface": "warn"
|
|
23
36
|
};
|
|
24
37
|
/**
|
|
@@ -29,9 +42,13 @@ const angularRules = {
|
|
|
29
42
|
* 控制流约束。它同时应用于外部模板与 processor 提取的内联模板。
|
|
30
43
|
*/
|
|
31
44
|
const angularTemplateRules = {
|
|
45
|
+
/** 双向绑定必须使用 `[(...)]` 顺序,反写的“香蕉盒”通常是模板笔误。 */
|
|
32
46
|
"@angular-eslint/template/banana-in-box": "error",
|
|
47
|
+
/** 模板比较使用严格等号,避免 Angular 表达式中的隐式类型转换。 */
|
|
33
48
|
"@angular-eslint/template/eqeqeq": "error",
|
|
49
|
+
/** 对 `async` pipe 结果直接取反会让初始 `null` 状态产生反直觉分支。 */
|
|
34
50
|
"@angular-eslint/template/no-negated-async": "error",
|
|
51
|
+
/** 采用现代 `@if` 和 `@for` 控制流,与 Angular 推荐模板语法保持一致。 */
|
|
35
52
|
"@angular-eslint/template/prefer-control-flow": "error"
|
|
36
53
|
};
|
|
37
54
|
/**
|
|
@@ -42,16 +59,27 @@ const angularTemplateRules = {
|
|
|
42
59
|
* `createAngularConfigs({ templateAccessibility: false })` 整组关闭而不影响模板基础正确性规则。
|
|
43
60
|
*/
|
|
44
61
|
const angularTemplateAccessibilityRules = {
|
|
62
|
+
/** 图片和图像型元素需要替代文本,确保非视觉用户能获得等价信息。 */
|
|
45
63
|
"@angular-eslint/template/alt-text": "error",
|
|
64
|
+
/** `click` 交互需要键盘等价入口,避免仅鼠标用户可操作。 */
|
|
46
65
|
"@angular-eslint/template/click-events-have-key-events": "error",
|
|
66
|
+
/** 需要可访问名称的元素不得为空,避免读屏软件播报无意义控件。 */
|
|
47
67
|
"@angular-eslint/template/elements-content": "error",
|
|
68
|
+
/** 具有交互语义的元素必须可聚焦,确保键盘导航能够到达。 */
|
|
48
69
|
"@angular-eslint/template/interactive-supports-focus": "error",
|
|
70
|
+
/** 表单 `label` 必须关联控件,扩大可点击区域并为辅助技术提供名称。 */
|
|
49
71
|
"@angular-eslint/template/label-has-associated-control": "error",
|
|
72
|
+
/** `mouseover` 和 `mouseout` 行为需要对应键盘焦点事件,保持输入方式等价。 */
|
|
50
73
|
"@angular-eslint/template/mouse-events-have-key-events": "error",
|
|
74
|
+
/** `autofocus` 会突然移动焦点并干扰读屏流程,默认禁止。 */
|
|
51
75
|
"@angular-eslint/template/no-autofocus": "error",
|
|
76
|
+
/** 禁止 `marquee`、`blink` 等干扰性元素,避免可读性和可访问性问题。 */
|
|
52
77
|
"@angular-eslint/template/no-distracting-elements": "error",
|
|
78
|
+
/** ARIA role 必须提供该角色要求的属性,避免声明不完整的语义。 */
|
|
53
79
|
"@angular-eslint/template/role-has-required-aria": "error",
|
|
80
|
+
/** `scope` 只能用于表头 `<th>`,避免在普通单元格上声明无效的表头范围。 */
|
|
54
81
|
"@angular-eslint/template/table-scope": "error",
|
|
82
|
+
/** ARIA 属性名和值必须有效,避免浏览器静默忽略错误语义。 */
|
|
55
83
|
"@angular-eslint/template/valid-aria": "error"
|
|
56
84
|
};
|
|
57
85
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.mjs","names":[],"sources":["../../src/rules/angular.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * Angular TypeScript 推荐规则。\n *\n * @remarks\n * Angular ESLint 的拆分插件不直接导出 Flat Config 预置;本记录与 angular-eslint\n * 22.x 的 `tsRecommended` 保持一致,并逐条说明启用理由。\n */\nexport const angularRules = {\n\t
|
|
1
|
+
{"version":3,"file":"angular.mjs","names":[],"sources":["../../src/rules/angular.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * Angular TypeScript 推荐规则。\n *\n * @remarks\n * Angular ESLint 的拆分插件不直接导出 Flat Config 预置;本记录与 angular-eslint\n * 22.x 的 `tsRecommended` 保持一致,并逐条说明启用理由。\n */\nexport const angularRules = {\n\t/** 生命周期方法只能出现在对应的 Angular 组件或指令上下文中,避免无效钩子。 */\n\t\"@angular-eslint/contextual-lifecycle\": \"error\",\n\t/** 空生命周期方法没有行为且容易误导维护者,应直接移除。 */\n\t\"@angular-eslint/no-empty-lifecycle-method\": \"error\",\n\t/** Input 别名会让模板 API 与类属性名称分离,增加搜索和重构成本。 */\n\t\"@angular-eslint/no-input-rename\": \"error\",\n\t/** 统一使用 `input()` 或 `@Input` 声明输入,避免与 metadata 数组混用两套 API。 */\n\t\"@angular-eslint/no-inputs-metadata-property\": \"error\",\n\t/** 输出名称不得覆盖原生 DOM 事件,否则模板事件含义容易混淆。 */\n\t\"@angular-eslint/no-output-native\": \"error\",\n\t/** 输出本身已经表达事件语义,不使用 `on` 前缀以保持 Angular 公共 API 约定。 */\n\t\"@angular-eslint/no-output-on-prefix\": \"error\",\n\t/** Output 别名会让模板 API 与类属性名称分离,增加搜索和重构成本。 */\n\t\"@angular-eslint/no-output-rename\": \"error\",\n\t/** 统一使用 `output()` 或 `@Output` 声明输出,避免与 metadata 数组混用两套 API。 */\n\t\"@angular-eslint/no-outputs-metadata-property\": \"error\",\n\t/** Angular 推荐使用 `inject()` 统一依赖注入写法。 */\n\t\"@angular-eslint/prefer-inject\": \"error\",\n\t/** Angular 22 默认采用 `OnPush`,禁止组件显式退回 `Eager` 或旧的 `Default` 策略。 */\n\t\"@angular-eslint/prefer-on-push-component-change-detection\": \"error\",\n\t/** 独立组件是现代 Angular 的默认模型。 */\n\t\"@angular-eslint/prefer-standalone\": \"error\",\n\t/** Pipe 类实现接口后可由 TypeScript 检查 `transform` 签名,避免运行时才发现不一致。 */\n\t\"@angular-eslint/use-pipe-transform-interface\": \"error\",\n\t/** 生命周期接口让方法拼写和签名可由 TypeScript 验证;警告级别便于渐进补齐旧代码。 */\n\t\"@angular-eslint/use-lifecycle-interface\": \"warn\",\n} satisfies RuleOptions;\n\n/**\n * Angular HTML 模板推荐规则。\n *\n * @remarks\n * 该记录与 angular-eslint 22.x 的 `templateRecommended` 对齐,并补充默认启用的现代\n * 控制流约束。它同时应用于外部模板与 processor 提取的内联模板。\n */\nexport const angularTemplateRules = {\n\t/** 双向绑定必须使用 `[(...)]` 顺序,反写的“香蕉盒”通常是模板笔误。 */\n\t\"@angular-eslint/template/banana-in-box\": \"error\",\n\t/** 模板比较使用严格等号,避免 Angular 表达式中的隐式类型转换。 */\n\t\"@angular-eslint/template/eqeqeq\": \"error\",\n\t/** 对 `async` pipe 结果直接取反会让初始 `null` 状态产生反直觉分支。 */\n\t\"@angular-eslint/template/no-negated-async\": \"error\",\n\t/** 采用现代 `@if` 和 `@for` 控制流,与 Angular 推荐模板语法保持一致。 */\n\t\"@angular-eslint/template/prefer-control-flow\": \"error\",\n} satisfies RuleOptions;\n\n/**\n * Angular 模板无障碍规则。\n *\n * @remarks\n * 规则覆盖替代文本、键盘交互、焦点、表单标签与 ARIA 合法性,可通过\n * `createAngularConfigs({ templateAccessibility: false })` 整组关闭而不影响模板基础正确性规则。\n */\nexport const angularTemplateAccessibilityRules = {\n\t/** 图片和图像型元素需要替代文本,确保非视觉用户能获得等价信息。 */\n\t\"@angular-eslint/template/alt-text\": \"error\",\n\t/** `click` 交互需要键盘等价入口,避免仅鼠标用户可操作。 */\n\t\"@angular-eslint/template/click-events-have-key-events\": \"error\",\n\t/** 需要可访问名称的元素不得为空,避免读屏软件播报无意义控件。 */\n\t\"@angular-eslint/template/elements-content\": \"error\",\n\t/** 具有交互语义的元素必须可聚焦,确保键盘导航能够到达。 */\n\t\"@angular-eslint/template/interactive-supports-focus\": \"error\",\n\t/** 表单 `label` 必须关联控件,扩大可点击区域并为辅助技术提供名称。 */\n\t\"@angular-eslint/template/label-has-associated-control\": \"error\",\n\t/** `mouseover` 和 `mouseout` 行为需要对应键盘焦点事件,保持输入方式等价。 */\n\t\"@angular-eslint/template/mouse-events-have-key-events\": \"error\",\n\t/** `autofocus` 会突然移动焦点并干扰读屏流程,默认禁止。 */\n\t\"@angular-eslint/template/no-autofocus\": \"error\",\n\t/** 禁止 `marquee`、`blink` 等干扰性元素,避免可读性和可访问性问题。 */\n\t\"@angular-eslint/template/no-distracting-elements\": \"error\",\n\t/** ARIA role 必须提供该角色要求的属性,避免声明不完整的语义。 */\n\t\"@angular-eslint/template/role-has-required-aria\": \"error\",\n\t/** `scope` 只能用于表头 `<th>`,避免在普通单元格上声明无效的表头范围。 */\n\t\"@angular-eslint/template/table-scope\": \"error\",\n\t/** ARIA 属性名和值必须有效,避免浏览器静默忽略错误语义。 */\n\t\"@angular-eslint/template/valid-aria\": \"error\",\n} satisfies RuleOptions;\n"],"mappings":";;;;;;;;AASA,MAAa,eAAe;;CAE3B,wCAAwC;;CAExC,6CAA6C;;CAE7C,mCAAmC;;CAEnC,+CAA+C;;CAE/C,oCAAoC;;CAEpC,uCAAuC;;CAEvC,oCAAoC;;CAEpC,gDAAgD;;CAEhD,iCAAiC;;CAEjC,6DAA6D;;CAE7D,qCAAqC;;CAErC,gDAAgD;;CAEhD,2CAA2C;AAC5C;;;;;;;;AASA,MAAa,uBAAuB;;CAEnC,0CAA0C;;CAE1C,mCAAmC;;CAEnC,6CAA6C;;CAE7C,gDAAgD;AACjD;;;;;;;;AASA,MAAa,oCAAoC;;CAEhD,qCAAqC;;CAErC,yDAAyD;;CAEzD,6CAA6C;;CAE7C,uDAAuD;;CAEvD,yDAAyD;;CAEzD,yDAAyD;;CAEzD,yCAAyC;;CAEzC,oDAAoD;;CAEpD,mDAAmD;;CAEnD,wCAAwC;;CAExC,uCAAuC;AACxC"}
|
package/dist/rules/common.d.mts
CHANGED
|
@@ -7,29 +7,39 @@
|
|
|
7
7
|
* 跨语言且误报较少的规则;纯格式和语法偏好交给 Prettier 或项目自行覆盖。
|
|
8
8
|
*/
|
|
9
9
|
export declare const commonRules: {
|
|
10
|
+
/** 要求数组回调在所有可到达分支返回值,避免 `map`、`filter` 等调用静默产生 `undefined`。 */
|
|
10
11
|
"array-callback-return": "error";
|
|
12
|
+
/** 浏览器弹窗通常不适合生产代码;使用警告允许原型调试,同时确保发布前能够被发现。 */
|
|
11
13
|
"no-alert": "warn";
|
|
14
|
+
/** `switch` 的 `case` 不创建词法作用域;要求用花括号包裹声明,避免跨分支冲突。 */
|
|
12
15
|
"no-case-declarations": "error";
|
|
16
|
+
/** 禁止动态执行字符串代码,避免代码注入和静态分析失效。 */
|
|
13
17
|
"no-eval": "error";
|
|
18
|
+
/** 禁止 `setTimeout`、`setInterval` 等 API 通过字符串间接执行代码。 */
|
|
14
19
|
"no-implied-eval": "error";
|
|
20
|
+
/** 禁止使用 `Function` 构造器动态编译字符串代码,避免绕过静态分析和安全策略。 */
|
|
15
21
|
"no-new-func": "error";
|
|
22
|
+
/** Promise executor 的返回值会被忽略,禁止误把 `return` 当作 Promise 的解析结果。 */
|
|
16
23
|
"no-promise-executor-return": "error";
|
|
24
|
+
/** 禁止反斜杠续行字符串,优先使用可读性更好的模板字符串。 */
|
|
17
25
|
"no-multi-str": "error";
|
|
26
|
+
/** `with` 会让标识符解析不可预测,并且在严格模式和 ESM 中不可用。 */
|
|
18
27
|
"no-with": "error";
|
|
28
|
+
/** Promise 是否等待由业务语义决定,不使用 `void promise` 作为 ESLint 规避语法。 */
|
|
19
29
|
"no-void": "error";
|
|
30
|
+
/** 简单单行分支允许省略花括号;多行分支必须使用花括号,同一条件链保持一致。 */
|
|
20
31
|
curly: ["error", "multi-line", "consistent"];
|
|
32
|
+
/** `default` 分支不是强制项,但存在时统一位于其他 `case` 之后。 */
|
|
21
33
|
"default-case-last": "error";
|
|
34
|
+
/** 要求严格相等;保留 `value == null` 同时判断 `null` 与 `undefined` 的常用写法。 */
|
|
22
35
|
eqeqeq: ["error", "always", {
|
|
23
36
|
null: "ignore";
|
|
24
37
|
}];
|
|
38
|
+
/** 使用幂运算符代替 `Math.pow`,使数学表达式更直接。 */
|
|
25
39
|
"prefer-exponentiation-operator": "error";
|
|
26
|
-
|
|
27
|
-
"sort-imports": ["
|
|
28
|
-
ignoreCase: false;
|
|
40
|
+
/** `import` 声明内部的成员按名称排序;声明之间的分组和顺序交给 `import-x/order`。 */
|
|
41
|
+
"sort-imports": ["error", {
|
|
29
42
|
ignoreDeclarationSort: true;
|
|
30
|
-
ignoreMemberSort: false;
|
|
31
|
-
memberSyntaxSortOrder: ["none", "all", "multiple", "single"];
|
|
32
|
-
allowSeparatedGroups: false;
|
|
33
43
|
}];
|
|
34
44
|
};
|
|
35
45
|
//#endregion
|
package/dist/rules/common.mjs
CHANGED
|
@@ -7,41 +7,44 @@
|
|
|
7
7
|
* 跨语言且误报较少的规则;纯格式和语法偏好交给 Prettier 或项目自行覆盖。
|
|
8
8
|
*/
|
|
9
9
|
const commonRules = {
|
|
10
|
+
/** 要求数组回调在所有可到达分支返回值,避免 `map`、`filter` 等调用静默产生 `undefined`。 */
|
|
10
11
|
"array-callback-return": "error",
|
|
12
|
+
/** 浏览器弹窗通常不适合生产代码;使用警告允许原型调试,同时确保发布前能够被发现。 */
|
|
11
13
|
"no-alert": "warn",
|
|
14
|
+
/** `switch` 的 `case` 不创建词法作用域;要求用花括号包裹声明,避免跨分支冲突。 */
|
|
12
15
|
"no-case-declarations": "error",
|
|
16
|
+
/** 禁止动态执行字符串代码,避免代码注入和静态分析失效。 */
|
|
13
17
|
"no-eval": "error",
|
|
18
|
+
/** 禁止 `setTimeout`、`setInterval` 等 API 通过字符串间接执行代码。 */
|
|
14
19
|
"no-implied-eval": "error",
|
|
20
|
+
/** 禁止使用 `Function` 构造器动态编译字符串代码,避免绕过静态分析和安全策略。 */
|
|
15
21
|
"no-new-func": "error",
|
|
22
|
+
/** Promise executor 的返回值会被忽略,禁止误把 `return` 当作 Promise 的解析结果。 */
|
|
16
23
|
"no-promise-executor-return": "error",
|
|
24
|
+
/** 禁止反斜杠续行字符串,优先使用可读性更好的模板字符串。 */
|
|
17
25
|
"no-multi-str": "error",
|
|
26
|
+
/** `with` 会让标识符解析不可预测,并且在严格模式和 ESM 中不可用。 */
|
|
18
27
|
"no-with": "error",
|
|
28
|
+
/** Promise 是否等待由业务语义决定,不使用 `void promise` 作为 ESLint 规避语法。 */
|
|
19
29
|
"no-void": "error",
|
|
30
|
+
/** 简单单行分支允许省略花括号;多行分支必须使用花括号,同一条件链保持一致。 */
|
|
20
31
|
curly: [
|
|
21
32
|
"error",
|
|
22
33
|
"multi-line",
|
|
23
34
|
"consistent"
|
|
24
35
|
],
|
|
36
|
+
/** `default` 分支不是强制项,但存在时统一位于其他 `case` 之后。 */
|
|
25
37
|
"default-case-last": "error",
|
|
38
|
+
/** 要求严格相等;保留 `value == null` 同时判断 `null` 与 `undefined` 的常用写法。 */
|
|
26
39
|
eqeqeq: [
|
|
27
40
|
"error",
|
|
28
41
|
"always",
|
|
29
42
|
{ null: "ignore" }
|
|
30
43
|
],
|
|
44
|
+
/** 使用幂运算符代替 `Math.pow`,使数学表达式更直接。 */
|
|
31
45
|
"prefer-exponentiation-operator": "error",
|
|
32
|
-
|
|
33
|
-
"sort-imports": ["
|
|
34
|
-
ignoreCase: false,
|
|
35
|
-
ignoreDeclarationSort: true,
|
|
36
|
-
ignoreMemberSort: false,
|
|
37
|
-
memberSyntaxSortOrder: [
|
|
38
|
-
"none",
|
|
39
|
-
"all",
|
|
40
|
-
"multiple",
|
|
41
|
-
"single"
|
|
42
|
-
],
|
|
43
|
-
allowSeparatedGroups: false
|
|
44
|
-
}]
|
|
46
|
+
/** `import` 声明内部的成员按名称排序;声明之间的分组和顺序交给 `import-x/order`。 */
|
|
47
|
+
"sort-imports": ["error", { ignoreDeclarationSort: true }]
|
|
45
48
|
};
|
|
46
49
|
//#endregion
|
|
47
50
|
export { commonRules };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.mjs","names":[],"sources":["../../src/rules/common.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * 跨 JavaScript、TypeScript 与 Vue 脚本生效的公共规则。\n *\n * @remarks\n * 默认规则面向 SDK、OA、Admin 与客户端项目使用同一套质量标准。这里只保留\n * 跨语言且误报较少的规则;纯格式和语法偏好交给 Prettier 或项目自行覆盖。\n */\nexport const commonRules = {\n\t
|
|
1
|
+
{"version":3,"file":"common.mjs","names":[],"sources":["../../src/rules/common.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * 跨 JavaScript、TypeScript 与 Vue 脚本生效的公共规则。\n *\n * @remarks\n * 默认规则面向 SDK、OA、Admin 与客户端项目使用同一套质量标准。这里只保留\n * 跨语言且误报较少的规则;纯格式和语法偏好交给 Prettier 或项目自行覆盖。\n */\nexport const commonRules = {\n\t/** 要求数组回调在所有可到达分支返回值,避免 `map`、`filter` 等调用静默产生 `undefined`。 */\n\t\"array-callback-return\": \"error\",\n\t/** 浏览器弹窗通常不适合生产代码;使用警告允许原型调试,同时确保发布前能够被发现。 */\n\t\"no-alert\": \"warn\",\n\t/** `switch` 的 `case` 不创建词法作用域;要求用花括号包裹声明,避免跨分支冲突。 */\n\t\"no-case-declarations\": \"error\",\n\t/** 禁止动态执行字符串代码,避免代码注入和静态分析失效。 */\n\t\"no-eval\": \"error\",\n\t/** 禁止 `setTimeout`、`setInterval` 等 API 通过字符串间接执行代码。 */\n\t\"no-implied-eval\": \"error\",\n\t/** 禁止使用 `Function` 构造器动态编译字符串代码,避免绕过静态分析和安全策略。 */\n\t\"no-new-func\": \"error\",\n\t/** Promise executor 的返回值会被忽略,禁止误把 `return` 当作 Promise 的解析结果。 */\n\t\"no-promise-executor-return\": \"error\",\n\t/** 禁止反斜杠续行字符串,优先使用可读性更好的模板字符串。 */\n\t\"no-multi-str\": \"error\",\n\t/** `with` 会让标识符解析不可预测,并且在严格模式和 ESM 中不可用。 */\n\t\"no-with\": \"error\",\n\t/** Promise 是否等待由业务语义决定,不使用 `void promise` 作为 ESLint 规避语法。 */\n\t\"no-void\": \"error\",\n\t/** 简单单行分支允许省略花括号;多行分支必须使用花括号,同一条件链保持一致。 */\n\tcurly: [\"error\", \"multi-line\", \"consistent\"],\n\t/** `default` 分支不是强制项,但存在时统一位于其他 `case` 之后。 */\n\t\"default-case-last\": \"error\",\n\t/** 要求严格相等;保留 `value == null` 同时判断 `null` 与 `undefined` 的常用写法。 */\n\teqeqeq: [\"error\", \"always\", { null: \"ignore\" }],\n\t/** 使用幂运算符代替 `Math.pow`,使数学表达式更直接。 */\n\t\"prefer-exponentiation-operator\": \"error\",\n\t/** `import` 声明内部的成员按名称排序;声明之间的分组和顺序交给 `import-x/order`。 */\n\t\"sort-imports\": [\"error\", { ignoreDeclarationSort: true }],\n} satisfies RuleOptions;\n"],"mappings":";;;;;;;;AASA,MAAa,cAAc;;CAE1B,yBAAyB;;CAEzB,YAAY;;CAEZ,wBAAwB;;CAExB,WAAW;;CAEX,mBAAmB;;CAEnB,eAAe;;CAEf,8BAA8B;;CAE9B,gBAAgB;;CAEhB,WAAW;;CAEX,WAAW;;CAEX,OAAO;EAAC;EAAS;EAAc;CAAY;;CAE3C,qBAAqB;;CAErB,QAAQ;EAAC;EAAS;EAAU,EAAE,MAAM,SAAS;CAAC;;CAE9C,kCAAkC;;CAElC,gBAAgB,CAAC,SAAS,EAAE,uBAAuB,KAAK,CAAC;AAC1D"}
|
package/dist/rules/import.d.mts
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
* 的静态导出分析默认关闭,避免共享配置误判路径别名或自定义模块解析方式。
|
|
8
8
|
*/
|
|
9
9
|
export declare const importRules: {
|
|
10
|
+
/** `import` 必须位于其他语句之前,避免模块依赖散落在执行逻辑中。 */
|
|
10
11
|
"import-x/first": "error";
|
|
12
|
+
/** 合并同一模块的重复 `import`,避免绑定分散或副作用被误读。 */
|
|
11
13
|
"import-x/no-duplicates": "error";
|
|
14
|
+
/** `import` 按来源分组并排序,错误顺序可由 ESLint 自动修复。 */
|
|
12
15
|
"import-x/order": ["error", {
|
|
13
16
|
groups: string[];
|
|
14
17
|
pathGroups: ({
|
|
@@ -29,11 +32,17 @@ export declare const importRules: {
|
|
|
29
32
|
};
|
|
30
33
|
warnOnUnassignedImports: true;
|
|
31
34
|
}];
|
|
35
|
+
/** [默认关闭] Vite 与 TypeScript 别名由项目解析器校验,避免共享配置绑定特定 resolver。 */
|
|
32
36
|
"import-x/no-unresolved": "off";
|
|
37
|
+
/** [默认关闭] 未配置 resolver 时,namespace 导出的静态分析容易产生误报。 */
|
|
33
38
|
"import-x/namespace": "off";
|
|
39
|
+
/** [默认关闭] 未配置 resolver 时,默认导出的静态分析容易产生误报。 */
|
|
34
40
|
"import-x/default": "off";
|
|
41
|
+
/** [默认关闭] 不限制同时存在默认导出与相近命名导出的模块 API 风格。 */
|
|
35
42
|
"import-x/no-named-as-default": "off";
|
|
43
|
+
/** [默认关闭] 不限制通过默认导入对象访问同名属性的项目 API 风格。 */
|
|
36
44
|
"import-x/no-named-as-default-member": "off";
|
|
45
|
+
/** [默认关闭] 未配置 resolver 时,命名导出的静态分析容易产生误报。 */
|
|
37
46
|
"import-x/named": "off";
|
|
38
47
|
};
|
|
39
48
|
//#endregion
|
package/dist/rules/import.mjs
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
* 的静态导出分析默认关闭,避免共享配置误判路径别名或自定义模块解析方式。
|
|
8
8
|
*/
|
|
9
9
|
const importRules = {
|
|
10
|
+
/** `import` 必须位于其他语句之前,避免模块依赖散落在执行逻辑中。 */
|
|
10
11
|
"import-x/first": "error",
|
|
12
|
+
/** 合并同一模块的重复 `import`,避免绑定分散或副作用被误读。 */
|
|
11
13
|
"import-x/no-duplicates": "error",
|
|
14
|
+
/** `import` 按来源分组并排序,错误顺序可由 ESLint 自动修复。 */
|
|
12
15
|
"import-x/order": ["error", {
|
|
13
16
|
groups: [
|
|
14
17
|
"builtin",
|
|
@@ -32,6 +35,21 @@ const importRules = {
|
|
|
32
35
|
group: "external",
|
|
33
36
|
position: "before"
|
|
34
37
|
},
|
|
38
|
+
{
|
|
39
|
+
pattern: "{react,react-dom,react-router,react-router-dom,@react/**,@reduxjs/**}",
|
|
40
|
+
group: "external",
|
|
41
|
+
position: "before"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
pattern: "{@angular/**,@angular-eslint/**}",
|
|
45
|
+
group: "external",
|
|
46
|
+
position: "before"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: "{vite,@vitejs/**}",
|
|
50
|
+
group: "external",
|
|
51
|
+
position: "before"
|
|
52
|
+
},
|
|
35
53
|
{
|
|
36
54
|
pattern: "{element-plus,element-plus/**,@element-plus/**}",
|
|
37
55
|
group: "external",
|
|
@@ -67,11 +85,17 @@ const importRules = {
|
|
|
67
85
|
},
|
|
68
86
|
warnOnUnassignedImports: true
|
|
69
87
|
}],
|
|
88
|
+
/** [默认关闭] Vite 与 TypeScript 别名由项目解析器校验,避免共享配置绑定特定 resolver。 */
|
|
70
89
|
"import-x/no-unresolved": "off",
|
|
90
|
+
/** [默认关闭] 未配置 resolver 时,namespace 导出的静态分析容易产生误报。 */
|
|
71
91
|
"import-x/namespace": "off",
|
|
92
|
+
/** [默认关闭] 未配置 resolver 时,默认导出的静态分析容易产生误报。 */
|
|
72
93
|
"import-x/default": "off",
|
|
94
|
+
/** [默认关闭] 不限制同时存在默认导出与相近命名导出的模块 API 风格。 */
|
|
73
95
|
"import-x/no-named-as-default": "off",
|
|
96
|
+
/** [默认关闭] 不限制通过默认导入对象访问同名属性的项目 API 风格。 */
|
|
74
97
|
"import-x/no-named-as-default-member": "off",
|
|
98
|
+
/** [默认关闭] 未配置 resolver 时,命名导出的静态分析容易产生误报。 */
|
|
75
99
|
"import-x/named": "off"
|
|
76
100
|
};
|
|
77
101
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/rules/import.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * 默认启用的模块导入正确性与排序规则。\n *\n * @remarks\n * 该记录补充 import-x 推荐预置,统一导入位置、重复导入及分组顺序。依赖项目 resolver\n * 的静态导出分析默认关闭,避免共享配置误判路径别名或自定义模块解析方式。\n */\nexport const importRules = {\n\t
|
|
1
|
+
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/rules/import.ts"],"sourcesContent":["import type { RuleOptions } from \"../typegen\";\n\n/**\n * 默认启用的模块导入正确性与排序规则。\n *\n * @remarks\n * 该记录补充 import-x 推荐预置,统一导入位置、重复导入及分组顺序。依赖项目 resolver\n * 的静态导出分析默认关闭,避免共享配置误判路径别名或自定义模块解析方式。\n */\nexport const importRules = {\n\t/** `import` 必须位于其他语句之前,避免模块依赖散落在执行逻辑中。 */\n\t\"import-x/first\": \"error\",\n\t/** 合并同一模块的重复 `import`,避免绑定分散或副作用被误读。 */\n\t\"import-x/no-duplicates\": \"error\",\n\t/** `import` 按来源分组并排序,错误顺序可由 ESLint 自动修复。 */\n\t\"import-x/order\": [\n\t\t\"error\",\n\t\t{\n\t\t\tgroups: [\n\t\t\t\t// Node.js 内置模块\n\t\t\t\t\"builtin\",\n\t\t\t\t// 第三方依赖\n\t\t\t\t\"external\",\n\t\t\t\t// 项目内部别名模块\n\t\t\t\t\"internal\",\n\t\t\t\t// 父级目录模块\n\t\t\t\t\"parent\",\n\t\t\t\t// 同级目录模块\n\t\t\t\t\"sibling\",\n\t\t\t\t// 当前目录入口模块\n\t\t\t\t\"index\",\n\t\t\t\t// TypeScript import = require() 导入\n\t\t\t\t\"object\",\n\t\t\t\t// 无法识别分类的导入\n\t\t\t\t\"unknown\",\n\t\t\t\t// TypeScript 类型导入始终位于所有非样式导入之后\n\t\t\t\t\"type\",\n\t\t\t],\n\t\t\t// 常用平台、框架和工具依赖优先于其他第三方依赖,并按声明顺序分层排序。\n\t\t\tpathGroups: [\n\t\t\t\t// uni-app 平台生态\n\t\t\t\t{ pattern: \"@dcloudio/**\", group: \"external\", position: \"before\" },\n\t\t\t\t// Vue 核心、路由、状态管理和 VueUse 生态\n\t\t\t\t{ pattern: \"{vue,@vue/**,vue-router,pinia,@pinia/**,@vueuse/**}\", group: \"external\", position: \"before\" },\n\t\t\t\t// React、路由和 Redux 生态\n\t\t\t\t{\n\t\t\t\t\tpattern: \"{react,react-dom,react-router,react-router-dom,@react/**,@reduxjs/**}\",\n\t\t\t\t\tgroup: \"external\",\n\t\t\t\t\tposition: \"before\",\n\t\t\t\t},\n\t\t\t\t// Angular 及 Angular ESLint 生态\n\t\t\t\t{ pattern: \"{@angular/**,@angular-eslint/**}\", group: \"external\", position: \"before\" },\n\t\t\t\t// Vite 及其官方作用域包\n\t\t\t\t{ pattern: \"{vite,@vitejs/**}\", group: \"external\", position: \"before\" },\n\t\t\t\t// Element Plus 生态及其子路径\n\t\t\t\t{ pattern: \"{element-plus,element-plus/**,@element-plus/**}\", group: \"external\", position: \"before\" },\n\t\t\t\t// Fast Element Plus 生态及其子路径\n\t\t\t\t{ pattern: \"{fast-element-plus,fast-element-plus/**,@fast-element-plus/**}\", group: \"external\", position: \"before\" },\n\t\t\t\t// Fast China 组织包及其子路径\n\t\t\t\t{ pattern: \"@fast-china/**\", group: \"external\", position: \"before\" },\n\t\t\t\t// Lodash、lodash-es、lodash-unified 及其子路径\n\t\t\t\t{ pattern: \"lodash{,-es,-unified}{,/**}\", group: \"external\", position: \"before\" },\n\t\t\t\t// 项目根目录 @/ 别名归入 internal,并优先于其他 internal 导入\n\t\t\t\t{ pattern: \"@/**\", group: \"internal\", position: \"before\" },\n\t\t\t],\n\t\t\t// 类型导入统一保留在 type 总分组,不参与自定义 pathGroups 匹配。\n\t\t\tpathGroupsExcludedImportTypes: [\"type\"],\n\t\t\t// type 总分组内部继续按照 builtin、external、internal、parent、sibling、index 来源层级排序\n\t\t\tsortTypesGroup: true,\n\t\t\t// 所有 import 分组连续排列,不保留空行\n\t\t\t\"newlines-between\": \"never\",\n\t\t\t// 同一分组内按照模块路径字母升序排列\n\t\t\talphabetize: {\n\t\t\t\torder: \"asc\",\n\t\t\t\tcaseInsensitive: true,\n\t\t\t},\n\t\t\t// 非样式副作用导入参与检查;样式导入由独立规则保持最后且不改变组内层叠顺序。\n\t\t\twarnOnUnassignedImports: true,\n\t\t},\n\t],\n\t/** [默认关闭] Vite 与 TypeScript 别名由项目解析器校验,避免共享配置绑定特定 resolver。 */\n\t\"import-x/no-unresolved\": \"off\",\n\t/** [默认关闭] 未配置 resolver 时,namespace 导出的静态分析容易产生误报。 */\n\t\"import-x/namespace\": \"off\",\n\t/** [默认关闭] 未配置 resolver 时,默认导出的静态分析容易产生误报。 */\n\t\"import-x/default\": \"off\",\n\t/** [默认关闭] 不限制同时存在默认导出与相近命名导出的模块 API 风格。 */\n\t\"import-x/no-named-as-default\": \"off\",\n\t/** [默认关闭] 不限制通过默认导入对象访问同名属性的项目 API 风格。 */\n\t\"import-x/no-named-as-default-member\": \"off\",\n\t/** [默认关闭] 未配置 resolver 时,命名导出的静态分析容易产生误报。 */\n\t\"import-x/named\": \"off\",\n} satisfies RuleOptions;\n"],"mappings":";;;;;;;;AASA,MAAa,cAAc;;CAE1B,kBAAkB;;CAElB,0BAA0B;;CAE1B,kBAAkB,CACjB,SACA;EACC,QAAQ;GAEP;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;GAEA;EACD;EAEA,YAAY;GAEX;IAAE,SAAS;IAAgB,OAAO;IAAY,UAAU;GAAS;GAEjE;IAAE,SAAS;IAAuD,OAAO;IAAY,UAAU;GAAS;GAExG;IACC,SAAS;IACT,OAAO;IACP,UAAU;GACX;GAEA;IAAE,SAAS;IAAoC,OAAO;IAAY,UAAU;GAAS;GAErF;IAAE,SAAS;IAAqB,OAAO;IAAY,UAAU;GAAS;GAEtE;IAAE,SAAS;IAAmD,OAAO;IAAY,UAAU;GAAS;GAEpG;IAAE,SAAS;IAAkE,OAAO;IAAY,UAAU;GAAS;GAEnH;IAAE,SAAS;IAAkB,OAAO;IAAY,UAAU;GAAS;GAEnE;IAAE,SAAS;IAA+B,OAAO;IAAY,UAAU;GAAS;GAEhF;IAAE,SAAS;IAAQ,OAAO;IAAY,UAAU;GAAS;EAC1D;EAEA,+BAA+B,CAAC,MAAM;EAEtC,gBAAgB;EAEhB,oBAAoB;EAEpB,aAAa;GACZ,OAAO;GACP,iBAAiB;EAClB;EAEA,yBAAyB;CAC1B,CACD;;CAEA,0BAA0B;;CAE1B,sBAAsB;;CAEtB,oBAAoB;;CAEpB,gCAAgC;;CAEhC,uCAAuC;;CAEvC,kBAAkB;AACnB"}
|