@fast-china/eslint-config 2.1.0 → 2.1.3
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 +19 -0
- package/dist/configs/import.mjs +10 -2
- package/dist/configs/import.mjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/import.mjs +61 -0
- package/dist/plugins/import.mjs.map +1 -0
- package/dist/rules/import.d.mts +1 -0
- package/dist/rules/import.mjs +1 -0
- 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/dist/typegen.d.mts +4 -0
- package/docs/engineering-audit.zh.md +3 -2
- package/docs/rules-risk.md +6 -5
- package/docs/rules-risk.zh.md +6 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,9 +6,28 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 2.1.3 - 2026-08-29
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Enabled `import-x/order` `sortTypesGroup` so separate type imports retain the final type group while sorting by their original source category within it.
|
|
14
|
+
|
|
15
|
+
## 2.1.2 - 2026-08-29
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Changed `@typescript-eslint/consistent-type-imports` fixes from inline type specifiers to separate `import type` declarations.
|
|
20
|
+
|
|
21
|
+
## 2.1.1 - 2026-08-29
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Added `import-x/style-imports-last` to require one final, stable stylesheet import group without automatic reordering.
|
|
26
|
+
|
|
9
27
|
### Changed
|
|
10
28
|
|
|
11
29
|
- Expanded the inline documentation for local ESLint rules and scoped overrides, including their purpose, important exceptions, and ownership of duplicate React checks.
|
|
30
|
+
- Excluded stylesheet imports from `import-x/order` while preserving its grouping, alphabetizing, and `warnOnUnassignedImports` checks for all other imports.
|
|
12
31
|
|
|
13
32
|
## 2.1.0 - 2026-08-26
|
|
14
33
|
|
package/dist/configs/import.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { GLOBS_CODE } from "../constants/index.mjs";
|
|
2
2
|
import { importRules } from "../rules/import.mjs";
|
|
3
|
+
import { styleAwareImportXPlugin } from "../plugins/import.mjs";
|
|
3
4
|
import { defineConfig } from "eslint/config";
|
|
4
5
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
5
6
|
//#region src/configs/import.ts
|
|
7
|
+
const importXRecommended = {
|
|
8
|
+
...eslintPluginImportX.flatConfigs.recommended,
|
|
9
|
+
plugins: { "import-x": styleAwareImportXPlugin }
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
12
|
* 创建模块导入规则配置。
|
|
8
13
|
*
|
|
@@ -16,8 +21,11 @@ import eslintPluginImportX from "eslint-plugin-import-x";
|
|
|
16
21
|
const createImportConfigs = (files = GLOBS_CODE) => defineConfig([{
|
|
17
22
|
name: "@fast-china/import",
|
|
18
23
|
files: [...files],
|
|
19
|
-
extends: [
|
|
20
|
-
rules:
|
|
24
|
+
extends: [importXRecommended],
|
|
25
|
+
rules: {
|
|
26
|
+
...importRules,
|
|
27
|
+
"import-x/style-imports-last": "error"
|
|
28
|
+
}
|
|
21
29
|
}]);
|
|
22
30
|
//#endregion
|
|
23
31
|
export { createImportConfigs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/configs/import.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginImportX from \"eslint-plugin-import-x\";\nimport { GLOBS_CODE } from \"../constants\";\nimport { importRules } from \"../rules\";\n\n/**\n * 创建模块导入规则配置。\n *\n * @remarks\n * 共享库不猜测项目的路径别名或解析器,因此只继承 import-x 的推荐能力,\n * 与 resolver 强耦合且容易误报的规则会在本地规则记录中显式关闭。\n *\n * @param files - 应用 import-x 推荐规则与本地覆盖规则的 ESLint glob 列表。\n * @returns 包含 import-x 插件预置和本地规则的 Flat Config 数组。\n */\nexport const createImportConfigs = (files: readonly string[] = GLOBS_CODE): ReturnType<typeof defineConfig> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/import\",\n\t\t\tfiles: [...files],\n\t\t\textends: [
|
|
1
|
+
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/configs/import.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginImportX from \"eslint-plugin-import-x\";\nimport { GLOBS_CODE } from \"../constants\";\nimport { styleAwareImportXPlugin } from \"../plugins/import\";\nimport { importRules } from \"../rules\";\nimport type { ESLint } from \"eslint\";\n\nconst importXRecommended = {\n\t...eslintPluginImportX.flatConfigs.recommended,\n\tplugins: {\n\t\t// import-x 当前发布类型仍基于旧版 RuleContext;运行时接口与 ESLint 10 Flat Config 兼容。\n\t\t\"import-x\": styleAwareImportXPlugin as unknown as ESLint.Plugin,\n\t},\n};\n\n/**\n * 创建模块导入规则配置。\n *\n * @remarks\n * 共享库不猜测项目的路径别名或解析器,因此只继承 import-x 的推荐能力,\n * 与 resolver 强耦合且容易误报的规则会在本地规则记录中显式关闭。\n *\n * @param files - 应用 import-x 推荐规则与本地覆盖规则的 ESLint glob 列表。\n * @returns 包含 import-x 插件预置和本地规则的 Flat Config 数组。\n */\nexport const createImportConfigs = (files: readonly string[] = GLOBS_CODE): ReturnType<typeof defineConfig> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/import\",\n\t\t\tfiles: [...files],\n\t\t\textends: [importXRecommended],\n\t\t\trules: {\n\t\t\t\t...importRules,\n\t\t\t\t// 样式导入必须形成最后一个连续分组;规则不提供修复,避免改变 CSS 层叠顺序。\n\t\t\t\t\"import-x/style-imports-last\": \"error\",\n\t\t\t},\n\t\t},\n\t]);\n"],"mappings":";;;;;;AAOA,MAAM,qBAAqB;CAC1B,GAAG,oBAAoB,YAAY;CACnC,SAAS,EAER,YAAY,wBACb;AACD;;;;;;;;;;;AAYA,MAAa,uBAAuB,QAA2B,eAC9D,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,SAAS,CAAC,kBAAkB;CAC5B,OAAO;EACN,GAAG;EAEH,+BAA+B;CAChC;AACD,CACD,CAAC"}
|
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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
2
|
+
//#region src/plugins/import.ts
|
|
3
|
+
const STYLE_IMPORT_PATTERN = /\.(?:acss|css|less|pcss|postcss|sass|scss|sss|styl|stylus|ttss|wxss)(?:[?#].*)?$/i;
|
|
4
|
+
const isStyleImport = (source) => typeof source === "string" && STYLE_IMPORT_PATTERN.test(source);
|
|
5
|
+
const importOrderRule = eslintPluginImportX.rules.order;
|
|
6
|
+
if (importOrderRule === void 0) throw new Error("eslint-plugin-import-x does not provide the order rule.");
|
|
7
|
+
/**
|
|
8
|
+
* 复用 import-x/order 的全部行为,但把样式导入交给 style-imports-last 独立处理。
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* import-x/order 没有按路径忽略导入的选项。如果让样式继续进入该规则,全局
|
|
12
|
+
* alphabetize 会改变样式的层叠顺序,因此只过滤静态样式 import,其他副作用导入仍受
|
|
13
|
+
* warnOnUnassignedImports 约束。
|
|
14
|
+
*/
|
|
15
|
+
const importOrderWithoutStylesRule = {
|
|
16
|
+
...importOrderRule,
|
|
17
|
+
create(context) {
|
|
18
|
+
const listeners = importOrderRule.create(context);
|
|
19
|
+
const checkImport = listeners.ImportDeclaration;
|
|
20
|
+
return {
|
|
21
|
+
...listeners,
|
|
22
|
+
ImportDeclaration(node) {
|
|
23
|
+
if (!isStyleImport(node.source.value)) checkImport?.(node);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** 只要求样式导入形成文件顶部 import 区域的最后一个连续分组,不改变组内顺序。 */
|
|
29
|
+
const styleImportsLastRule = {
|
|
30
|
+
meta: {
|
|
31
|
+
type: "suggestion",
|
|
32
|
+
docs: { description: "Require stylesheet imports to form the final contiguous import group without sorting them." },
|
|
33
|
+
schema: [],
|
|
34
|
+
messages: { styleImportsLast: "Style import `{{source}}` must occur after all non-style imports." }
|
|
35
|
+
},
|
|
36
|
+
create(context) {
|
|
37
|
+
return { Program(node) {
|
|
38
|
+
const imports = node.body.filter((statement) => statement.type === "ImportDeclaration");
|
|
39
|
+
let lastNonStyleImportIndex = -1;
|
|
40
|
+
for (const [index, statement] of imports.entries()) if (!isStyleImport(statement.source.value)) lastNonStyleImportIndex = index;
|
|
41
|
+
for (const statement of imports.slice(0, lastNonStyleImportIndex)) if (isStyleImport(statement.source.value)) context.report({
|
|
42
|
+
node: statement,
|
|
43
|
+
messageId: "styleImportsLast",
|
|
44
|
+
data: { source: statement.source.value }
|
|
45
|
+
});
|
|
46
|
+
} };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/** import-x 插件适配:样式导入不参与 import-x/order,其他规则保持上游实现。 */
|
|
50
|
+
const styleAwareImportXPlugin = {
|
|
51
|
+
...eslintPluginImportX,
|
|
52
|
+
rules: {
|
|
53
|
+
...eslintPluginImportX.rules,
|
|
54
|
+
order: importOrderWithoutStylesRule,
|
|
55
|
+
"style-imports-last": styleImportsLastRule
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { styleAwareImportXPlugin };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=import.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/plugins/import.ts"],"sourcesContent":["import eslintPluginImportX from \"eslint-plugin-import-x\";\nimport type { Rule } from \"eslint\";\n\nconst STYLE_IMPORT_PATTERN = /\\.(?:acss|css|less|pcss|postcss|sass|scss|sss|styl|stylus|ttss|wxss)(?:[?#].*)?$/i;\n\nconst isStyleImport = (source: unknown): source is string => typeof source === \"string\" && STYLE_IMPORT_PATTERN.test(source);\n\nconst importOrderRule = eslintPluginImportX.rules.order;\n\nif (importOrderRule === undefined) {\n\tthrow new Error(\"eslint-plugin-import-x does not provide the order rule.\");\n}\n\n/**\n * 复用 import-x/order 的全部行为,但把样式导入交给 style-imports-last 独立处理。\n *\n * @remarks\n * import-x/order 没有按路径忽略导入的选项。如果让样式继续进入该规则,全局\n * alphabetize 会改变样式的层叠顺序,因此只过滤静态样式 import,其他副作用导入仍受\n * warnOnUnassignedImports 约束。\n */\nconst importOrderWithoutStylesRule: typeof importOrderRule = {\n\t...importOrderRule,\n\tcreate(context) {\n\t\tconst listeners = importOrderRule.create(context);\n\t\tconst checkImport = listeners.ImportDeclaration;\n\n\t\treturn {\n\t\t\t...listeners,\n\t\t\tImportDeclaration(node) {\n\t\t\t\tif (!isStyleImport(node.source.value)) {\n\t\t\t\t\tcheckImport?.(node);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n};\n\n/** 只要求样式导入形成文件顶部 import 区域的最后一个连续分组,不改变组内顺序。 */\nconst styleImportsLastRule: Rule.RuleModule = {\n\tmeta: {\n\t\ttype: \"suggestion\",\n\t\tdocs: {\n\t\t\tdescription: \"Require stylesheet imports to form the final contiguous import group without sorting them.\",\n\t\t},\n\t\tschema: [],\n\t\tmessages: {\n\t\t\tstyleImportsLast: \"Style import `{{source}}` must occur after all non-style imports.\",\n\t\t},\n\t},\n\tcreate(context) {\n\t\treturn {\n\t\t\tProgram(node) {\n\t\t\t\tconst imports = node.body.filter((statement) => statement.type === \"ImportDeclaration\");\n\t\t\t\tlet lastNonStyleImportIndex = -1;\n\n\t\t\t\tfor (const [index, statement] of imports.entries()) {\n\t\t\t\t\tif (!isStyleImport(statement.source.value)) {\n\t\t\t\t\t\tlastNonStyleImportIndex = index;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const statement of imports.slice(0, lastNonStyleImportIndex)) {\n\t\t\t\t\tif (isStyleImport(statement.source.value)) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode: statement,\n\t\t\t\t\t\t\tmessageId: \"styleImportsLast\",\n\t\t\t\t\t\t\tdata: { source: statement.source.value },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n};\n\n/** import-x 插件适配:样式导入不参与 import-x/order,其他规则保持上游实现。 */\nexport const styleAwareImportXPlugin = {\n\t...eslintPluginImportX,\n\trules: {\n\t\t...eslintPluginImportX.rules,\n\t\torder: importOrderWithoutStylesRule,\n\t\t\"style-imports-last\": styleImportsLastRule,\n\t},\n};\n"],"mappings":";;AAGA,MAAM,uBAAuB;AAE7B,MAAM,iBAAiB,WAAsC,OAAO,WAAW,YAAY,qBAAqB,KAAK,MAAM;AAE3H,MAAM,kBAAkB,oBAAoB,MAAM;AAElD,IAAI,oBAAoB,KAAA,GACvB,MAAM,IAAI,MAAM,yDAAyD;;;;;;;;;AAW1E,MAAM,+BAAuD;CAC5D,GAAG;CACH,OAAO,SAAS;EACf,MAAM,YAAY,gBAAgB,OAAO,OAAO;EAChD,MAAM,cAAc,UAAU;EAE9B,OAAO;GACN,GAAG;GACH,kBAAkB,MAAM;IACvB,IAAI,CAAC,cAAc,KAAK,OAAO,KAAK,GACnC,cAAc,IAAI;GAEpB;EACD;CACD;AACD;;AAGA,MAAM,uBAAwC;CAC7C,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,6FACd;EACA,QAAQ,CAAC;EACT,UAAU,EACT,kBAAkB,oEACnB;CACD;CACA,OAAO,SAAS;EACf,OAAO,EACN,QAAQ,MAAM;GACb,MAAM,UAAU,KAAK,KAAK,QAAQ,cAAc,UAAU,SAAS,mBAAmB;GACtF,IAAI,0BAA0B;GAE9B,KAAK,MAAM,CAAC,OAAO,cAAc,QAAQ,QAAQ,GAChD,IAAI,CAAC,cAAc,UAAU,OAAO,KAAK,GACxC,0BAA0B;GAI5B,KAAK,MAAM,aAAa,QAAQ,MAAM,GAAG,uBAAuB,GAC/D,IAAI,cAAc,UAAU,OAAO,KAAK,GACvC,QAAQ,OAAO;IACd,MAAM;IACN,WAAW;IACX,MAAM,EAAE,QAAQ,UAAU,OAAO,MAAM;GACxC,CAAC;EAGJ,EACD;CACD;AACD;;AAGA,MAAa,0BAA0B;CACtC,GAAG;CACH,OAAO;EACN,GAAG,oBAAoB;EACvB,OAAO;EACP,sBAAsB;CACvB;AACD"}
|
package/dist/rules/import.d.mts
CHANGED
package/dist/rules/import.mjs
CHANGED
|
@@ -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// 按来源分组并排序,保持所有项目一致的模块结构。\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// TypeScript 类型导入\n\t\t\t\t\"type\",\n\t\t\t\t// 无法识别分类的导入\n\t\t\t\t\"unknown\",\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],\n\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// TypeScript 类型导入\n\t\t\t\t\"type\",\n\t\t\t\t// 无法识别分类的导入\n\t\t\t\t\"unknown\",\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],\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;EACjF;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"}
|
package/dist/typegen.d.mts
CHANGED
|
@@ -2333,6 +2333,10 @@ interface RuleOptions {
|
|
|
2333
2333
|
* @see https://github.com/un-ts/eslint-plugin-import-x/blob/v4.17.1/docs/rules/prefer-namespace-import.md
|
|
2334
2334
|
*/
|
|
2335
2335
|
'import-x/prefer-namespace-import'?: Linter.RuleEntry<ImportXPreferNamespaceImport>;
|
|
2336
|
+
/**
|
|
2337
|
+
* Require stylesheet imports to form the final contiguous import group without sorting them.
|
|
2338
|
+
*/
|
|
2339
|
+
'import-x/style-imports-last'?: Linter.RuleEntry<[]>;
|
|
2336
2340
|
/**
|
|
2337
2341
|
* Forbid potentially ambiguous parse goal (`script` vs. `module`).
|
|
2338
2342
|
* @see https://github.com/un-ts/eslint-plugin-import-x/blob/v4.17.1/docs/rules/unambiguous.md
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# 工程质量审查报告
|
|
2
2
|
|
|
3
|
-
审查日期:2026-08-
|
|
3
|
+
审查日期:2026-08-29
|
|
4
4
|
|
|
5
|
-
审查对象:`@fast-china/eslint-config` 2.1.
|
|
5
|
+
审查对象:`@fast-china/eslint-config` 2.1.3 工作区
|
|
6
6
|
|
|
7
7
|
## 结论
|
|
8
8
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
## 当前规则模型
|
|
12
12
|
|
|
13
13
|
- JavaScript、TypeScript、Import 和 RegExp 只有一套共享规则。
|
|
14
|
+
- 样式导入由独立规则约束为最后一个连续分组,不参与普通 import 字母排序,也不提供自动修复。
|
|
14
15
|
- TypeScript、Vue 和 React TypeScript 始终使用 `recommendedTypeChecked` 与 Project Service。
|
|
15
16
|
- Vue 使用 `flat/recommended`,并叠加事件声明、kebab-case 属性、闭合标签和排序规则。
|
|
16
17
|
- RegExp 使用显式审查过的正确性与安全规则,不继承完整偏好型推荐集合。
|
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.3 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,8 @@ 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`; ordinary side-effect imports remain checked, type imports are ordered by source category inside the final type group, and stylesheet imports do not participate in this rule.
|
|
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.
|
|
47
48
|
|
|
48
49
|
### TypeScript
|
|
49
50
|
|
|
@@ -53,7 +54,7 @@ The root entry is a fixed Vue 3 + TypeScript + UniApp preset:
|
|
|
53
54
|
- `no-explicit-any` warns.
|
|
54
55
|
- `no-unused-vars` is an error; an `_` prefix marks intentional omissions and rest siblings are ignored.
|
|
55
56
|
- `no-empty-function` only allows empty constructors and override methods.
|
|
56
|
-
- `consistent-type-imports`
|
|
57
|
+
- `consistent-type-imports` fixes type-only dependencies as separate `import type` declarations.
|
|
57
58
|
- `no-non-null-assertion` is an error.
|
|
58
59
|
|
|
59
60
|
### Vue
|
|
@@ -81,8 +82,8 @@ ESLint does not execute conditional compilation, so `wx`, `plus`, and similar ob
|
|
|
81
82
|
|
|
82
83
|
Review these fixes carefully:
|
|
83
84
|
|
|
84
|
-
- Import groups, member order, and side-effect import placement.
|
|
85
|
-
-
|
|
85
|
+
- Import groups, type-source categories, member order, and side-effect import placement.
|
|
86
|
+
- Separate TypeScript `import type` declarations.
|
|
86
87
|
- Vue attribute naming and ordering.
|
|
87
88
|
- `package.json` and `tsconfig*.json` key order.
|
|
88
89
|
|
package/docs/rules-risk.zh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 默认规则与风险指南
|
|
2
2
|
|
|
3
|
-
本文说明 2.1.
|
|
3
|
+
本文说明 2.1.3 当前配置模型、主要规则和迁移风险。规则源码注释只解释现行意图;历史差异统一记录在 `CHANGELOG.md`。
|
|
4
4
|
|
|
5
5
|
## 配置模型
|
|
6
6
|
|
|
@@ -43,7 +43,8 @@ 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`;普通副作用导入继续受检,类型导入在 `type` 总分组内按来源层级排序,样式导入不参与该规则。
|
|
47
|
+
- `import-x/style-imports-last` 为 `error`;CSS、SCSS、LESS 等样式必须形成最后一个连续导入分组,组内顺序保持不变且不自动修复。
|
|
47
48
|
|
|
48
49
|
### TypeScript
|
|
49
50
|
|
|
@@ -53,7 +54,7 @@ SDK、OA、Admin、Vue Web 与 UniApp 客户端共享同一套 JavaScript、Type
|
|
|
53
54
|
- `no-explicit-any` 为 `warn`。
|
|
54
55
|
- `no-unused-vars` 为 `error`;`_` 前缀表示有意忽略,rest siblings 不误报。
|
|
55
56
|
- `no-empty-function` 仅允许空构造函数和空覆写方法。
|
|
56
|
-
- `consistent-type-imports`
|
|
57
|
+
- `consistent-type-imports` 使用独立 `import type` 修复形式。
|
|
57
58
|
- `no-non-null-assertion` 为 `error`。
|
|
58
59
|
|
|
59
60
|
### Vue
|
|
@@ -81,8 +82,8 @@ ESLint 不执行条件编译,因此 `wx`、`plus` 等对象在根入口处理
|
|
|
81
82
|
|
|
82
83
|
重点审查以下自动修复:
|
|
83
84
|
|
|
84
|
-
- Import
|
|
85
|
-
- TypeScript
|
|
85
|
+
- Import 分组、类型来源层级、成员顺序和副作用导入位置。
|
|
86
|
+
- TypeScript 独立 `import type` 声明。
|
|
86
87
|
- Vue 属性命名与排序。
|
|
87
88
|
- `package.json` 和 `tsconfig*.json` 字段顺序。
|
|
88
89
|
|
package/package.json
CHANGED