@fast-china/eslint-config 2.0.2 → 2.0.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 +23 -1
- package/README.md +77 -18
- package/README.zh.md +77 -18
- package/dist/configs/angular.d.mts +41 -0
- package/dist/configs/angular.d.mts.map +1 -0
- package/dist/configs/angular.mjs +33 -0
- package/dist/configs/angular.mjs.map +1 -0
- package/dist/configs/common.d.mts +11 -0
- package/dist/configs/common.d.mts.map +1 -0
- package/dist/configs/common.mjs +20 -0
- package/dist/configs/common.mjs.map +1 -0
- package/dist/configs/environment.d.mts +61 -0
- package/dist/configs/environment.d.mts.map +1 -0
- package/dist/configs/environment.mjs +33 -0
- package/dist/configs/environment.mjs.map +1 -0
- package/dist/configs/ignores.d.mts +15 -0
- package/dist/configs/ignores.d.mts.map +1 -0
- package/dist/configs/ignores.mjs +32 -0
- package/dist/configs/ignores.mjs.map +1 -0
- package/dist/configs/import.d.mts +11 -0
- package/dist/configs/import.d.mts.map +1 -0
- package/dist/configs/import.mjs +21 -0
- package/dist/configs/import.mjs.map +1 -0
- package/dist/configs/index.d.mts +17 -0
- package/dist/configs/index.mjs +17 -0
- package/dist/configs/javascript.d.mts +10 -0
- package/dist/configs/javascript.d.mts.map +1 -0
- package/dist/configs/javascript.mjs +24 -0
- package/dist/configs/javascript.mjs.map +1 -0
- package/dist/configs/json.d.mts +10 -0
- package/dist/configs/json.d.mts.map +1 -0
- package/dist/configs/json.mjs +35 -0
- package/dist/configs/json.mjs.map +1 -0
- package/dist/configs/lodash.d.mts +12 -0
- package/dist/configs/lodash.d.mts.map +1 -0
- package/dist/configs/lodash.mjs +18 -0
- package/dist/configs/lodash.mjs.map +1 -0
- package/dist/configs/markdown.d.mts +10 -0
- package/dist/configs/markdown.d.mts.map +1 -0
- package/dist/configs/markdown.mjs +18 -0
- package/dist/configs/markdown.mjs.map +1 -0
- package/dist/configs/prettier.d.mts +11 -0
- package/dist/configs/prettier.d.mts.map +1 -0
- package/dist/configs/prettier.mjs +17 -0
- package/dist/configs/prettier.mjs.map +1 -0
- package/dist/configs/react.d.mts +86 -0
- package/dist/configs/react.d.mts.map +1 -0
- package/dist/configs/react.mjs +31 -0
- package/dist/configs/react.mjs.map +1 -0
- package/dist/configs/regexp.d.mts +11 -0
- package/dist/configs/regexp.d.mts.map +1 -0
- package/dist/configs/regexp.mjs +19 -0
- package/dist/configs/regexp.mjs.map +1 -0
- package/dist/configs/sort-package.d.mts +11 -0
- package/dist/configs/sort-package.d.mts.map +1 -0
- package/dist/configs/sort-package.mjs +18 -0
- package/dist/configs/sort-package.mjs.map +1 -0
- package/dist/configs/sort-tsconfig.d.mts +10 -0
- package/dist/configs/sort-tsconfig.d.mts.map +1 -0
- package/dist/configs/sort-tsconfig.mjs +18 -0
- package/dist/configs/sort-tsconfig.mjs.map +1 -0
- package/dist/configs/typescript.d.mts +60 -0
- package/dist/configs/typescript.d.mts.map +1 -0
- package/dist/configs/typescript.mjs +44 -0
- package/dist/configs/typescript.mjs.map +1 -0
- package/dist/configs/vue.d.mts +43 -0
- package/dist/configs/vue.d.mts.map +1 -0
- package/dist/configs/vue.mjs +50 -0
- package/dist/configs/vue.mjs.map +1 -0
- package/dist/constants/index.d.mts +34 -0
- package/dist/constants/index.d.mts.map +1 -0
- package/dist/constants/index.mjs +52 -0
- package/dist/constants/index.mjs.map +1 -0
- package/dist/index.d.mts +20 -147
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -402
- package/dist/index.mjs.map +1 -1
- package/dist/rules/angular.d.mts +46 -0
- package/dist/rules/angular.d.mts.map +1 -0
- package/dist/rules/angular.mjs +47 -0
- package/dist/rules/angular.mjs.map +1 -0
- package/dist/rules/common.d.mts +32 -0
- package/dist/rules/common.d.mts.map +1 -0
- package/dist/rules/common.mjs +38 -0
- package/dist/rules/common.mjs.map +1 -0
- package/dist/rules/import.d.mts +24 -0
- package/dist/rules/import.d.mts.map +1 -0
- package/dist/rules/import.mjs +35 -0
- package/dist/rules/import.mjs.map +1 -0
- package/dist/rules/index.d.mts +12 -309
- package/dist/rules/index.mjs +10 -1
- package/dist/rules/javascript.d.mts +48 -0
- package/dist/rules/javascript.d.mts.map +1 -0
- package/dist/rules/javascript.mjs +49 -0
- package/dist/rules/javascript.mjs.map +1 -0
- package/dist/rules/lodash.d.mts +40 -0
- package/dist/rules/lodash.d.mts.map +1 -0
- package/dist/rules/lodash.mjs +43 -0
- package/dist/rules/lodash.mjs.map +1 -0
- package/dist/rules/react.d.mts +26 -0
- package/dist/rules/react.d.mts.map +1 -0
- package/dist/rules/react.mjs +27 -0
- package/dist/rules/react.mjs.map +1 -0
- package/dist/rules/sort-package.d.mts +32 -0
- package/dist/rules/sort-package.d.mts.map +1 -0
- package/dist/rules/sort-package.mjs +75 -0
- package/dist/rules/sort-package.mjs.map +1 -0
- package/dist/rules/sort-tsconfig.d.mts +20 -0
- package/dist/rules/sort-tsconfig.d.mts.map +1 -0
- package/dist/rules/sort-tsconfig.mjs +122 -0
- package/dist/rules/sort-tsconfig.mjs.map +1 -0
- package/dist/rules/typescript.d.mts +34 -0
- package/dist/rules/typescript.d.mts.map +1 -0
- package/dist/rules/typescript.mjs +35 -0
- package/dist/rules/typescript.mjs.map +1 -0
- package/dist/rules/vue.d.mts +24 -0
- package/dist/rules/vue.d.mts.map +1 -0
- package/dist/rules/vue.mjs +33 -0
- package/dist/rules/vue.mjs.map +1 -0
- package/dist/typegen.d.mts +1 -1
- package/docs/engineering-audit.zh.md +25 -23
- package/docs/rules-risk.md +3 -3
- package/docs/rules-risk.zh.md +3 -3
- package/package.json +16 -6
- package/dist/rules/index.d.mts.map +0 -1
- package/dist/rules.mjs +0 -477
- package/dist/rules.mjs.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GLOBS_TSCONFIG } from "../constants/index.mjs";
|
|
2
|
+
import { tsconfigJsonSortRules } from "../rules/sort-tsconfig.mjs";
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
4
|
+
//#region src/configs/sort-tsconfig.ts
|
|
5
|
+
/**
|
|
6
|
+
* 创建 tsconfig.json 排序配置。
|
|
7
|
+
*
|
|
8
|
+
* 排序只改变字段阅读顺序,不改变编译选项值;由于首次修复 diff 较大,默认关闭。
|
|
9
|
+
*/
|
|
10
|
+
const createTsconfigSortConfigs = () => defineConfig([{
|
|
11
|
+
name: "@fast-china/sort/tsconfig",
|
|
12
|
+
files: [...GLOBS_TSCONFIG],
|
|
13
|
+
rules: tsconfigJsonSortRules
|
|
14
|
+
}]);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { createTsconfigSortConfigs };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=sort-tsconfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-tsconfig.mjs","names":[],"sources":["../../src/configs/sort-tsconfig.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_TSCONFIG } from \"../constants\";\nimport { tsconfigJsonSortRules } from \"../rules\";\n\n/**\n * 创建 tsconfig.json 排序配置。\n *\n * 排序只改变字段阅读顺序,不改变编译选项值;由于首次修复 diff 较大,默认关闭。\n */\nexport const createTsconfigSortConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/sort/tsconfig\",\n\t\t\tfiles: [...GLOBS_TSCONFIG],\n\t\t\trules: tsconfigJsonSortRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;AAUA,MAAa,kCACZ,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,cAAc;CACzB,OAAO;AACR,CACD,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
//#region src/configs/typescript.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript 解析器、推荐预置与类型感知检查选项。
|
|
5
|
+
*
|
|
6
|
+
* 该对象通过 `fastConfig({ typescript: { ... } })` 传入。传入对象会启用 TypeScript
|
|
7
|
+
* 支持,并检查 `.ts`、`.cts`、`.mts` 与 `.tsx`。相同的类型感知状态还会传递给已启用的
|
|
8
|
+
* Vue 和 React 配置,使普通 TypeScript 文件、Vue SFC 与 TSX 使用一致的检查级别。
|
|
9
|
+
*
|
|
10
|
+
* 默认模式不读取类型信息,启动快且不要求文件属于某个 tsconfig;类型感知模式会启动
|
|
11
|
+
* typescript-eslint Project Service,能够执行更强的语义规则,但要求项目配置和执行目录
|
|
12
|
+
* 正确,并会增加首次检查时间与内存占用。
|
|
13
|
+
*/
|
|
14
|
+
interface TypeScriptConfigOptions {
|
|
15
|
+
/**
|
|
16
|
+
* 是否启用依赖完整 TypeScript 类型信息的规则。
|
|
17
|
+
*
|
|
18
|
+
* `false` 使用 typescript-eslint 的 `recommended` 与 `stylistic` 预置,不创建 TypeScript
|
|
19
|
+
* Program。`true` 切换到 `recommendedTypeChecked` 与 `stylisticTypeChecked`,并启用
|
|
20
|
+
* `parserOptions.projectService`。被检查文件通常需要包含在可发现的 tsconfig 中,否则
|
|
21
|
+
* Project Service 会报告文件不属于项目。
|
|
22
|
+
*
|
|
23
|
+
* 开启后 Vue 与 React 的 TypeScript 规则也会选择类型感知版本。大型 monorepo 建议评估
|
|
24
|
+
* lint 启动耗时和内存占用,并确保各工作区 tsconfig 边界明确。
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
typeChecked?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* typescript-eslint 查找 tsconfig 与创建 Project Service 时使用的根目录。
|
|
30
|
+
*
|
|
31
|
+
* 仅在 `typeChecked: true` 时写入解析器选项。普通单仓库通常可让 typescript-eslint 从
|
|
32
|
+
* `eslint.config.*` 调用栈推断;复杂 monorepo、共享配置包装层或从其他目录启动 ESLint
|
|
33
|
+
* 时,建议传入配置文件所在目录的绝对路径,例如 `import.meta.dirname`,避免发现错误的
|
|
34
|
+
* tsconfig 或跨越预期的项目边界。
|
|
35
|
+
* @default undefined
|
|
36
|
+
*/
|
|
37
|
+
tsconfigRootDir?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 返回 typescript-eslint 推荐预置。
|
|
41
|
+
*
|
|
42
|
+
* Vue SFC 需要移除上游仅匹配 `.ts` 的文件范围,否则这些关闭核心规则的配置会与
|
|
43
|
+
* `.vue` 外层范围形成不可能命中的 AND 条件。
|
|
44
|
+
*/
|
|
45
|
+
declare const getTypeScriptPresetConfigs: (typeChecked: boolean, removeFileScopes?: boolean) => Linter.Config[];
|
|
46
|
+
/** 创建启用 Project Service 时需要的解析器选项。 */
|
|
47
|
+
declare const createTypeScriptParserOptions: ({ typeChecked, tsconfigRootDir }?: TypeScriptConfigOptions) => {
|
|
48
|
+
tsconfigRootDir?: string | undefined;
|
|
49
|
+
projectService?: boolean | undefined;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 创建 TypeScript 配置。
|
|
53
|
+
*
|
|
54
|
+
* 默认采用无需类型信息的 recommended + stylistic 预置;`typeChecked: true` 会切换为
|
|
55
|
+
* 对应的类型感知预置并启动 Project Service。
|
|
56
|
+
*/
|
|
57
|
+
declare const createTypeScriptConfigs: (options?: TypeScriptConfigOptions, files?: readonly string[]) => import("eslint/config").ConfigObject[];
|
|
58
|
+
//#endregion
|
|
59
|
+
export { TypeScriptConfigOptions, createTypeScriptConfigs, createTypeScriptParserOptions, getTypeScriptPresetConfigs };
|
|
60
|
+
//# sourceMappingURL=typescript.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.mts","names":[],"sources":["../../src/configs/typescript.ts"],"mappings":";;;;;;;;;;;;;UAmBiB;;;;;;;;;;;;;EAahB;;;;;;;;;;EAUA;;;;;;;;cASY,6BAA8B,sBAAsB,+BAA2B,OAAO;;cAetF,kCAAiC,aAAA,oBAA0C;;;;;;;;;;cAW3E,0BAA2B,UAAS,yBAA8B,sDAA2C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GLOBS_TYPESCRIPT } from "../constants/index.mjs";
|
|
2
|
+
import { typescriptRules } from "../rules/typescript.mjs";
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
|
+
//#region src/configs/typescript.ts
|
|
6
|
+
/**
|
|
7
|
+
* 返回 typescript-eslint 推荐预置。
|
|
8
|
+
*
|
|
9
|
+
* Vue SFC 需要移除上游仅匹配 `.ts` 的文件范围,否则这些关闭核心规则的配置会与
|
|
10
|
+
* `.vue` 外层范围形成不可能命中的 AND 条件。
|
|
11
|
+
*/
|
|
12
|
+
const getTypeScriptPresetConfigs = (typeChecked, removeFileScopes = false) => {
|
|
13
|
+
const configs = [...typeChecked ? tseslint.configs.recommendedTypeChecked : tseslint.configs.recommended, ...typeChecked ? tseslint.configs.stylisticTypeChecked : tseslint.configs.stylistic];
|
|
14
|
+
if (!removeFileScopes) return configs;
|
|
15
|
+
return configs.map((config) => {
|
|
16
|
+
const { files: _files, ...configWithoutFiles } = config;
|
|
17
|
+
return configWithoutFiles;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
/** 创建启用 Project Service 时需要的解析器选项。 */
|
|
21
|
+
const createTypeScriptParserOptions = ({ typeChecked = false, tsconfigRootDir } = {}) => ({
|
|
22
|
+
...typeChecked ? { projectService: true } : {},
|
|
23
|
+
...typeChecked && tsconfigRootDir ? { tsconfigRootDir } : {}
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* 创建 TypeScript 配置。
|
|
27
|
+
*
|
|
28
|
+
* 默认采用无需类型信息的 recommended + stylistic 预置;`typeChecked: true` 会切换为
|
|
29
|
+
* 对应的类型感知预置并启动 Project Service。
|
|
30
|
+
*/
|
|
31
|
+
const createTypeScriptConfigs = (options = {}, files = GLOBS_TYPESCRIPT) => defineConfig([{
|
|
32
|
+
name: options.typeChecked ? "@fast-china/typescript/type-checked" : "@fast-china/typescript",
|
|
33
|
+
files: [...files],
|
|
34
|
+
extends: getTypeScriptPresetConfigs(options.typeChecked ?? false),
|
|
35
|
+
languageOptions: {
|
|
36
|
+
ecmaVersion: "latest",
|
|
37
|
+
parserOptions: createTypeScriptParserOptions(options)
|
|
38
|
+
},
|
|
39
|
+
rules: typescriptRules
|
|
40
|
+
}]);
|
|
41
|
+
//#endregion
|
|
42
|
+
export { createTypeScriptConfigs, createTypeScriptParserOptions, getTypeScriptPresetConfigs };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=typescript.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.mjs","names":[],"sources":["../../src/configs/typescript.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport tseslint from \"typescript-eslint\";\n\nimport { GLOBS_TYPESCRIPT } from \"../constants\";\nimport { typescriptRules } from \"../rules\";\n\nimport type { Linter } from \"eslint\";\n\n/**\n * TypeScript 解析器、推荐预置与类型感知检查选项。\n *\n * 该对象通过 `fastConfig({ typescript: { ... } })` 传入。传入对象会启用 TypeScript\n * 支持,并检查 `.ts`、`.cts`、`.mts` 与 `.tsx`。相同的类型感知状态还会传递给已启用的\n * Vue 和 React 配置,使普通 TypeScript 文件、Vue SFC 与 TSX 使用一致的检查级别。\n *\n * 默认模式不读取类型信息,启动快且不要求文件属于某个 tsconfig;类型感知模式会启动\n * typescript-eslint Project Service,能够执行更强的语义规则,但要求项目配置和执行目录\n * 正确,并会增加首次检查时间与内存占用。\n */\nexport interface TypeScriptConfigOptions {\n\t/**\n\t * 是否启用依赖完整 TypeScript 类型信息的规则。\n\t *\n\t * `false` 使用 typescript-eslint 的 `recommended` 与 `stylistic` 预置,不创建 TypeScript\n\t * Program。`true` 切换到 `recommendedTypeChecked` 与 `stylisticTypeChecked`,并启用\n\t * `parserOptions.projectService`。被检查文件通常需要包含在可发现的 tsconfig 中,否则\n\t * Project Service 会报告文件不属于项目。\n\t *\n\t * 开启后 Vue 与 React 的 TypeScript 规则也会选择类型感知版本。大型 monorepo 建议评估\n\t * lint 启动耗时和内存占用,并确保各工作区 tsconfig 边界明确。\n\t * @default false\n\t */\n\ttypeChecked?: boolean;\n\t/**\n\t * typescript-eslint 查找 tsconfig 与创建 Project Service 时使用的根目录。\n\t *\n\t * 仅在 `typeChecked: true` 时写入解析器选项。普通单仓库通常可让 typescript-eslint 从\n\t * `eslint.config.*` 调用栈推断;复杂 monorepo、共享配置包装层或从其他目录启动 ESLint\n\t * 时,建议传入配置文件所在目录的绝对路径,例如 `import.meta.dirname`,避免发现错误的\n\t * tsconfig 或跨越预期的项目边界。\n\t * @default undefined\n\t */\n\ttsconfigRootDir?: string;\n}\n\n/**\n * 返回 typescript-eslint 推荐预置。\n *\n * Vue SFC 需要移除上游仅匹配 `.ts` 的文件范围,否则这些关闭核心规则的配置会与\n * `.vue` 外层范围形成不可能命中的 AND 条件。\n */\nexport const getTypeScriptPresetConfigs = (typeChecked: boolean, removeFileScopes = false): Linter.Config[] => {\n\tconst configs = [\n\t\t...(typeChecked ? tseslint.configs.recommendedTypeChecked : tseslint.configs.recommended),\n\t\t...(typeChecked ? tseslint.configs.stylisticTypeChecked : tseslint.configs.stylistic),\n\t] as Linter.Config[];\n\n\tif (!removeFileScopes) return configs;\n\n\treturn configs.map((config) => {\n\t\tconst { files: _files, ...configWithoutFiles } = config;\n\t\treturn configWithoutFiles;\n\t});\n};\n\n/** 创建启用 Project Service 时需要的解析器选项。 */\nexport const createTypeScriptParserOptions = ({ typeChecked = false, tsconfigRootDir }: TypeScriptConfigOptions = {}) => ({\n\t...(typeChecked ? { projectService: true } : {}),\n\t...(typeChecked && tsconfigRootDir ? { tsconfigRootDir } : {}),\n});\n\n/**\n * 创建 TypeScript 配置。\n *\n * 默认采用无需类型信息的 recommended + stylistic 预置;`typeChecked: true` 会切换为\n * 对应的类型感知预置并启动 Project Service。\n */\nexport const createTypeScriptConfigs = (options: TypeScriptConfigOptions = {}, files: readonly string[] = GLOBS_TYPESCRIPT) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: options.typeChecked ? \"@fast-china/typescript/type-checked\" : \"@fast-china/typescript\",\n\t\t\tfiles: [...files],\n\t\t\textends: getTypeScriptPresetConfigs(options.typeChecked ?? false),\n\t\t\tlanguageOptions: {\n\t\t\t\tecmaVersion: \"latest\",\n\t\t\t\tparserOptions: createTypeScriptParserOptions(options),\n\t\t\t},\n\t\t\trules: typescriptRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;AAmDA,MAAa,8BAA8B,aAAsB,mBAAmB,UAA2B;CAC9G,MAAM,UAAU,CACf,GAAI,cAAc,SAAS,QAAQ,yBAAyB,SAAS,QAAQ,aAC7E,GAAI,cAAc,SAAS,QAAQ,uBAAuB,SAAS,QAAQ,SAC5E;CAEA,IAAI,CAAC,kBAAkB,OAAO;CAE9B,OAAO,QAAQ,KAAK,WAAW;EAC9B,MAAM,EAAE,OAAO,QAAQ,GAAG,uBAAuB;EACjD,OAAO;CACR,CAAC;AACF;;AAGA,MAAa,iCAAiC,EAAE,cAAc,OAAO,oBAA6C,CAAC,OAAO;CACzH,GAAI,cAAc,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9C,GAAI,eAAe,kBAAkB,EAAE,gBAAgB,IAAI,CAAC;AAC7D;;;;;;;AAQA,MAAa,2BAA2B,UAAmC,CAAC,GAAG,QAA2B,qBACzG,aAAa,CACZ;CACC,MAAM,QAAQ,cAAc,wCAAwC;CACpE,OAAO,CAAC,GAAG,KAAK;CAChB,SAAS,2BAA2B,QAAQ,eAAe,KAAK;CAChE,iBAAiB;EAChB,aAAa;EACb,eAAe,8BAA8B,OAAO;CACrD;CACA,OAAO;AACR,CACD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TypeScriptConfigOptions } from "./typescript.mjs";
|
|
2
|
+
//#region src/configs/vue.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Vue 3 单文件组件生成器使用的脚本语言与类型感知选项。
|
|
5
|
+
*
|
|
6
|
+
* `fastConfig()` 会根据顶层选项推导这些值;直接组合配置片段时可从 `./configs`
|
|
7
|
+
* 子路径使用该接口。
|
|
8
|
+
* 用户通过顶层 `vue` 决定是否接管 `.vue` 文件,通过顶层 `typescript` 决定 SFC 脚本
|
|
9
|
+
* 是否启用 TypeScript 解析和类型感知能力;工厂会把两者转换为此对象。
|
|
10
|
+
*
|
|
11
|
+
* Vue 模板始终由 `vue-eslint-parser` 解析。启用 TypeScript 时,它再把 `<script>` 内容
|
|
12
|
+
* 委托给 typescript-eslint parser,并复用普通 TypeScript 文件的推荐预置与解析器选项。
|
|
13
|
+
*/
|
|
14
|
+
interface VueConfigOptions {
|
|
15
|
+
/**
|
|
16
|
+
* 是否使用 typescript-eslint parser 解析 SFC 的 `<script>` 与 `<script setup>` 内容。
|
|
17
|
+
*
|
|
18
|
+
* `true` 同时加载 TypeScript 推荐规则和本库 TypeScript 规则,并允许
|
|
19
|
+
* `<script lang="ts">`;`false` 不注册 TypeScript 脚本解析器,只按 JavaScript 处理
|
|
20
|
+
* SFC 脚本。该值由顶层 `FastConfigOptions.typescript` 是否关闭推导。
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
typescript?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 与普通 TypeScript 文件共享的类型感知和 tsconfig 根目录选项。
|
|
26
|
+
*
|
|
27
|
+
* `typeChecked: true` 会让 Vue SFC 使用类型感知的 typescript-eslint 预置并启动 Project
|
|
28
|
+
* Service;`tsconfigRootDir` 会原样传给解析器。工厂只会在顶层 TypeScript 能力启用时
|
|
29
|
+
* 传入有效设置,避免 Vue 单独形成与普通 `.ts` 文件不一致的类型检查模式。
|
|
30
|
+
* @default {}
|
|
31
|
+
*/
|
|
32
|
+
typescriptOptions?: TypeScriptConfigOptions;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 创建 Vue 3 单文件组件配置。
|
|
36
|
+
*
|
|
37
|
+
* 本包只处理 Vue 3。启用 TypeScript 时,Vue 模板解析器通过 `parserOptions.parser`
|
|
38
|
+
* 委托给 typescript-eslint;这是 Vue 官方推荐的自定义脚本解析器接入方式。
|
|
39
|
+
*/
|
|
40
|
+
declare const createVueConfigs: ({ typescript, typescriptOptions }?: VueConfigOptions) => import("eslint/config").ConfigObject[];
|
|
41
|
+
//#endregion
|
|
42
|
+
export { VueConfigOptions, createVueConfigs };
|
|
43
|
+
//# sourceMappingURL=vue.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.d.mts","names":[],"sources":["../../src/configs/vue.ts"],"mappings":";;;;;;;;;;;;;UAsBiB;;;;;;;;;EAShB;;;;;;;;;EASA,oBAAoB;;;;;;;;cASR,qBAAoB,YAAA,sBAA+C,6CAAqB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { GLOB_VUE } from "../constants/index.mjs";
|
|
2
|
+
import { typescriptRules } from "../rules/typescript.mjs";
|
|
3
|
+
import { vueRules } from "../rules/vue.mjs";
|
|
4
|
+
import { createTypeScriptParserOptions, getTypeScriptPresetConfigs } from "./typescript.mjs";
|
|
5
|
+
import { defineConfig } from "eslint/config";
|
|
6
|
+
import eslint from "@eslint/js";
|
|
7
|
+
import tseslint from "typescript-eslint";
|
|
8
|
+
import eslintPluginVue from "eslint-plugin-vue";
|
|
9
|
+
import vueEslintParser from "vue-eslint-parser";
|
|
10
|
+
//#region src/configs/vue.ts
|
|
11
|
+
/**
|
|
12
|
+
* 创建 Vue 3 单文件组件配置。
|
|
13
|
+
*
|
|
14
|
+
* 本包只处理 Vue 3。启用 TypeScript 时,Vue 模板解析器通过 `parserOptions.parser`
|
|
15
|
+
* 委托给 typescript-eslint;这是 Vue 官方推荐的自定义脚本解析器接入方式。
|
|
16
|
+
*/
|
|
17
|
+
const createVueConfigs = ({ typescript = true, typescriptOptions = {} } = {}) => {
|
|
18
|
+
const typeChecked = typescriptOptions.typeChecked ?? false;
|
|
19
|
+
const typeScriptConfigs = typescript ? getTypeScriptPresetConfigs(typeChecked, true) : [];
|
|
20
|
+
return defineConfig([{
|
|
21
|
+
name: typeChecked ? "@fast-china/vue/type-checked" : "@fast-china/vue",
|
|
22
|
+
files: [GLOB_VUE],
|
|
23
|
+
extends: [
|
|
24
|
+
eslint.configs.recommended,
|
|
25
|
+
...typeScriptConfigs,
|
|
26
|
+
...eslintPluginVue.configs["flat/recommended"]
|
|
27
|
+
],
|
|
28
|
+
languageOptions: {
|
|
29
|
+
ecmaVersion: "latest",
|
|
30
|
+
parser: vueEslintParser,
|
|
31
|
+
parserOptions: {
|
|
32
|
+
...typescript ? {
|
|
33
|
+
parser: tseslint.parser,
|
|
34
|
+
extraFileExtensions: [".vue"]
|
|
35
|
+
} : {},
|
|
36
|
+
ecmaFeatures: { jsx: true },
|
|
37
|
+
sourceType: "module",
|
|
38
|
+
...createTypeScriptParserOptions(typescriptOptions)
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
...typescript ? typescriptRules : {},
|
|
43
|
+
...vueRules
|
|
44
|
+
}
|
|
45
|
+
}]);
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { createVueConfigs };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=vue.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.mjs","names":[],"sources":["../../src/configs/vue.ts"],"sourcesContent":["import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\nimport eslintPluginVue from \"eslint-plugin-vue\";\nimport tseslint from \"typescript-eslint\";\nimport vueEslintParser from \"vue-eslint-parser\";\n\nimport { GLOB_VUE } from \"../constants\";\nimport { typescriptRules, vueRules } from \"../rules\";\n\nimport { type TypeScriptConfigOptions, createTypeScriptParserOptions, getTypeScriptPresetConfigs } from \"./typescript\";\n\n/**\n * Vue 3 单文件组件生成器使用的脚本语言与类型感知选项。\n *\n * `fastConfig()` 会根据顶层选项推导这些值;直接组合配置片段时可从 `./configs`\n * 子路径使用该接口。\n * 用户通过顶层 `vue` 决定是否接管 `.vue` 文件,通过顶层 `typescript` 决定 SFC 脚本\n * 是否启用 TypeScript 解析和类型感知能力;工厂会把两者转换为此对象。\n *\n * Vue 模板始终由 `vue-eslint-parser` 解析。启用 TypeScript 时,它再把 `<script>` 内容\n * 委托给 typescript-eslint parser,并复用普通 TypeScript 文件的推荐预置与解析器选项。\n */\nexport interface VueConfigOptions {\n\t/**\n\t * 是否使用 typescript-eslint parser 解析 SFC 的 `<script>` 与 `<script setup>` 内容。\n\t *\n\t * `true` 同时加载 TypeScript 推荐规则和本库 TypeScript 规则,并允许\n\t * `<script lang=\"ts\">`;`false` 不注册 TypeScript 脚本解析器,只按 JavaScript 处理\n\t * SFC 脚本。该值由顶层 `FastConfigOptions.typescript` 是否关闭推导。\n\t * @default true\n\t */\n\ttypescript?: boolean;\n\t/**\n\t * 与普通 TypeScript 文件共享的类型感知和 tsconfig 根目录选项。\n\t *\n\t * `typeChecked: true` 会让 Vue SFC 使用类型感知的 typescript-eslint 预置并启动 Project\n\t * Service;`tsconfigRootDir` 会原样传给解析器。工厂只会在顶层 TypeScript 能力启用时\n\t * 传入有效设置,避免 Vue 单独形成与普通 `.ts` 文件不一致的类型检查模式。\n\t * @default {}\n\t */\n\ttypescriptOptions?: TypeScriptConfigOptions;\n}\n\n/**\n * 创建 Vue 3 单文件组件配置。\n *\n * 本包只处理 Vue 3。启用 TypeScript 时,Vue 模板解析器通过 `parserOptions.parser`\n * 委托给 typescript-eslint;这是 Vue 官方推荐的自定义脚本解析器接入方式。\n */\nexport const createVueConfigs = ({ typescript = true, typescriptOptions = {} }: VueConfigOptions = {}) => {\n\tconst typeChecked = typescriptOptions.typeChecked ?? false;\n\tconst typeScriptConfigs = typescript ? getTypeScriptPresetConfigs(typeChecked, true) : [];\n\n\treturn defineConfig([\n\t\t{\n\t\t\tname: typeChecked ? \"@fast-china/vue/type-checked\" : \"@fast-china/vue\",\n\t\t\tfiles: [GLOB_VUE],\n\t\t\textends: [eslint.configs.recommended, ...typeScriptConfigs, ...eslintPluginVue.configs[\"flat/recommended\"]],\n\t\t\tlanguageOptions: {\n\t\t\t\tecmaVersion: \"latest\",\n\t\t\t\tparser: vueEslintParser,\n\t\t\t\tparserOptions: {\n\t\t\t\t\t...(typescript ? { parser: tseslint.parser, extraFileExtensions: [\".vue\"] } : {}),\n\t\t\t\t\tecmaFeatures: {\n\t\t\t\t\t\tjsx: true,\n\t\t\t\t\t},\n\t\t\t\t\tsourceType: \"module\",\n\t\t\t\t\t...createTypeScriptParserOptions(typescriptOptions),\n\t\t\t\t},\n\t\t\t},\n\t\t\trules: {\n\t\t\t\t...(typescript ? typescriptRules : {}),\n\t\t\t\t...vueRules,\n\t\t\t},\n\t\t},\n\t]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAiDA,MAAa,oBAAoB,EAAE,aAAa,MAAM,oBAAoB,CAAC,MAAwB,CAAC,MAAM;CACzG,MAAM,cAAc,kBAAkB,eAAe;CACrD,MAAM,oBAAoB,aAAa,2BAA2B,aAAa,IAAI,IAAI,CAAC;CAExF,OAAO,aAAa,CACnB;EACC,MAAM,cAAc,iCAAiC;EACrD,OAAO,CAAC,QAAQ;EAChB,SAAS;GAAC,OAAO,QAAQ;GAAa,GAAG;GAAmB,GAAG,gBAAgB,QAAQ;EAAmB;EAC1G,iBAAiB;GAChB,aAAa;GACb,QAAQ;GACR,eAAe;IACd,GAAI,aAAa;KAAE,QAAQ,SAAS;KAAQ,qBAAqB,CAAC,MAAM;IAAE,IAAI,CAAC;IAC/E,cAAc,EACb,KAAK,KACN;IACA,YAAY;IACZ,GAAG,8BAA8B,iBAAiB;GACnD;EACD;EACA,OAAO;GACN,GAAI,aAAa,kBAAkB,CAAC;GACpC,GAAG;EACJ;CACD,CACD,CAAC;AACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/constants/index.d.ts
|
|
2
|
+
/** `@fast-china/eslint-config/constants` 公开的文件匹配常量。 */
|
|
3
|
+
/** JavaScript 与 JSX 文件;扩展名列表与 Node.js ESM/CJS 约定保持一致。 */
|
|
4
|
+
declare const GLOBS_JAVASCRIPT: readonly ["**/*.{js,cjs,mjs,jsx}"];
|
|
5
|
+
/** TypeScript 与 TSX 文件;包含 TypeScript 的 ESM/CJS 专用扩展名。 */
|
|
6
|
+
declare const GLOBS_TYPESCRIPT: readonly ["**/*.{ts,cts,mts,tsx}"];
|
|
7
|
+
/** Vue 3 单文件组件。 */
|
|
8
|
+
declare const GLOB_VUE = "**/*.vue";
|
|
9
|
+
/** Angular 组件、指令、服务等框架源码;Angular CLI 项目以 `.ts` 为标准源码扩展名。 */
|
|
10
|
+
declare const GLOB_ANGULAR_TYPESCRIPT = "**/*.ts";
|
|
11
|
+
/** Angular 外部模板;内联模板由 Angular 处理器提取后复用同一模板配置。 */
|
|
12
|
+
declare const GLOB_ANGULAR_TEMPLATE = "**/*.html";
|
|
13
|
+
/** ESLint JSON language 支持的三种 JSON 方言。 */
|
|
14
|
+
declare const GLOB_JSON = "**/*.json";
|
|
15
|
+
declare const GLOB_JSONC = "**/*.jsonc";
|
|
16
|
+
declare const GLOB_JSON5 = "**/*.json5";
|
|
17
|
+
/** Markdown 文档。 */
|
|
18
|
+
declare const GLOB_MARKDOWN = "**/*.md";
|
|
19
|
+
/** 默认由 JavaScript、TypeScript 和 Vue 规则处理的全部代码文件。 */
|
|
20
|
+
declare const GLOBS_CODE: readonly ["**/*.{js,cjs,mjs,jsx}", "**/*.{ts,cts,mts,tsx}", "**/*.vue"];
|
|
21
|
+
/**
|
|
22
|
+
* 应额外获得 Node.js 全局变量的工程文件。
|
|
23
|
+
*
|
|
24
|
+
* 这些模式还会与当前已启用的 JavaScript/TypeScript 文件模式做 AND 匹配,
|
|
25
|
+
* 因而关闭 TypeScript 后不会意外让 ESLint 接管 `.ts` 文件。
|
|
26
|
+
*/
|
|
27
|
+
declare const GLOBS_NODE_TOOLING: readonly ["**/*.{config,setup}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "**/{scripts,bin}/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "**/{test,tests}/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "**/*.{test,spec}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "**/cli.{js,cjs,mjs,ts,cts,mts}"];
|
|
28
|
+
/** TypeScript 配置文件;它们使用 JSONC 语法并允许注释。 */
|
|
29
|
+
declare const GLOBS_TSCONFIG: readonly ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
30
|
+
/** 不应交给 JSON/Markdown 解析器处理的包管理器锁文件。 */
|
|
31
|
+
declare const GLOBS_LOCKFILES: readonly ["**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/bun.lock", "**/bun.lockb", "**/deno.lock"];
|
|
32
|
+
//#endregion
|
|
33
|
+
export { GLOBS_CODE, GLOBS_JAVASCRIPT, GLOBS_LOCKFILES, GLOBS_NODE_TOOLING, GLOBS_TSCONFIG, GLOBS_TYPESCRIPT, GLOB_ANGULAR_TEMPLATE, GLOB_ANGULAR_TYPESCRIPT, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_MARKDOWN, GLOB_VUE };
|
|
34
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants/index.ts"],"mappings":";;;cAGa;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;cACA;cACA;;cAGA;;cAGA;;;;;;;cAQA;;cASA;;cAGA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/constants/index.ts
|
|
2
|
+
/** `@fast-china/eslint-config/constants` 公开的文件匹配常量。 */
|
|
3
|
+
/** JavaScript 与 JSX 文件;扩展名列表与 Node.js ESM/CJS 约定保持一致。 */
|
|
4
|
+
const GLOBS_JAVASCRIPT = ["**/*.{js,cjs,mjs,jsx}"];
|
|
5
|
+
/** TypeScript 与 TSX 文件;包含 TypeScript 的 ESM/CJS 专用扩展名。 */
|
|
6
|
+
const GLOBS_TYPESCRIPT = ["**/*.{ts,cts,mts,tsx}"];
|
|
7
|
+
/** Vue 3 单文件组件。 */
|
|
8
|
+
const GLOB_VUE = "**/*.vue";
|
|
9
|
+
/** Angular 组件、指令、服务等框架源码;Angular CLI 项目以 `.ts` 为标准源码扩展名。 */
|
|
10
|
+
const GLOB_ANGULAR_TYPESCRIPT = "**/*.ts";
|
|
11
|
+
/** Angular 外部模板;内联模板由 Angular 处理器提取后复用同一模板配置。 */
|
|
12
|
+
const GLOB_ANGULAR_TEMPLATE = "**/*.html";
|
|
13
|
+
/** ESLint JSON language 支持的三种 JSON 方言。 */
|
|
14
|
+
const GLOB_JSON = "**/*.json";
|
|
15
|
+
const GLOB_JSONC = "**/*.jsonc";
|
|
16
|
+
const GLOB_JSON5 = "**/*.json5";
|
|
17
|
+
/** Markdown 文档。 */
|
|
18
|
+
const GLOB_MARKDOWN = "**/*.md";
|
|
19
|
+
/** 默认由 JavaScript、TypeScript 和 Vue 规则处理的全部代码文件。 */
|
|
20
|
+
const GLOBS_CODE = [
|
|
21
|
+
...GLOBS_JAVASCRIPT,
|
|
22
|
+
...GLOBS_TYPESCRIPT,
|
|
23
|
+
GLOB_VUE
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* 应额外获得 Node.js 全局变量的工程文件。
|
|
27
|
+
*
|
|
28
|
+
* 这些模式还会与当前已启用的 JavaScript/TypeScript 文件模式做 AND 匹配,
|
|
29
|
+
* 因而关闭 TypeScript 后不会意外让 ESLint 接管 `.ts` 文件。
|
|
30
|
+
*/
|
|
31
|
+
const GLOBS_NODE_TOOLING = [
|
|
32
|
+
"**/*.{config,setup}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}",
|
|
33
|
+
"**/{scripts,bin}/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}",
|
|
34
|
+
"**/{test,tests}/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}",
|
|
35
|
+
"**/*.{test,spec}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}",
|
|
36
|
+
"**/cli.{js,cjs,mjs,ts,cts,mts}"
|
|
37
|
+
];
|
|
38
|
+
/** TypeScript 配置文件;它们使用 JSONC 语法并允许注释。 */
|
|
39
|
+
const GLOBS_TSCONFIG = ["**/tsconfig.json", "**/tsconfig.*.json"];
|
|
40
|
+
/** 不应交给 JSON/Markdown 解析器处理的包管理器锁文件。 */
|
|
41
|
+
const GLOBS_LOCKFILES = [
|
|
42
|
+
"**/package-lock.json",
|
|
43
|
+
"**/yarn.lock",
|
|
44
|
+
"**/pnpm-lock.yaml",
|
|
45
|
+
"**/bun.lock",
|
|
46
|
+
"**/bun.lockb",
|
|
47
|
+
"**/deno.lock"
|
|
48
|
+
];
|
|
49
|
+
//#endregion
|
|
50
|
+
export { GLOBS_CODE, GLOBS_JAVASCRIPT, GLOBS_LOCKFILES, GLOBS_NODE_TOOLING, GLOBS_TSCONFIG, GLOBS_TYPESCRIPT, GLOB_ANGULAR_TEMPLATE, GLOB_ANGULAR_TYPESCRIPT, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_MARKDOWN, GLOB_VUE };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/constants/index.ts"],"sourcesContent":["/** `@fast-china/eslint-config/constants` 公开的文件匹配常量。 */\n\n/** JavaScript 与 JSX 文件;扩展名列表与 Node.js ESM/CJS 约定保持一致。 */\nexport const GLOBS_JAVASCRIPT = [\"**/*.{js,cjs,mjs,jsx}\"] as const;\n\n/** TypeScript 与 TSX 文件;包含 TypeScript 的 ESM/CJS 专用扩展名。 */\nexport const GLOBS_TYPESCRIPT = [\"**/*.{ts,cts,mts,tsx}\"] as const;\n\n/** Vue 3 单文件组件。 */\nexport const GLOB_VUE = \"**/*.vue\";\n\n/** Angular 组件、指令、服务等框架源码;Angular CLI 项目以 `.ts` 为标准源码扩展名。 */\nexport const GLOB_ANGULAR_TYPESCRIPT = \"**/*.ts\";\n\n/** Angular 外部模板;内联模板由 Angular 处理器提取后复用同一模板配置。 */\nexport const GLOB_ANGULAR_TEMPLATE = \"**/*.html\";\n\n/** ESLint JSON language 支持的三种 JSON 方言。 */\nexport const GLOB_JSON = \"**/*.json\";\nexport const GLOB_JSONC = \"**/*.jsonc\";\nexport const GLOB_JSON5 = \"**/*.json5\";\n\n/** Markdown 文档。 */\nexport const GLOB_MARKDOWN = \"**/*.md\";\n\n/** 默认由 JavaScript、TypeScript 和 Vue 规则处理的全部代码文件。 */\nexport const GLOBS_CODE = [...GLOBS_JAVASCRIPT, ...GLOBS_TYPESCRIPT, GLOB_VUE] as const;\n\n/**\n * 应额外获得 Node.js 全局变量的工程文件。\n *\n * 这些模式还会与当前已启用的 JavaScript/TypeScript 文件模式做 AND 匹配,\n * 因而关闭 TypeScript 后不会意外让 ESLint 接管 `.ts` 文件。\n */\nexport const GLOBS_NODE_TOOLING = [\n\t\"**/*.{config,setup}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}\",\n\t\"**/{scripts,bin}/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}\",\n\t\"**/{test,tests}/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}\",\n\t\"**/*.{test,spec}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}\",\n\t\"**/cli.{js,cjs,mjs,ts,cts,mts}\",\n] as const;\n\n/** TypeScript 配置文件;它们使用 JSONC 语法并允许注释。 */\nexport const GLOBS_TSCONFIG = [\"**/tsconfig.json\", \"**/tsconfig.*.json\"] as const;\n\n/** 不应交给 JSON/Markdown 解析器处理的包管理器锁文件。 */\nexport const GLOBS_LOCKFILES = [\"**/package-lock.json\", \"**/yarn.lock\", \"**/pnpm-lock.yaml\", \"**/bun.lock\", \"**/bun.lockb\", \"**/deno.lock\"] as const;\n"],"mappings":";;;AAGA,MAAa,mBAAmB,CAAC,uBAAuB;;AAGxD,MAAa,mBAAmB,CAAC,uBAAuB;;AAGxD,MAAa,WAAW;;AAGxB,MAAa,0BAA0B;;AAGvC,MAAa,wBAAwB;;AAGrC,MAAa,YAAY;AACzB,MAAa,aAAa;AAC1B,MAAa,aAAa;;AAG1B,MAAa,gBAAgB;;AAG7B,MAAa,aAAa;CAAC,GAAG;CAAkB,GAAG;CAAkB;AAAQ;;;;;;;AAQ7E,MAAa,qBAAqB;CACjC;CACA;CACA;CACA;CACA;AACD;;AAGA,MAAa,iBAAiB,CAAC,oBAAoB,oBAAoB;;AAGvE,MAAa,kBAAkB;CAAC;CAAwB;CAAgB;CAAqB;CAAe;CAAgB;AAAc"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,127 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AngularConfigOptions } from "./configs/angular.mjs";
|
|
2
|
+
import { RuntimeEnvironment } from "./configs/environment.mjs";
|
|
3
|
+
import { ReactConfigOptions } from "./configs/react.mjs";
|
|
4
|
+
import { TypeScriptConfigOptions } from "./configs/typescript.mjs";
|
|
5
|
+
import { RuleOptions } from "./typegen.mjs";
|
|
2
6
|
import { Config } from "eslint/config";
|
|
3
7
|
import { Linter } from "eslint";
|
|
4
|
-
//#region src/
|
|
5
|
-
|
|
6
|
-
* Angular TypeScript 源码与 HTML 模板检查的细分选项。
|
|
7
|
-
*
|
|
8
|
-
* 该对象通过 `fastConfig({ angular: { ... } })` 传入。只要传入对象,Angular 支持就会
|
|
9
|
-
* 被启用;未指定的字段继续使用各自默认值。Angular 配置始终包含框架 TypeScript 规则
|
|
10
|
-
* 和外部 `.html` 模板基础规则,本接口只控制成本或迁移影响较高的可选部分。
|
|
11
|
-
*
|
|
12
|
-
* Angular 支持依赖顶层 `typescript` 能力,不能与 `typescript: false` 同时使用。
|
|
13
|
-
* 这些选项不会修改 Angular 编译器、CLI 或模板类型检查配置。
|
|
14
|
-
*/
|
|
15
|
-
interface AngularConfigOptions {
|
|
16
|
-
/**
|
|
17
|
-
* 是否使用 Angular 官方 processor,从 TypeScript 文件的
|
|
18
|
-
* `@Component({ template: ... })` 元数据中提取内联 HTML 并复用模板规则进行检查。
|
|
19
|
-
*
|
|
20
|
-
* 关闭后仍会检查 Angular TypeScript 源码和外部 `.html` 模板,只是不再处理组件中的
|
|
21
|
-
* 内联模板。大型项目若主要使用外部模板,或 processor 与其他工具发生冲突,可暂时关闭。
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
inlineTemplates?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* 是否在模板基础正确性规则之外启用 Angular 模板无障碍规则组。
|
|
27
|
-
*
|
|
28
|
-
* 该规则组检查替代文本、键盘交互、焦点、表单标签和 ARIA 等可访问性问题,适用于
|
|
29
|
-
* 外部模板与已提取的内联模板。关闭后仍保留模板语法、严格比较和现代控制流等基础规则。
|
|
30
|
-
* 对旧项目而言可能一次产生较多报告,建议在确认迁移计划后再决定是否临时关闭。
|
|
31
|
-
* @default true
|
|
32
|
-
*/
|
|
33
|
-
templateAccessibility?: boolean;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/configs/environment.d.ts
|
|
37
|
-
type RuntimeEnvironment = "browser" | "node" | "universal";
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/configs/lodash.d.ts
|
|
40
|
-
/** 项目允许使用的 Lodash 导入来源。 */
|
|
41
|
-
type LodashPreference = "lodash" | "lodash-unified";
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/configs/react.d.ts
|
|
44
|
-
/**
|
|
45
|
-
* React 与兼容 JSX 运行时的检测设置。
|
|
46
|
-
*
|
|
47
|
-
* 该对象通过 `fastConfig({ react: { ... } })` 传入。传入对象会启用 React 支持,并在
|
|
48
|
-
* JavaScript/JSX 和 TypeScript/TSX 文件上加载对应的 `@eslint-react` 推荐预置、React
|
|
49
|
-
* 官方 Hooks Flat Config 以及本库规则。实际文件范围仍受顶层 `javascript`、
|
|
50
|
-
* `typescript` 开关控制。
|
|
51
|
-
*
|
|
52
|
-
* 这些字段只传给 ESLint 插件用于理解项目的 React 语义,不会改变 JSX 编译方式、自动
|
|
53
|
-
* 导入 React、设置打包器别名或安装兼容运行时。
|
|
54
|
-
*/
|
|
55
|
-
interface ReactConfigOptions {
|
|
56
|
-
/**
|
|
57
|
-
* 提供 React API 与 JSX 运行时的包入口名称。
|
|
58
|
-
*
|
|
59
|
-
* 标准 React 项目保持 `"react"`;Preact 等兼容运行时可填写自身包名,使
|
|
60
|
-
* `@eslint-react` 按正确的导入来源识别组件和 API。该设置不会修改 TypeScript
|
|
61
|
-
* `jsxImportSource`、Babel、Vite 或其他构建工具配置,两侧需要由项目自行保持一致。
|
|
62
|
-
* @default "react"
|
|
63
|
-
*/
|
|
64
|
-
importSource?: string;
|
|
65
|
-
/**
|
|
66
|
-
* 项目约定用于切换多态组件底层元素或组件类型的属性名。
|
|
67
|
-
*
|
|
68
|
-
* 例如 `<Button as="a" />` 中的 `as`。插件会据此理解多态组件最终渲染元素的语义,
|
|
69
|
-
* 从而提高 DOM 与可访问性相关规则的判断准确度;未采用多态组件时通常无需修改。
|
|
70
|
-
* @default "as"
|
|
71
|
-
*/
|
|
72
|
-
polymorphicPropName?: string;
|
|
73
|
-
/**
|
|
74
|
-
* 供插件选择版本相关行为的 React 版本号或自动检测标记。
|
|
75
|
-
*
|
|
76
|
-
* `"detect"` 会尝试从当前项目依赖解析已安装的 React 版本。monorepo、PnP、兼容运行时
|
|
77
|
-
* 或依赖不可见的执行环境若无法可靠检测,可传入明确版本号,例如 `"19.1.0"`。
|
|
78
|
-
* 该值只影响 lint 规则判断,不会限制或安装 React 依赖版本。
|
|
79
|
-
* @default "detect"
|
|
80
|
-
*/
|
|
81
|
-
version?: string;
|
|
82
|
-
}
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/configs/typescript.d.ts
|
|
8
|
+
//#region src/index.d.ts
|
|
9
|
+
type RejectUnknownRuleNames<Rules extends RuleOptions> = Rules & Record<Exclude<keyof Rules, keyof RuleOptions>, never>;
|
|
85
10
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* 该对象通过 `fastConfig({ typescript: { ... } })` 传入。传入对象会启用 TypeScript
|
|
89
|
-
* 支持,并检查 `.ts`、`.cts`、`.mts` 与 `.tsx`。相同的类型感知状态还会传递给已启用的
|
|
90
|
-
* Vue 和 React 配置,使普通 TypeScript 文件、Vue SFC 与 TSX 使用一致的检查级别。
|
|
11
|
+
* 为项目规则提供精确的规则名、严重级别和规则选项自动补全。
|
|
91
12
|
*
|
|
92
|
-
*
|
|
93
|
-
* typescript-eslint Project Service,能够执行更强的语义规则,但要求项目配置和执行目录
|
|
94
|
-
* 正确,并会增加首次检查时间与内存占用。
|
|
13
|
+
* 该函数不会修改传入对象;它只在 TypeScript 编译阶段拒绝未知规则和无效选项。
|
|
95
14
|
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 是否启用依赖完整 TypeScript 类型信息的规则。
|
|
99
|
-
*
|
|
100
|
-
* `false` 使用 typescript-eslint 的 `recommended` 与 `stylistic` 预置,不创建 TypeScript
|
|
101
|
-
* Program。`true` 切换到 `recommendedTypeChecked` 与 `stylisticTypeChecked`,并启用
|
|
102
|
-
* `parserOptions.projectService`。被检查文件通常需要包含在可发现的 tsconfig 中,否则
|
|
103
|
-
* Project Service 会报告文件不属于项目。
|
|
104
|
-
*
|
|
105
|
-
* 开启后 Vue 与 React 的 TypeScript 规则也会选择类型感知版本。大型 monorepo 建议评估
|
|
106
|
-
* lint 启动耗时和内存占用,并确保各工作区 tsconfig 边界明确。
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
typeChecked?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* typescript-eslint 查找 tsconfig 与创建 Project Service 时使用的根目录。
|
|
112
|
-
*
|
|
113
|
-
* 仅在 `typeChecked: true` 时写入解析器选项。普通单仓库通常可让 typescript-eslint 从
|
|
114
|
-
* `eslint.config.*` 调用栈推断;复杂 monorepo、共享配置包装层或从其他目录启动 ESLint
|
|
115
|
-
* 时,建议传入配置文件所在目录的绝对路径,例如 `import.meta.dirname`,避免发现错误的
|
|
116
|
-
* tsconfig 或跨越预期的项目边界。
|
|
117
|
-
* @default undefined
|
|
118
|
-
*/
|
|
119
|
-
tsconfigRootDir?: string;
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/code/index.d.ts
|
|
15
|
+
declare const defineRules: <const Rules extends RuleOptions>(rules: RejectUnknownRuleNames<Rules>) => Rules & Linter.RulesRecord;
|
|
123
16
|
/**
|
|
124
|
-
* `fastConfig()` 的项目级 ESLint Flat Config 选项。
|
|
17
|
+
* 核心工厂 `fastConfig()` 的项目级 ESLint Flat Config 选项。
|
|
125
18
|
*
|
|
126
19
|
* 每个字段只控制一个相对独立的配置片段。未传入字段时使用下方 `@default` 标注的值;
|
|
127
20
|
* 布尔选项传入 `false` 会让工厂完全跳过对应片段,支持对象形式的框架或 TypeScript
|
|
@@ -208,7 +101,7 @@ interface FastConfigOptions {
|
|
|
208
101
|
* 是否让工厂接管 JavaScript、CommonJS、ES Module 与 JSX 文件。
|
|
209
102
|
*
|
|
210
103
|
* 启用时匹配 `.js`、`.cjs`、`.mjs` 与 `.jsx`;关闭后这些文件不会进入基础规则、
|
|
211
|
-
* 环境全局变量、import、regexp
|
|
104
|
+
* 环境全局变量、import、regexp 或 React 的 JavaScript 配置范围,但不会影响
|
|
212
105
|
* 已启用的 TypeScript、Vue、JSON 或 Markdown 文件。
|
|
213
106
|
* @default true
|
|
214
107
|
*/
|
|
@@ -221,24 +114,12 @@ interface FastConfigOptions {
|
|
|
221
114
|
* @default true
|
|
222
115
|
*/
|
|
223
116
|
json?: boolean;
|
|
224
|
-
/**
|
|
225
|
-
* 是否统一项目中的 Lodash 静态 ESM 导入来源。
|
|
226
|
-
*
|
|
227
|
-
* - `false`:不限制 `lodash`、`lodash-es` 与 `lodash-unified` 的使用。
|
|
228
|
-
* - `"lodash"`:允许 `lodash` 及其子路径,禁止混用另外两个包。
|
|
229
|
-
* - `"lodash-unified"`:统一使用 `lodash-unified`,禁止另外两个包及其子路径。
|
|
230
|
-
*
|
|
231
|
-
* 该能力只约束静态 `import`/`export`,不会检查动态 `import()` 或 CommonJS
|
|
232
|
-
* `require()`,也不会安装、替换或迁移任何 Lodash 依赖。
|
|
233
|
-
* @default false
|
|
234
|
-
*/
|
|
235
|
-
lodash?: false | LodashPreference;
|
|
236
117
|
/**
|
|
237
118
|
* 是否使用 `@eslint/markdown` 推荐配置检查 `.md` 文档的结构和 Markdown 语法。
|
|
238
119
|
*
|
|
239
120
|
* 该配置关注 Markdown 文档本身,不会自动把项目的 JavaScript、TypeScript 或框架
|
|
240
121
|
* 规则应用到围栏代码块;如需检查代码块,应通过项目覆盖配置明确指定。
|
|
241
|
-
* @default
|
|
122
|
+
* @default false
|
|
242
123
|
*/
|
|
243
124
|
markdown?: boolean;
|
|
244
125
|
/**
|
|
@@ -322,8 +203,7 @@ declare const defaultConfigOptions: Readonly<{
|
|
|
322
203
|
readonly imports: true;
|
|
323
204
|
readonly javascript: true;
|
|
324
205
|
readonly json: true;
|
|
325
|
-
readonly
|
|
326
|
-
readonly markdown: true;
|
|
206
|
+
readonly markdown: false;
|
|
327
207
|
readonly prettier: true;
|
|
328
208
|
readonly react: false;
|
|
329
209
|
readonly regexp: true;
|
|
@@ -333,21 +213,14 @@ declare const defaultConfigOptions: Readonly<{
|
|
|
333
213
|
readonly vue: true;
|
|
334
214
|
}>;
|
|
335
215
|
/**
|
|
336
|
-
* 创建面向 Vue 3、
|
|
216
|
+
* 创建面向 Vue 3、Vite、TypeScript 与浏览器后台管理项目的 ESLint Flat Config。
|
|
337
217
|
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
218
|
+
* 默认启用浏览器环境、JavaScript、TypeScript、Vue 3、import、RegExp、JSON 和
|
|
219
|
+
* Prettier 兼容层。React、Angular、Markdown 与清单排序按需启用;Lodash 导入策略
|
|
220
|
+
* 通过 `@fast-china/eslint-config/configs` 独立组合。
|
|
221
|
+
* 额外配置参数会放在内置配置之后,因此项目可以按文件范围覆盖任何默认规则。
|
|
340
222
|
*/
|
|
341
223
|
declare const fastConfig: (options?: FastConfigOptions, ...overrides: Config[]) => Config[];
|
|
342
224
|
//#endregion
|
|
343
|
-
|
|
344
|
-
type RejectUnknownRuleNames<Rules extends RuleOptions> = Rules & Record<Exclude<keyof Rules, keyof RuleOptions>, never>;
|
|
345
|
-
/**
|
|
346
|
-
* 为项目规则提供精确的规则名、严重级别和规则选项自动补全。
|
|
347
|
-
*
|
|
348
|
-
* 该函数不会修改传入对象;它只在 TypeScript 编译阶段拒绝未知规则和无效选项。
|
|
349
|
-
*/
|
|
350
|
-
declare const defineRules: <const Rules extends RuleOptions>(rules: RejectUnknownRuleNames<Rules>) => Rules & Linter.RulesRecord;
|
|
351
|
-
//#endregion
|
|
352
|
-
export { type AngularConfigOptions, type FastConfigOptions, type LodashPreference, type ReactConfigOptions, type RuleOptions, type RuntimeEnvironment, type TypeScriptConfigOptions, fastConfig as default, fastConfig, defaultConfigOptions, defineRules };
|
|
225
|
+
export { FastConfigOptions, type RuleOptions, fastConfig as default, fastConfig, defaultConfigOptions, defineRules };
|
|
353
226
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;KA0BK,uBAAuB,cAAc,eAAe,QAAQ,OAAO,cAAc,aAAa;;;;;;cAOtF,oBAAqB,cAAc,aAAa,OAAO,uBAAuB,WAAS,QAAQ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;UA2BlG;;;;;;;;;;;;EAYhB,oBAAoB;;;;;;;;;;;;;EAapB,cAAc;;;;;;;;;EASd,UAAU,OAAO;;;;;;;;EAQjB;;;;;;;;EAQA;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;;;EAQA;;;;;;;;EAQA;;;;;;;;;EASA;;;;;;;;EAQA;;;;;;;;;;EAUA,kBAAkB;;;;;;;;;EASlB,QAAQ;;;;;;;;;EASR;;;;;;;;EAQA;;;;;;;;;;EAUA,uBAAuB;;;;;;;;;EASvB;;;cAIY,sBAAoB;;;;;;;;;;;;;;;;;;;;;;;;cAyBpB,aAAc,UAAS,sBAA2B,WAAW,aAAW"}
|