@fast-china/eslint-config 2.1.0 → 2.1.1
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 +7 -0
- package/dist/configs/import.mjs +10 -2
- package/dist/configs/import.mjs.map +1 -1
- package/dist/plugins/import.mjs +61 -0
- package/dist/plugins/import.mjs.map +1 -0
- package/dist/rules/import.mjs.map +1 -1
- package/dist/typegen.d.mts +4 -0
- package/docs/engineering-audit.zh.md +3 -2
- package/docs/rules-risk.md +3 -2
- package/docs/rules-risk.zh.md +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,9 +6,16 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 2.1.1 - 2026-08-29
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added `import-x/style-imports-last` to require one final, stable stylesheet import group without automatic reordering.
|
|
14
|
+
|
|
9
15
|
### Changed
|
|
10
16
|
|
|
11
17
|
- Expanded the inline documentation for local ESLint rules and scoped overrides, including their purpose, important exceptions, and ownership of duplicate React checks.
|
|
18
|
+
- Excluded stylesheet imports from `import-x/order` while preserving its grouping, alphabetizing, and `warnOnUnassignedImports` checks for all other imports.
|
|
12
19
|
|
|
13
20
|
## 2.1.0 - 2026-08-26
|
|
14
21
|
|
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"}
|
|
@@ -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"}
|
|
@@ -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// 类型导入不参与 pathGroups 匹配,始终保留在 type 分组\n\t\t\tpathGroupsExcludedImportTypes: [\"type\"],\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//
|
|
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// 所有 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,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"}
|
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.1 工作区
|
|
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.1 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`; it still checks ordinary side-effect imports, while 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
|
|
package/docs/rules-risk.zh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 默认规则与风险指南
|
|
2
2
|
|
|
3
|
-
本文说明 2.1.
|
|
3
|
+
本文说明 2.1.1 当前配置模型、主要规则和迁移风险。规则源码注释只解释现行意图;历史差异统一记录在 `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`;它继续检查普通副作用导入,但样式导入不参与该规则。
|
|
47
|
+
- `import-x/style-imports-last` 为 `error`;CSS、SCSS、LESS 等样式必须形成最后一个连续导入分组,组内顺序保持不变且不自动修复。
|
|
47
48
|
|
|
48
49
|
### TypeScript
|
|
49
50
|
|
package/package.json
CHANGED