@fast-china/eslint-config 2.1.1 → 2.1.4
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 +18 -0
- package/dist/index.mjs.map +1 -1
- package/dist/rules/import.d.mts +7 -2
- package/dist/rules/import.mjs +8 -2
- package/dist/rules/import.mjs.map +1 -1
- package/dist/rules/typescript.d.mts +1 -1
- package/dist/rules/typescript.mjs +1 -1
- package/dist/rules/typescript.mjs.map +1 -1
- package/docs/engineering-audit.zh.md +3 -2
- package/docs/rules-risk.md +5 -5
- package/docs/rules-risk.zh.md +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,24 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 2.1.4 - 2026-08-30
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Classified `@/**` root aliases as leading internal imports and moved the `type` group after every other non-style import group, while styles remain in their final stable group.
|
|
14
|
+
|
|
15
|
+
## 2.1.3 - 2026-08-29
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Enabled `import-x/order` `sortTypesGroup` so separate type imports retain the final type group while sorting by their original source category within it.
|
|
20
|
+
|
|
21
|
+
## 2.1.2 - 2026-08-29
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Changed `@typescript-eslint/consistent-type-imports` fixes from inline type specifiers to separate `import type` declarations.
|
|
26
|
+
|
|
9
27
|
## 2.1.1 - 2026-08-29
|
|
10
28
|
|
|
11
29
|
### Added
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * 根入口提供面向 Vue 3、TypeScript 与 UniApp 浏览器项目的固定 ESLint 配置。\n *\n * 配置片段、glob 常量与原始规则分别由 `./configs`、`./constants` 与 `./rules` 子路径提供。\n *\n * @packageDocumentation\n */\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * 根入口提供面向 Vue 3、TypeScript 与 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 } from \"./configs/vue\";\nimport { GLOBS_CODE, GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT, GLOB_NVUE } 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 * 为项目规则提供精确的规则名、严重级别和规则选项自动补全。\n *\n * @remarks\n * 该函数不会修改传入对象;它只在 TypeScript 编译阶段拒绝未知规则和无效选项。\n *\n * @typeParam Rules - 调用方传入的规则记录类型;保留字面量键和值以提供精确推断。\n * @param rules - 需要进行规则名、严重级别和选项校验的 ESLint 规则记录。\n * @returns 原始规则记录。返回值同时兼容 ESLint 的通用 `RulesRecord` 类型。\n */\nexport const defineRules = <const Rules extends RuleOptions>(rules: RejectUnknownRuleNames<Rules>): Rules & Linter.RulesRecord => rules;\n\nexport type { RuleOptions } from \"./typegen\";\n\n/**\n * 根配置工厂唯一保留的项目选项。\n *\n * @remarks\n * 根入口固定启用 `.gitignore`、JavaScript、类型感知 TypeScript、Vue 3、UniApp、Import、\n * RegExp、JSON、清单排序和 Prettier 兼容层。项目级规则、globals 与 ignores 应通过\n * `fastConfig()` 的后置 Flat Config 参数声明。React、Angular、Markdown 与其他可选能力\n * 应从 `@fast-china/eslint-config/configs` 显式组合。\n */\nexport interface FastConfigOptions {\n\t/**\n\t * 应用代码实际运行的环境。\n\t *\n\t * - `\"browser\"`:提供浏览器全局变量。\n\t * - `\"node\"`:提供 Node.js 全局变量。\n\t * - `\"universal\"`:同时提供浏览器与 Node.js 全局变量。\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 VUE_PROJECT_FILES = [...GLOBS_CODE, GLOB_NVUE];\n\nconst createProjectConfigs = (environment: RuntimeEnvironment, codeFiles: readonly string[], frameworkConfigs: readonly Config[] = []): 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(),\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 * 创建不绑定前端框架的固定基础配置。\n *\n * @remarks\n * 默认包含 `.gitignore`、JavaScript、类型感知 TypeScript、Import、RegExp、JSON、\n * `package.json`/`tsconfig*.json` 排序、Prettier 兼容层和 Node.js 工程文件覆写。\n * React、Angular、Markdown 与 Lodash 等能力由调用方从 `./configs` 子路径继续组合。\n *\n * @param options - 应用代码的运行环境。\n * @returns 可作为 React、Angular、Node.js 或 SDK 项目基础的 Flat Config 数组。\n */\nexport const createBaseConfigs = ({ environment = \"browser\" }: FastConfigOptions = {}): Config[] => createProjectConfigs(environment, SCRIPT_FILES);\n\nconst createVueProjectConfigs = ({ environment = \"browser\" }: FastConfigOptions = {}): Config[] =>\n\tcreateProjectConfigs(environment, VUE_PROJECT_FILES, [...createVueConfigs(), ...createUniAppConfigs(VUE_PROJECT_FILES)]);\n\n/**\n * 创建固定的 Vue 3、TypeScript 与 UniApp ESLint Flat Config。\n *\n * @remarks\n * 除运行环境外,根入口不提供能力启停开关。TypeScript 和 Vue 始终使用\n * `recommendedTypeChecked` 与 Project Service;被检查文件必须属于可发现的 tsconfig。\n * 额外配置会放在全部内置片段之后,因此可以覆盖项目规则、globals、ignores 或解析器选项。\n *\n * @param options - 应用代码的运行环境。\n * @param overrides - 追加到全部内置片段之后的 ESLint Flat Config。\n * @returns 可直接导出给 ESLint 的 Flat Config 数组。\n *\n * @example\n * ```ts\n * import { defineRules, fastConfig } from \"@fast-china/eslint-config\";\n *\n * export default fastConfig(\n * { environment: \"browser\" },\n * {\n * files: [\"src/generated/*.ts\"],\n * rules: defineRules({ \"@typescript-eslint/no-unused-vars\": \"off\" }),\n * },\n * );\n * ```\n */\nexport const fastConfig = ({ environment = \"browser\" }: FastConfigOptions = {}, ...overrides: Config[]): Config[] =>\n\tdefineConfig([...createVueProjectConfigs({ environment }), ...overrides]);\n\n/**\n * 可直接导出或展开的默认 ESLint Flat Config。\n *\n * @remarks\n * 默认使用浏览器环境。需要切换运行环境或追加项目覆写时,请使用具名导出的\n * {@link fastConfig} 工厂。\n */\nconst fastChina: Config[] = fastConfig();\n\nexport default fastChina;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,eAAgD,UAAqE;AA2BlI,MAAM,eAAe,CAAC,GAAG,kBAAkB,GAAG,gBAAgB;AAC9D,MAAM,oBAAoB,CAAC,GAAG,YAAY,SAAS;AAEnD,MAAM,wBAAwB,aAAiC,WAA8B,mBAAsC,CAAC,MACnI,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;CAC3B,GAAG,kBAAkB;CACrB,GAAG,6BAA6B;CAChC,GAAG,0BAA0B;CAC7B,GAAG;CACH,GAAG,sBAAsB;CACzB,GAAG,yBAAyB,YAAY;AACzC,CAAC;;;;;;;;;;;;AAaF,MAAa,qBAAqB,EAAE,cAAc,cAAiC,CAAC,MAAgB,qBAAqB,aAAa,YAAY;AAElJ,MAAM,2BAA2B,EAAE,cAAc,cAAiC,CAAC,MAClF,qBAAqB,aAAa,mBAAmB,CAAC,GAAG,iBAAiB,GAAG,GAAG,oBAAoB,iBAAiB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BxH,MAAa,cAAc,EAAE,cAAc,cAAiC,CAAC,GAAG,GAAG,cAClF,aAAa,CAAC,GAAG,wBAAwB,EAAE,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;;;;;;;;AASzE,MAAM,YAAsB,WAAW"}
|
package/dist/rules/import.d.mts
CHANGED
|
@@ -11,12 +11,17 @@ declare const importRules: {
|
|
|
11
11
|
"import-x/no-duplicates": "error";
|
|
12
12
|
"import-x/order": ["error", {
|
|
13
13
|
groups: string[];
|
|
14
|
-
pathGroups: {
|
|
14
|
+
pathGroups: ({
|
|
15
15
|
pattern: string;
|
|
16
16
|
group: "external";
|
|
17
17
|
position: "before";
|
|
18
|
-
}
|
|
18
|
+
} | {
|
|
19
|
+
pattern: string;
|
|
20
|
+
group: "internal";
|
|
21
|
+
position: "before";
|
|
22
|
+
})[];
|
|
19
23
|
pathGroupsExcludedImportTypes: string[];
|
|
24
|
+
sortTypesGroup: true;
|
|
20
25
|
"newlines-between": "never";
|
|
21
26
|
alphabetize: {
|
|
22
27
|
order: "asc";
|
package/dist/rules/import.mjs
CHANGED
|
@@ -18,8 +18,8 @@ const importRules = {
|
|
|
18
18
|
"sibling",
|
|
19
19
|
"index",
|
|
20
20
|
"object",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"unknown",
|
|
22
|
+
"type"
|
|
23
23
|
],
|
|
24
24
|
pathGroups: [
|
|
25
25
|
{
|
|
@@ -51,9 +51,15 @@ const importRules = {
|
|
|
51
51
|
pattern: "lodash{,-es,-unified}{,/**}",
|
|
52
52
|
group: "external",
|
|
53
53
|
position: "before"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
pattern: "@/**",
|
|
57
|
+
group: "internal",
|
|
58
|
+
position: "before"
|
|
54
59
|
}
|
|
55
60
|
],
|
|
56
61
|
pathGroupsExcludedImportTypes: ["type"],
|
|
62
|
+
sortTypesGroup: true,
|
|
57
63
|
"newlines-between": "never",
|
|
58
64
|
alphabetize: {
|
|
59
65
|
order: "asc",
|
|
@@ -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// import 必须位于其他语句之前,避免模块依赖散落在执行逻辑中。\n\t\"import-x/first\": \"error\",\n\t// 合并同一模块的重复 import,避免绑定分散或副作用被误读。\n\t\"import-x/no-duplicates\": \"error\",\n\t// 非样式 import 按来源分组并排序,保持所有项目一致的模块结构。\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//
|
|
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 按来源分组并排序,保持所有项目一致的模块结构。\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// 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// 类型导入不参与自定义 pathGroups 匹配,统一保留在 type 总分组\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// 非样式副作用导入同样参与检查;样式导入由 createImportConfigs 注册的本地规则独立处理\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;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"}
|
|
@@ -34,7 +34,7 @@ declare const typescriptRules: {
|
|
|
34
34
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "error";
|
|
35
35
|
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
36
36
|
disallowTypeAnnotations: false;
|
|
37
|
-
fixStyle: "
|
|
37
|
+
fixStyle: "separate-type-imports";
|
|
38
38
|
prefer: "type-imports";
|
|
39
39
|
}];
|
|
40
40
|
};
|
|
@@ -30,7 +30,7 @@ const typescriptRules = {
|
|
|
30
30
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
31
31
|
"@typescript-eslint/consistent-type-imports": ["error", {
|
|
32
32
|
disallowTypeAnnotations: false,
|
|
33
|
-
fixStyle: "
|
|
33
|
+
fixStyle: "separate-type-imports",
|
|
34
34
|
prefer: "type-imports"
|
|
35
35
|
}]
|
|
36
36
|
};
|
|
@@ -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 * 公共模块边界要求显式类型,业务内部函数保留 TypeScript 返回类型推断;默认的\n * recommendedTypeChecked 预置负责补充类型语义检查。\n */\nexport const typescriptRules = {\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\tvarsIgnorePattern: \"^_\",\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 工具文件由末尾覆写单独放开。\n\t\"@typescript-eslint/no-require-imports\": \"error\",\n\t// 禁止普通空函数,避免遗漏实现;仅允许无函数体逻辑的构造器和有意留空的重写方法。\n\t\"@typescript-eslint/no-empty-function\": [\"error\", { allow: [\"constructors\", \"overrideMethods\"] }],\n\t// 使用 TS 版本识别类型断言等语法;允许常见的短路和三元表达式调用模式。\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// 删除可由 TypeScript 明确推断的原始值类型标注。\n\t\"@typescript-eslint/no-inferrable-types\": \"error\",\n\t// 禁止非空断言,要求显式处理空值边界。\n\t\"@typescript-eslint/no-non-null-assertion\": \"error\",\n\t// 可选链之后再做非空断言逻辑矛盾,通常表示边界条件设计有误。\n\t\"@typescript-eslint/no-non-null-asserted-optional-chain\": \"error\",\n\t//
|
|
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 * 公共模块边界要求显式类型,业务内部函数保留 TypeScript 返回类型推断;默认的\n * recommendedTypeChecked 预置负责补充类型语义检查。\n */\nexport const typescriptRules = {\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\tvarsIgnorePattern: \"^_\",\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 工具文件由末尾覆写单独放开。\n\t\"@typescript-eslint/no-require-imports\": \"error\",\n\t// 禁止普通空函数,避免遗漏实现;仅允许无函数体逻辑的构造器和有意留空的重写方法。\n\t\"@typescript-eslint/no-empty-function\": [\"error\", { allow: [\"constructors\", \"overrideMethods\"] }],\n\t// 使用 TS 版本识别类型断言等语法;允许常见的短路和三元表达式调用模式。\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// 删除可由 TypeScript 明确推断的原始值类型标注。\n\t\"@typescript-eslint/no-inferrable-types\": \"error\",\n\t// 禁止非空断言,要求显式处理空值边界。\n\t\"@typescript-eslint/no-non-null-assertion\": \"error\",\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} satisfies RuleOptions;\n\n/** 仅在 Project Service 提供完整类型信息后应用的 TypeScript 类型感知规则覆写。 */\nexport const typescriptTypeCheckedRules = {\n\t// 默认 in-try-catch 模式:try/catch/finally 内要求 return await,让本地错误处理捕获 Promise 拒绝;其他位置避免多余 await。\n\t\"@typescript-eslint/return-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,qDAAqD,CAAC,SAAS,EAAE,oCAAoC,MAAM,CAAC;CAE5G,mCAAmC;CAEnC,qCAAqC,CACpC,SACA;EACC,MAAM;EACN,mBAAmB;EACnB,cAAc;EACd,2BAA2B;EAC3B,oBAAoB;EACpB,mBAAmB;CACpB,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;CAE1C,4CAA4C;CAE5C,0DAA0D;CAE1D,8CAA8C,CAC7C,SACA;EACC,yBAAyB;EACzB,UAAU;EACV,QAAQ;CACT,CACD;AACD;;AAGA,MAAa,6BAA6B;CAEzC,mCAAmC;CAEnC,mDAAmD,CAAC,SAAS,EAAE,sBAAsB,KAAK,CAAC;AAC5F"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# 工程质量审查报告
|
|
2
2
|
|
|
3
|
-
审查日期:2026-08-
|
|
3
|
+
审查日期:2026-08-30
|
|
4
4
|
|
|
5
|
-
审查对象:`@fast-china/eslint-config` 2.1.
|
|
5
|
+
审查对象:`@fast-china/eslint-config` 2.1.4 工作区
|
|
6
6
|
|
|
7
7
|
## 结论
|
|
8
8
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
## 当前规则模型
|
|
12
12
|
|
|
13
13
|
- JavaScript、TypeScript、Import 和 RegExp 只有一套共享规则。
|
|
14
|
+
- `@/**` 根别名归入 internal;类型导入位于所有其他非样式导入之后,并在 type 总分组内按来源层级排序。
|
|
14
15
|
- 样式导入由独立规则约束为最后一个连续分组,不参与普通 import 字母排序,也不提供自动修复。
|
|
15
16
|
- TypeScript、Vue 和 React TypeScript 始终使用 `recommendedTypeChecked` 与 Project Service。
|
|
16
17
|
- Vue 使用 `flat/recommended`,并叠加事件声明、kebab-case 属性、闭合标签和排序规则。
|
package/docs/rules-risk.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Default Rules and Risk Guide
|
|
2
2
|
|
|
3
|
-
This document describes the current 2.1.
|
|
3
|
+
This document describes the current 2.1.4 configuration model, major rules, and migration risks. Source comments explain current intent only; historical changes belong in `CHANGELOG.md`.
|
|
4
4
|
|
|
5
5
|
## Configuration model
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ The root entry is a fixed Vue 3 + TypeScript + UniApp preset:
|
|
|
43
43
|
- `prefer-arrow-callback`, `logical-assignment-operators`, and `prefer-object-spread` are errors.
|
|
44
44
|
- `prefer-exponentiation-operator` and `prefer-object-has-own` are errors.
|
|
45
45
|
- `sort-imports` warns and only sorts members within one import.
|
|
46
|
-
- `import-x/order` is an error with `warnOnUnassignedImports: true`;
|
|
46
|
+
- `import-x/order` is an error with `warnOnUnassignedImports: true` and `sortTypesGroup: true`; `@/**` belongs to `internal`, type imports follow every non-style import and retain source-category ordering inside the final type group, and stylesheet imports do not participate in this rule.
|
|
47
47
|
- `import-x/style-imports-last` is an error; CSS, SCSS, LESS, and related styles must form the final contiguous import group, with their internal order preserved and no automatic fix.
|
|
48
48
|
|
|
49
49
|
### TypeScript
|
|
@@ -54,7 +54,7 @@ The root entry is a fixed Vue 3 + TypeScript + UniApp preset:
|
|
|
54
54
|
- `no-explicit-any` warns.
|
|
55
55
|
- `no-unused-vars` is an error; an `_` prefix marks intentional omissions and rest siblings are ignored.
|
|
56
56
|
- `no-empty-function` only allows empty constructors and override methods.
|
|
57
|
-
- `consistent-type-imports`
|
|
57
|
+
- `consistent-type-imports` fixes type-only dependencies as separate `import type` declarations.
|
|
58
58
|
- `no-non-null-assertion` is an error.
|
|
59
59
|
|
|
60
60
|
### Vue
|
|
@@ -82,8 +82,8 @@ ESLint does not execute conditional compilation, so `wx`, `plus`, and similar ob
|
|
|
82
82
|
|
|
83
83
|
Review these fixes carefully:
|
|
84
84
|
|
|
85
|
-
- Import groups, member order, and side-effect import placement.
|
|
86
|
-
-
|
|
85
|
+
- Import groups, type-source categories, member order, and side-effect import placement.
|
|
86
|
+
- Separate TypeScript `import type` declarations.
|
|
87
87
|
- Vue attribute naming and ordering.
|
|
88
88
|
- `package.json` and `tsconfig*.json` key order.
|
|
89
89
|
|
package/docs/rules-risk.zh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 默认规则与风险指南
|
|
2
2
|
|
|
3
|
-
本文说明 2.1.
|
|
3
|
+
本文说明 2.1.4 当前配置模型、主要规则和迁移风险。规则源码注释只解释现行意图;历史差异统一记录在 `CHANGELOG.md`。
|
|
4
4
|
|
|
5
5
|
## 配置模型
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ SDK、OA、Admin、Vue Web 与 UniApp 客户端共享同一套 JavaScript、Type
|
|
|
43
43
|
- `prefer-arrow-callback`、`logical-assignment-operators`、`prefer-object-spread` 为 `error`。
|
|
44
44
|
- `prefer-exponentiation-operator`、`prefer-object-has-own` 为 `error`。
|
|
45
45
|
- `sort-imports` 为 `warn`,只排序同一 import 的成员。
|
|
46
|
-
- `import-x/order` 为 `error`,并设置 `warnOnUnassignedImports: true
|
|
46
|
+
- `import-x/order` 为 `error`,并设置 `warnOnUnassignedImports: true` 和 `sortTypesGroup: true`;`@/**` 归入 `internal`,类型导入位于所有非样式导入之后并在 `type` 总分组内按来源层级排序,样式导入不参与该规则。
|
|
47
47
|
- `import-x/style-imports-last` 为 `error`;CSS、SCSS、LESS 等样式必须形成最后一个连续导入分组,组内顺序保持不变且不自动修复。
|
|
48
48
|
|
|
49
49
|
### TypeScript
|
|
@@ -54,7 +54,7 @@ SDK、OA、Admin、Vue Web 与 UniApp 客户端共享同一套 JavaScript、Type
|
|
|
54
54
|
- `no-explicit-any` 为 `warn`。
|
|
55
55
|
- `no-unused-vars` 为 `error`;`_` 前缀表示有意忽略,rest siblings 不误报。
|
|
56
56
|
- `no-empty-function` 仅允许空构造函数和空覆写方法。
|
|
57
|
-
- `consistent-type-imports`
|
|
57
|
+
- `consistent-type-imports` 使用独立 `import type` 修复形式。
|
|
58
58
|
- `no-non-null-assertion` 为 `error`。
|
|
59
59
|
|
|
60
60
|
### Vue
|
|
@@ -82,8 +82,8 @@ ESLint 不执行条件编译,因此 `wx`、`plus` 等对象在根入口处理
|
|
|
82
82
|
|
|
83
83
|
重点审查以下自动修复:
|
|
84
84
|
|
|
85
|
-
- Import
|
|
86
|
-
- TypeScript
|
|
85
|
+
- Import 分组、类型来源层级、成员顺序和副作用导入位置。
|
|
86
|
+
- TypeScript 独立 `import type` 声明。
|
|
87
87
|
- Vue 属性命名与排序。
|
|
88
88
|
- `package.json` 和 `tsconfig*.json` 字段顺序。
|
|
89
89
|
|
package/package.json
CHANGED