@fast-china/eslint-config 2.1.4 → 2.1.5
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 +6 -0
- package/README.md +2 -1
- package/README.zh.md +2 -1
- package/dist/configs/typescript.d.mts +5 -1
- package/dist/configs/typescript.mjs +9 -2
- package/dist/configs/typescript.mjs.map +1 -1
- package/dist/configs/vue.mjs +0 -1
- package/dist/configs/vue.mjs.map +1 -1
- package/docs/engineering-audit.zh.md +1 -1
- package/docs/rules-risk.md +2 -2
- package/docs/rules-risk.zh.md +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 2.1.5 - 2026-09-01
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Unified `extraFileExtensions: [".vue", ".nvue"]` across type-aware TypeScript, TSX, Vue, and NVue parsing so Project Service does not reload the project while linting mixed file types.
|
|
14
|
+
|
|
9
15
|
## 2.1.4 - 2026-08-30
|
|
10
16
|
|
|
11
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -113,10 +113,11 @@ Trailing configs have the highest precedence. `defineRules()` leaves the object
|
|
|
113
113
|
```js
|
|
114
114
|
parserOptions: {
|
|
115
115
|
projectService: true,
|
|
116
|
+
extraFileExtensions: [".vue", ".nvue"],
|
|
116
117
|
}
|
|
117
118
|
```
|
|
118
119
|
|
|
119
|
-
Linted files must belong to a discoverable `tsconfig.json`. The `typeChecked` and `tsconfigRootDir` wrapper options have been removed. Complex monorepos can override `languageOptions.parserOptions` in a trailing Flat Config when necessary.
|
|
120
|
+
Linted files must belong to a discoverable `tsconfig.json`. The same `extraFileExtensions` list is applied to TypeScript, TSX, Vue, and NVue files so Project Service does not reload the project while linting mixed file types. The `typeChecked` and `tsconfigRootDir` wrapper options have been removed. Complex monorepos can override `languageOptions.parserOptions` in a trailing Flat Config when necessary, but every type-aware file override in the same project must keep `extraFileExtensions` identical.
|
|
120
121
|
|
|
121
122
|
## React
|
|
122
123
|
|
package/README.zh.md
CHANGED
|
@@ -115,10 +115,11 @@ export default fastConfig(
|
|
|
115
115
|
```js
|
|
116
116
|
parserOptions: {
|
|
117
117
|
projectService: true,
|
|
118
|
+
extraFileExtensions: [".vue", ".nvue"],
|
|
118
119
|
}
|
|
119
120
|
```
|
|
120
121
|
|
|
121
|
-
被检查文件必须属于可发现的 `tsconfig.json
|
|
122
|
+
被检查文件必须属于可发现的 `tsconfig.json`。TypeScript、TSX、Vue 与 NVue 统一使用相同的 `extraFileExtensions`,避免混合检查文件时 Project Service 重载项目。不再提供 `typeChecked` 和 `tsconfigRootDir` 包装选项;复杂 monorepo 如需指定根目录,可在后置 Flat Config 中直接覆盖 `languageOptions.parserOptions`,但同一项目中所有类型感知文件覆盖必须保持 `extraFileExtensions` 完全一致。
|
|
122
123
|
|
|
123
124
|
## React
|
|
124
125
|
|
|
@@ -10,7 +10,11 @@ declare const getTypeScriptPresetConfigs: () => Linter.Config[];
|
|
|
10
10
|
/**
|
|
11
11
|
* 创建 TypeScript 解析器的 Project Service 选项。
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
13
|
+
* @remarks
|
|
14
|
+
* TypeScript、TSX、Vue 与 NVue 必须使用完全一致的 `extraFileExtensions`。否则混合检查文件时,
|
|
15
|
+
* TypeScript Server 会因扩展名集合变化而反复重载整个项目。
|
|
16
|
+
*
|
|
17
|
+
* @returns 始终启用 `projectService`,并统一声明 Vue 扩展名的解析器选项。
|
|
14
18
|
*/
|
|
15
19
|
declare const createTypeScriptParserOptions: () => Linter.ParserOptions;
|
|
16
20
|
/**
|
|
@@ -21,9 +21,16 @@ const getTypeScriptPresetConfigs = () => [
|
|
|
21
21
|
/**
|
|
22
22
|
* 创建 TypeScript 解析器的 Project Service 选项。
|
|
23
23
|
*
|
|
24
|
-
* @
|
|
24
|
+
* @remarks
|
|
25
|
+
* TypeScript、TSX、Vue 与 NVue 必须使用完全一致的 `extraFileExtensions`。否则混合检查文件时,
|
|
26
|
+
* TypeScript Server 会因扩展名集合变化而反复重载整个项目。
|
|
27
|
+
*
|
|
28
|
+
* @returns 始终启用 `projectService`,并统一声明 Vue 扩展名的解析器选项。
|
|
25
29
|
*/
|
|
26
|
-
const createTypeScriptParserOptions = () => ({
|
|
30
|
+
const createTypeScriptParserOptions = () => ({
|
|
31
|
+
projectService: true,
|
|
32
|
+
extraFileExtensions: [".vue", ".nvue"]
|
|
33
|
+
});
|
|
27
34
|
/**
|
|
28
35
|
* 创建 TypeScript 配置。
|
|
29
36
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.mjs","names":[],"sources":["../../src/configs/typescript.ts"],"sourcesContent":["import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\nimport tseslint from \"typescript-eslint\";\nimport { GLOBS_TYPESCRIPT } from \"../constants\";\nimport { javascriptRules, typescriptRules, typescriptTypeCheckedRules } from \"../rules\";\nimport type { Linter } from \"eslint\";\n\n/**\n * 返回 typescript-eslint 推荐预置。\n *\n * @returns ESLint 核心推荐规则与对应的 typescript-eslint 推荐预置。\n */\nexport const getTypeScriptPresetConfigs = (): Linter.Config[] =>\n\t[\n\t\teslint.configs.recommended,\n\t\t{\n\t\t\tname: \"@fast-china/typescript/javascript-rules\",\n\t\t\trules: javascriptRules,\n\t\t},\n\t\t...tseslint.configs.recommendedTypeChecked,\n\t] as Linter.Config[];\n\n/**\n * 创建 TypeScript 解析器的 Project Service 选项。\n *\n * @returns 始终启用 `projectService
|
|
1
|
+
{"version":3,"file":"typescript.mjs","names":[],"sources":["../../src/configs/typescript.ts"],"sourcesContent":["import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\nimport tseslint from \"typescript-eslint\";\nimport { GLOBS_TYPESCRIPT } from \"../constants\";\nimport { javascriptRules, typescriptRules, typescriptTypeCheckedRules } from \"../rules\";\nimport type { Linter } from \"eslint\";\n\n/**\n * 返回 typescript-eslint 推荐预置。\n *\n * @returns ESLint 核心推荐规则与对应的 typescript-eslint 推荐预置。\n */\nexport const getTypeScriptPresetConfigs = (): Linter.Config[] =>\n\t[\n\t\teslint.configs.recommended,\n\t\t{\n\t\t\tname: \"@fast-china/typescript/javascript-rules\",\n\t\t\trules: javascriptRules,\n\t\t},\n\t\t...tseslint.configs.recommendedTypeChecked,\n\t] as Linter.Config[];\n\n/**\n * 创建 TypeScript 解析器的 Project Service 选项。\n *\n * @remarks\n * TypeScript、TSX、Vue 与 NVue 必须使用完全一致的 `extraFileExtensions`。否则混合检查文件时,\n * TypeScript Server 会因扩展名集合变化而反复重载整个项目。\n *\n * @returns 始终启用 `projectService`,并统一声明 Vue 扩展名的解析器选项。\n */\nexport const createTypeScriptParserOptions = (): Linter.ParserOptions => ({\n\tprojectService: true,\n\textraFileExtensions: [\".vue\", \".nvue\"],\n});\n\n/**\n * 创建 TypeScript 配置。\n *\n * @remarks\n * 始终采用 ESLint 与 typescript-eslint 的 `recommendedTypeChecked` 预置并启动 Project Service。\n * 被检查文件必须属于可发现的 tsconfig。特殊项目可在后置 Flat Config 中覆盖解析器选项。\n *\n * @param files - 应用 TypeScript 配置的 ESLint glob 列表。\n * @returns 包含 TypeScript 预置、解析器选项与本地规则的 Flat Config 数组。\n */\nexport const createTypeScriptConfigs = (files: readonly string[] = GLOBS_TYPESCRIPT): ReturnType<typeof defineConfig> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/typescript/type-checked\",\n\t\t\tfiles: [...files],\n\t\t\textends: getTypeScriptPresetConfigs(),\n\t\t\tlanguageOptions: {\n\t\t\t\tecmaVersion: \"latest\",\n\t\t\t\tparserOptions: createTypeScriptParserOptions(),\n\t\t\t},\n\t\t\trules: {\n\t\t\t\t...typescriptRules,\n\t\t\t\t...typescriptTypeCheckedRules,\n\t\t\t},\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,mCACZ;CACC,OAAO,QAAQ;CACf;EACC,MAAM;EACN,OAAO;CACR;CACA,GAAG,SAAS,QAAQ;AACrB;;;;;;;;;;AAWD,MAAa,uCAA6D;CACzE,gBAAgB;CAChB,qBAAqB,CAAC,QAAQ,OAAO;AACtC;;;;;;;;;;;AAYA,MAAa,2BAA2B,QAA2B,qBAClE,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,SAAS,2BAA2B;CACpC,iBAAiB;EAChB,aAAa;EACb,eAAe,8BAA8B;CAC9C;CACA,OAAO;EACN,GAAG;EACH,GAAG;CACJ;AACD,CACD,CAAC"}
|
package/dist/configs/vue.mjs
CHANGED
package/dist/configs/vue.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.mjs","names":[],"sources":["../../src/configs/vue.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginVue from \"eslint-plugin-vue\";\nimport tseslint from \"typescript-eslint\";\nimport vueEslintParser from \"vue-eslint-parser\";\nimport { GLOB_NVUE, GLOB_VUE } from \"../constants\";\nimport { typescriptRules, typescriptTypeCheckedRules, vueRules } from \"../rules\";\nimport { createTypeScriptParserOptions, getTypeScriptPresetConfigs } from \"./typescript\";\n\n/**\n * 创建 Vue 3 单文件组件配置。\n *\n * @remarks\n * 本包只处理 Vue 3,并默认同时接管 UniApp 原生渲染页面使用的 `.nvue`。Vue 模板解析器\n * 通过 `parserOptions.parser` 委托给 typescript-eslint,统一使用类型感知检查。\n *\n * @returns 包含 Vue 模板、脚本解析器、推荐预置与本地规则的 Flat Config 数组。\n */\nexport const createVueConfigs = (): ReturnType<typeof defineConfig> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/vue/type-checked\",\n\t\t\tfiles: [GLOB_VUE, GLOB_NVUE],\n\t\t\textends: [...getTypeScriptPresetConfigs(), ...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\tparser: tseslint.parser,\n\t\t\t\t\
|
|
1
|
+
{"version":3,"file":"vue.mjs","names":[],"sources":["../../src/configs/vue.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginVue from \"eslint-plugin-vue\";\nimport tseslint from \"typescript-eslint\";\nimport vueEslintParser from \"vue-eslint-parser\";\nimport { GLOB_NVUE, GLOB_VUE } from \"../constants\";\nimport { typescriptRules, typescriptTypeCheckedRules, vueRules } from \"../rules\";\nimport { createTypeScriptParserOptions, getTypeScriptPresetConfigs } from \"./typescript\";\n\n/**\n * 创建 Vue 3 单文件组件配置。\n *\n * @remarks\n * 本包只处理 Vue 3,并默认同时接管 UniApp 原生渲染页面使用的 `.nvue`。Vue 模板解析器\n * 通过 `parserOptions.parser` 委托给 typescript-eslint,统一使用类型感知检查。\n *\n * @returns 包含 Vue 模板、脚本解析器、推荐预置与本地规则的 Flat Config 数组。\n */\nexport const createVueConfigs = (): ReturnType<typeof defineConfig> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/vue/type-checked\",\n\t\t\tfiles: [GLOB_VUE, GLOB_NVUE],\n\t\t\textends: [...getTypeScriptPresetConfigs(), ...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\tparser: tseslint.parser,\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(),\n\t\t\t\t},\n\t\t\t},\n\t\t\trules: {\n\t\t\t\t...typescriptRules,\n\t\t\t\t...typescriptTypeCheckedRules,\n\t\t\t\t// Vue SFC 继承的 TypeScript 预置保留自身 files 范围,因此显式关闭容易误判 TS AST 的核心规则。\n\t\t\t\t...(tseslint.configs.recommendedTypeChecked[1]?.rules ?? {}),\n\t\t\t\t// SFC 内部函数依赖上下文推断返回类型,只要求模块导出边界显式声明。\n\t\t\t\t\"@typescript-eslint/explicit-function-return-type\": \"off\",\n\t\t\t\t...vueRules,\n\t\t\t},\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,yBACZ,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,UAAU,SAAS;CAC3B,SAAS,CAAC,GAAG,2BAA2B,GAAG,GAAG,gBAAgB,QAAQ,mBAAmB;CACzF,iBAAiB;EAChB,aAAa;EACb,QAAQ;EACR,eAAe;GACd,QAAQ,SAAS;GACjB,cAAc,EACb,KAAK,KACN;GACA,YAAY;GACZ,GAAG,8BAA8B;EAClC;CACD;CACA,OAAO;EACN,GAAG;EACH,GAAG;EAEH,GAAI,SAAS,QAAQ,uBAAuB,EAAE,EAAE,SAAS,CAAC;EAE1D,oDAAoD;EACpD,GAAG;CACJ;AACD,CACD,CAAC"}
|
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.5 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
|
|
|
@@ -48,7 +48,7 @@ The root entry is a fixed Vue 3 + TypeScript + UniApp preset:
|
|
|
48
48
|
|
|
49
49
|
### TypeScript
|
|
50
50
|
|
|
51
|
-
- `recommendedTypeChecked` and `projectService: true` are always enabled.
|
|
51
|
+
- `recommendedTypeChecked` and `projectService: true` are always enabled; TypeScript, TSX, Vue, and NVue share `extraFileExtensions: [".vue", ".nvue"]` to prevent Project Service reloads during mixed-file linting.
|
|
52
52
|
- `explicit-module-boundary-types` is an error and does not allow explicitly typed `any` arguments as an escape hatch.
|
|
53
53
|
- `explicit-function-return-type` is not additionally enabled, so internal functions and callbacks can rely on inference.
|
|
54
54
|
- `no-explicit-any` warns.
|
package/docs/rules-risk.zh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 默认规则与风险指南
|
|
2
2
|
|
|
3
|
-
本文说明 2.1.
|
|
3
|
+
本文说明 2.1.5 当前配置模型、主要规则和迁移风险。规则源码注释只解释现行意图;历史差异统一记录在 `CHANGELOG.md`。
|
|
4
4
|
|
|
5
5
|
## 配置模型
|
|
6
6
|
|
|
@@ -48,7 +48,7 @@ SDK、OA、Admin、Vue Web 与 UniApp 客户端共享同一套 JavaScript、Type
|
|
|
48
48
|
|
|
49
49
|
### TypeScript
|
|
50
50
|
|
|
51
|
-
- 始终启用 `recommendedTypeChecked` 与 `projectService: true
|
|
51
|
+
- 始终启用 `recommendedTypeChecked` 与 `projectService: true`;TypeScript、TSX、Vue 与 NVue 统一使用 `extraFileExtensions: [".vue", ".nvue"]`,避免混合检查时 Project Service 重载项目。
|
|
52
52
|
- `explicit-module-boundary-types` 为 `error`,模块导出边界必须显式声明类型,不允许用显式 `any` 参数规避。
|
|
53
53
|
- `explicit-function-return-type` 不额外启用,内部函数和回调可以依赖推断。
|
|
54
54
|
- `no-explicit-any` 为 `warn`。
|
package/package.json
CHANGED