@fast-china/eslint-config 2.0.9 → 2.1.0
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 +38 -0
- package/CONTRIBUTING.md +8 -7
- package/README.md +108 -236
- package/README.zh.md +105 -231
- package/SECURITY.md +4 -4
- package/dist/configs/angular.d.mts +6 -6
- package/dist/configs/angular.mjs +1 -1
- package/dist/configs/angular.mjs.map +1 -1
- package/dist/configs/common.d.mts +2 -1
- package/dist/configs/common.mjs.map +1 -1
- package/dist/configs/environment.d.mts +21 -11
- package/dist/configs/environment.mjs +25 -5
- package/dist/configs/environment.mjs.map +1 -1
- package/dist/configs/ignores.d.mts +3 -2
- package/dist/configs/ignores.mjs +4 -3
- package/dist/configs/ignores.mjs.map +1 -1
- package/dist/configs/import.d.mts +2 -1
- package/dist/configs/import.mjs.map +1 -1
- package/dist/configs/index.d.mts +5 -4
- package/dist/configs/index.mjs +3 -2
- package/dist/configs/javascript.d.mts +2 -1
- package/dist/configs/javascript.mjs.map +1 -1
- package/dist/configs/json.d.mts +5 -3
- package/dist/configs/json.mjs +5 -4
- package/dist/configs/json.mjs.map +1 -1
- package/dist/configs/lodash.d.mts +2 -1
- package/dist/configs/lodash.mjs.map +1 -1
- package/dist/configs/markdown.d.mts +2 -1
- package/dist/configs/markdown.mjs.map +1 -1
- package/dist/configs/prettier.d.mts +2 -1
- package/dist/configs/prettier.mjs +4 -1
- package/dist/configs/prettier.mjs.map +1 -1
- package/dist/configs/react.d.mts +7 -44
- package/dist/configs/react.mjs +7 -8
- package/dist/configs/react.mjs.map +1 -1
- package/dist/configs/regexp.d.mts +4 -4
- package/dist/configs/regexp.mjs +5 -4
- package/dist/configs/regexp.mjs.map +1 -1
- package/dist/configs/sort-package.d.mts +4 -3
- package/dist/configs/sort-package.mjs +2 -2
- package/dist/configs/sort-package.mjs.map +1 -1
- package/dist/configs/sort-tsconfig.d.mts +4 -2
- package/dist/configs/sort-tsconfig.mjs +2 -1
- package/dist/configs/sort-tsconfig.mjs.map +1 -1
- package/dist/configs/typescript.d.mts +9 -56
- package/dist/configs/typescript.mjs +20 -29
- package/dist/configs/typescript.mjs.map +1 -1
- package/dist/configs/uniapp.d.mts +17 -0
- package/dist/configs/uniapp.mjs +30 -0
- package/dist/configs/uniapp.mjs.map +1 -0
- package/dist/configs/vue.d.mts +5 -38
- package/dist/configs/vue.mjs +25 -35
- package/dist/configs/vue.mjs.map +1 -1
- package/dist/constants/index.d.mts +33 -1
- package/dist/constants/index.mjs +33 -1
- package/dist/constants/index.mjs.map +1 -1
- package/dist/index.d.mts +41 -208
- package/dist/index.mjs +58 -100
- package/dist/index.mjs.map +1 -1
- package/dist/rules/angular.d.mts +1 -1
- package/dist/rules/angular.mjs +1 -1
- package/dist/rules/angular.mjs.map +1 -1
- package/dist/rules/common.d.mts +2 -2
- package/dist/rules/common.mjs +2 -2
- package/dist/rules/common.mjs.map +1 -1
- package/dist/rules/import.mjs.map +1 -1
- package/dist/rules/index.d.mts +2 -1
- package/dist/rules/index.mjs +2 -1
- package/dist/rules/javascript.d.mts +10 -6
- package/dist/rules/javascript.mjs +12 -6
- package/dist/rules/javascript.mjs.map +1 -1
- package/dist/rules/react.d.mts +2 -3
- package/dist/rules/react.mjs +2 -3
- package/dist/rules/react.mjs.map +1 -1
- package/dist/rules/regexp.d.mts +38 -0
- package/dist/rules/regexp.mjs +39 -0
- package/dist/rules/regexp.mjs.map +1 -0
- package/dist/rules/sort-package.d.mts +1 -1
- package/dist/rules/sort-package.mjs +1 -1
- package/dist/rules/sort-package.mjs.map +1 -1
- package/dist/rules/sort-tsconfig.d.mts +1 -1
- package/dist/rules/sort-tsconfig.mjs +1 -1
- package/dist/rules/sort-tsconfig.mjs.map +1 -1
- package/dist/rules/typescript.d.mts +11 -3
- package/dist/rules/typescript.mjs +10 -4
- package/dist/rules/typescript.mjs.map +1 -1
- package/dist/rules/vue.d.mts +8 -2
- package/dist/rules/vue.mjs +8 -2
- package/dist/rules/vue.mjs.map +1 -1
- package/docs/engineering-audit.zh.md +53 -77
- package/docs/rules-risk.md +104 -101
- package/docs/rules-risk.zh.md +104 -105
- package/package.json +3 -2
package/README.zh.md
CHANGED
|
@@ -8,21 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
# @fast-china/eslint-config
|
|
10
10
|
|
|
11
|
-
面向 Vue 3、React、Angular、Vite、TypeScript 与 JavaScript 项目的实用型 ESLint Flat Config 规则库。
|
|
11
|
+
面向 Vue 3、UniApp、React、Angular、Vite、TypeScript 与 JavaScript 项目的实用型 ESLint Flat Config 规则库。
|
|
12
12
|
|
|
13
13
|
[](https://www.npmjs.com/package/@fast-china/eslint-config) [](https://nodejs.org/) [](https://eslint.org/) [](./LICENSE)
|
|
14
14
|
|
|
15
15
|
## 特性
|
|
16
16
|
|
|
17
17
|
- 基于 ESLint 10,仅提供原生 Flat Config。
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- 可选统一使用 `lodash` 或 `lodash-unified`,避免同一项目混用多个 Lodash 入口。
|
|
18
|
+
- 根入口固定面向 Vue 3 + TypeScript + UniApp,不再通过布尔选项启停语言和插件。
|
|
19
|
+
- TypeScript、Vue 与 React TypeScript 始终使用类型感知推荐规则和 Project Service。
|
|
20
|
+
- SDK、OA、Admin 与客户端使用同一套 JavaScript、TypeScript、Import 和 RegExp 规则,不提供严格度档位。
|
|
21
|
+
- 默认启用 JavaScript、TypeScript、Vue/`.nvue`、UniApp globals、JSON 各方言、Import、RegExp、清单排序、`.gitignore` 与 Prettier 兼容层。
|
|
22
|
+
- React、Angular、Markdown 和 Lodash 策略通过 `@fast-china/eslint-config/configs` 显式组合。
|
|
23
|
+
- 根据规则 schema 生成精确 `RuleOptions`,提供规则名和规则选项自动补全。
|
|
24
|
+
- 插件与解析器均由本包声明依赖,使用者不需要手工拼装依赖树。
|
|
26
25
|
|
|
27
26
|
## 环境要求
|
|
28
27
|
|
|
@@ -30,315 +29,192 @@
|
|
|
30
29
|
- ESLint `^10.0.0`
|
|
31
30
|
- TypeScript `^6.0.0`
|
|
32
31
|
|
|
33
|
-
这些版本范围与 ESLint 10 及内置语言插件的运行要求保持一致。
|
|
34
|
-
|
|
35
32
|
## 安装
|
|
36
33
|
|
|
37
34
|
```sh
|
|
38
35
|
pnpm add -D eslint typescript @fast-china/eslint-config
|
|
39
36
|
```
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## 快速开始:Vue 3 + Vite
|
|
38
|
+
## Vue 3 / UniApp 快速开始
|
|
44
39
|
|
|
45
40
|
创建 `eslint.config.mjs`:
|
|
46
41
|
|
|
47
42
|
```js
|
|
48
43
|
import fastChina from "@fast-china/eslint-config";
|
|
49
44
|
|
|
50
|
-
export default fastChina
|
|
45
|
+
export default fastChina;
|
|
51
46
|
```
|
|
52
47
|
|
|
53
|
-
|
|
48
|
+
默认入口固定包含:
|
|
54
49
|
|
|
55
|
-
|
|
50
|
+
- 浏览器运行环境和 Node.js 工程文件 globals。
|
|
51
|
+
- JavaScript、类型感知 TypeScript、Vue 3 与 `.nvue`。
|
|
52
|
+
- `uni`、`uniCloud`、页面 API 以及 `wx`、`plus`、`my`、`tt` 等条件编译平台 globals。
|
|
53
|
+
- JSON、JSONC、JSON5,以及允许注释的 `pages.json`、`manifest.json` 和 VS Code `settings.json`、`extensions.json`。
|
|
54
|
+
- Import、RegExp、`package.json`/`tsconfig*.json` 排序、`.gitignore` 和 Prettier 冲突关闭层。
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
ESLint 不执行 UniApp 的 `#ifdef`/`#endif`,因此只能识别平台对象,不能验证对象是否位于正确的平台分支。当前不处理需要专用解析器的 `.uvue` 与 `.uts`。
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
## `fastConfig()`
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
根工厂只保留 `environment`,默认值为 `"browser"`:
|
|
62
61
|
|
|
63
62
|
```js
|
|
64
|
-
import
|
|
63
|
+
import { fastConfig } from "@fast-china/eslint-config";
|
|
65
64
|
|
|
66
|
-
export default
|
|
67
|
-
|
|
68
|
-
vue: false,
|
|
65
|
+
export default fastConfig({
|
|
66
|
+
environment: "universal",
|
|
69
67
|
});
|
|
70
68
|
```
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
可选值:
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
| 值 | 应用源码 globals |
|
|
73
|
+
| ------------- | ---------------- |
|
|
74
|
+
| `"browser"` | 浏览器 |
|
|
75
|
+
| `"node"` | Node.js |
|
|
76
|
+
| `"universal"` | 浏览器和 Node.js |
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
import fastChina from "@fast-china/eslint-config";
|
|
78
|
+
配置文件、脚本、测试和 CLI 文件始终单独获得 Node.js globals,并允许必要的 `console` 和 CommonJS 兼容加载。
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
angular: true,
|
|
81
|
-
vue: false,
|
|
82
|
-
});
|
|
83
|
-
```
|
|
80
|
+
## 项目覆写
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
规则、globals、ignores 和解析器特殊设置直接使用后置 Flat Config,不再包装成根工厂选项:
|
|
86
83
|
|
|
87
84
|
```js
|
|
88
|
-
|
|
89
|
-
angular: {
|
|
90
|
-
inlineTemplates: true,
|
|
91
|
-
templateAccessibility: true,
|
|
92
|
-
},
|
|
93
|
-
vue: false,
|
|
94
|
-
});
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Angular 依赖 TypeScript 集成;同时设置 `angular: true` 与 `typescript: false` 时会立即抛出清晰的配置错误。
|
|
85
|
+
import { defineRules, fastConfig } from "@fast-china/eslint-config";
|
|
98
86
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
87
|
+
export default fastConfig(
|
|
88
|
+
{ environment: "browser" },
|
|
89
|
+
{
|
|
90
|
+
ignores: ["public/vendor/**"],
|
|
91
|
+
languageOptions: {
|
|
92
|
+
globals: {
|
|
93
|
+
__APP_VERSION__: "readonly",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
rules: defineRules({
|
|
97
|
+
"no-console": "warn",
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
files: ["**/*.generated.ts"],
|
|
102
|
+
rules: defineRules({
|
|
103
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
104
|
+
}),
|
|
105
|
+
}
|
|
106
|
+
);
|
|
108
107
|
```
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```js
|
|
113
|
-
import fastChina from "@fast-china/eslint-config";
|
|
109
|
+
后置配置拥有最高优先级。`defineRules()` 不修改对象,只提供精确的规则类型检查。
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
environment: "node",
|
|
117
|
-
json: false,
|
|
118
|
-
markdown: false,
|
|
119
|
-
typescript: false,
|
|
120
|
-
vue: false,
|
|
121
|
-
});
|
|
122
|
-
```
|
|
111
|
+
## TypeScript
|
|
123
112
|
|
|
124
|
-
|
|
113
|
+
`createTypeScriptConfigs()`、Vue SFC 和 React TSX 始终使用 `recommendedTypeChecked` 与:
|
|
125
114
|
|
|
126
115
|
```js
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
typescript: {
|
|
131
|
-
tsconfigRootDir: import.meta.dirname,
|
|
132
|
-
typeChecked: true,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
116
|
+
parserOptions: {
|
|
117
|
+
projectService: true,
|
|
118
|
+
}
|
|
135
119
|
```
|
|
136
120
|
|
|
137
|
-
|
|
121
|
+
被检查文件必须属于可发现的 `tsconfig.json`。不再提供 `typeChecked` 和 `tsconfigRootDir` 包装选项;复杂 monorepo 如需指定根目录,可在后置 Flat Config 中直接覆盖 `languageOptions.parserOptions`。
|
|
138
122
|
|
|
139
|
-
|
|
123
|
+
## React
|
|
140
124
|
|
|
141
|
-
|
|
125
|
+
React 项目从不绑定框架的基础配置开始组合:
|
|
142
126
|
|
|
143
127
|
```js
|
|
128
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
129
|
+
import { createReactConfigs } from "@fast-china/eslint-config/configs";
|
|
144
130
|
import { defineConfig } from "eslint/config";
|
|
145
131
|
|
|
146
|
-
|
|
147
|
-
createCommonConfigs,
|
|
148
|
-
createEnvironmentConfigs,
|
|
149
|
-
createGitignoreConfigs,
|
|
150
|
-
createGlobalIgnores,
|
|
151
|
-
createImportConfigs,
|
|
152
|
-
createJavaScriptConfigs,
|
|
153
|
-
createPrettierConfigs,
|
|
154
|
-
createReactConfigs,
|
|
155
|
-
createRegexpConfigs,
|
|
156
|
-
createTypeScriptConfigs,
|
|
157
|
-
} from "@fast-china/eslint-config/configs";
|
|
158
|
-
import { GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
|
|
159
|
-
|
|
160
|
-
const codeFiles = [...GLOBS_JAVASCRIPT, ...GLOBS_TYPESCRIPT];
|
|
161
|
-
|
|
162
|
-
export default defineConfig([
|
|
163
|
-
...createGlobalIgnores(),
|
|
164
|
-
...createGitignoreConfigs(),
|
|
165
|
-
...createEnvironmentConfigs({ environment: "browser", files: codeFiles, nodeFiles: codeFiles }),
|
|
166
|
-
...createCommonConfigs(codeFiles),
|
|
167
|
-
...createJavaScriptConfigs(),
|
|
168
|
-
...createImportConfigs(codeFiles),
|
|
169
|
-
...createRegexpConfigs(codeFiles),
|
|
170
|
-
...createTypeScriptConfigs(),
|
|
171
|
-
...createReactConfigs({}, { javascript: true, typescript: true }),
|
|
172
|
-
...createPrettierConfigs(),
|
|
173
|
-
]);
|
|
132
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs()]);
|
|
174
133
|
```
|
|
175
134
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
## 配置选项
|
|
179
|
-
|
|
180
|
-
| 选项 | 默认值 | 作用 |
|
|
181
|
-
| ----------------- | ----------- | -------------------------------------------------------------- |
|
|
182
|
-
| `angular` | `false` | 启用 Angular TypeScript 与模板,或传入 Angular 专用选项。 |
|
|
183
|
-
| `environment` | `"browser"` | 可选 `"browser"`、`"node"` 或 `"universal"` 全局变量。 |
|
|
184
|
-
| `globals` | 无 | 增加项目宿主、测试运行器等提供的全局变量。 |
|
|
185
|
-
| `gitignore` | `true` | 读取项目根目录的 `.gitignore`。 |
|
|
186
|
-
| `ignores` | `[]` | 追加项目自己的全局忽略模式。 |
|
|
187
|
-
| `imports` | `true` | 启用 import-x 正确性与排序规则。 |
|
|
188
|
-
| `javascript` | `true` | 处理 JavaScript 与 JSX。 |
|
|
189
|
-
| `json` | `true` | 启用 JSON、JSONC 与 JSON5 推荐规则。 |
|
|
190
|
-
| `markdown` | `false` | 启用官方 Markdown 语言规则。 |
|
|
191
|
-
| `prettier` | `true` | 关闭与 Prettier 冲突的 ESLint 规则。 |
|
|
192
|
-
| `react` | `false` | 启用 React、JSX 与 Hooks,或传入运行时和 React 版本设置。 |
|
|
193
|
-
| `regexp` | `true` | 启用推荐的正则表达式规则。 |
|
|
194
|
-
| `rules` | 无 | 对所有已启用代码文件追加具有精确类型的项目规则。 |
|
|
195
|
-
| `sortPackageJson` | `false` | 按安全白名单排序 `package.json`,不会进入 `exports` 条件对象。 |
|
|
196
|
-
| `sortTsconfig` | `false` | 按 TypeScript 文档主题排序 `tsconfig*.json`。 |
|
|
197
|
-
| `typescript` | `true` | 可关闭,或传入 `{ typeChecked: true, tsconfigRootDir }`。 |
|
|
198
|
-
| `vue` | `true` | 启用 Vue 3 单文件组件支持。 |
|
|
199
|
-
|
|
200
|
-
## 框架覆盖范围
|
|
201
|
-
|
|
202
|
-
Vue 3、React 与 Angular 都有专用解析器或处理器、推荐规则、配置选项、生成规则类型与集成测试。Nuxt 可使用 Vue 基础配置;Next.js 与 Remix 可使用 React 基础配置,并在 `fastConfig()` 后追加各自的框架 Flat Config。兼容 React 的 JSX 运行时可以使用 `react.importSource`。
|
|
203
|
-
|
|
204
|
-
Svelte、Astro 与 Solid 具有不同的模板或编译器语义,目前不会被包装成名义上的“一键支持”。项目已经可以把它们的官方 Flat Config 作为末尾覆写传入;将来只有在解析器、处理器、规则 schema、文档和真实运行时 fixture 一并完成时,才会增加对应的一等开关。
|
|
205
|
-
|
|
206
|
-
## Lodash 导入策略
|
|
207
|
-
|
|
208
|
-
Lodash 策略不是 `fastConfig()` 选项。只有需要统一静态导入来源时,才从 `@fast-china/eslint-config/configs` 导入 `createLodashConfigs()`:
|
|
209
|
-
|
|
210
|
-
- `createLodashConfigs("lodash-unified")`:禁止从 `lodash`、`lodash-es` 及其子路径静态导入或重新导出。
|
|
211
|
-
- `createLodashConfigs("lodash")`:禁止从 `lodash-es`、`lodash-unified` 及其子路径静态导入或重新导出;允许 `lodash` 根入口和 `lodash/*` 按方法导入。
|
|
135
|
+
基础配置提供统一的 JavaScript、类型感知 TypeScript、JSON、Import、RegExp、清单排序和 Prettier 兼容层;React 片段追加 `@eslint-react`、React 官方 Hooks Recommended 和 DOM 安全规则,不会加载 Vue 或 UniApp globals。
|
|
212
136
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
```sh
|
|
216
|
-
pnpm add lodash-unified
|
|
217
|
-
```
|
|
137
|
+
Preact 等兼容运行时可以传入 React 识别设置:
|
|
218
138
|
|
|
219
139
|
```js
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
import fastChina from "@fast-china/eslint-config";
|
|
223
|
-
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
224
|
-
import { cloneDeep, debounce } from "lodash-unified";
|
|
225
|
-
|
|
226
|
-
export default defineConfig([...fastChina(), ...createLodashConfigs("lodash-unified")]);
|
|
140
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs({ importSource: "preact", version: "detect" })]);
|
|
227
141
|
```
|
|
228
142
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
```sh
|
|
232
|
-
pnpm add lodash
|
|
233
|
-
pnpm add -D @types/lodash
|
|
234
|
-
```
|
|
143
|
+
## Angular
|
|
235
144
|
|
|
236
145
|
```js
|
|
146
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
147
|
+
import { createAngularConfigs } from "@fast-china/eslint-config/configs";
|
|
237
148
|
import { defineConfig } from "eslint/config";
|
|
238
149
|
|
|
239
|
-
|
|
240
|
-
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
241
|
-
import debounce from "lodash/debounce";
|
|
242
|
-
|
|
243
|
-
export default defineConfig([...fastChina(), ...createLodashConfigs("lodash")]);
|
|
150
|
+
export default defineConfig([...createBaseConfigs(), ...createAngularConfigs()]);
|
|
244
151
|
```
|
|
245
152
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
如果后续 `rules` 或文件级覆写再次设置 `no-restricted-imports`,ESLint 会用后面的完整规则替换这套策略,而不是合并选项。需要组合更多包限制时,可从 `@fast-china/eslint-config/rules` 导入原始 `preferLodashRules` 或 `preferLodashUnifiedRules`,统一维护一份完整规则。
|
|
249
|
-
|
|
250
|
-
## 精确规则类型与自动补全
|
|
251
|
-
|
|
252
|
-
本包根据 ESLint 核心规则和所有随包插件公开的 JSON Schema 生成 `RuleOptions`,并提供不会改变运行时对象的 `defineRules()`。在输入规则名、严重级别或选项时,TypeScript 与支持类型分析的编辑器会给出补全;拼错规则名或填写无效选项时会立即报错。
|
|
153
|
+
Angular 片段检查 TypeScript 源码、外部 HTML 模板和组件内联模板,默认启用官方模板无障碍规则。特殊项目仍可配置:
|
|
253
154
|
|
|
254
155
|
```js
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const projectRules = defineRules({
|
|
259
|
-
"@angular-eslint/template/alt-text": "error",
|
|
260
|
-
"@eslint-react/dom-no-missing-button-type": "error",
|
|
261
|
-
"@typescript-eslint/no-unused-vars": ["error", { args: "after-used" }],
|
|
262
|
-
"import-x/order": ["error", { "newlines-between": "never" }],
|
|
263
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
264
|
-
"vue/attributes-order": ["error", { order: ["DEFINITION", "EVENTS", "CONTENT"] }],
|
|
156
|
+
createAngularConfigs({
|
|
157
|
+
inlineTemplates: false,
|
|
158
|
+
templateAccessibility: false,
|
|
265
159
|
});
|
|
266
|
-
|
|
267
|
-
export default fastChina(
|
|
268
|
-
{ rules: projectRules },
|
|
269
|
-
{
|
|
270
|
-
files: ["**/*.generated.ts"],
|
|
271
|
-
name: "project/generated",
|
|
272
|
-
rules: defineRules({ "@typescript-eslint/no-unused-vars": "off" }),
|
|
273
|
-
}
|
|
274
|
-
);
|
|
275
160
|
```
|
|
276
161
|
|
|
277
|
-
|
|
162
|
+
## Node.js / SDK
|
|
278
163
|
|
|
279
|
-
|
|
280
|
-
import type { RuleOptions } from "@fast-china/eslint-config";
|
|
164
|
+
不需要 Vue、UniApp、React 或 Angular 的项目直接使用基础配置:
|
|
281
165
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
166
|
+
```js
|
|
167
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
168
|
+
|
|
169
|
+
export default createBaseConfigs({ environment: "node" });
|
|
285
170
|
```
|
|
286
171
|
|
|
287
|
-
|
|
172
|
+
`createBaseConfigs()` 固定启用 JavaScript、类型感知 TypeScript、JSON、Import、RegExp、清单排序、`.gitignore` 和 Prettier 兼容层,但不接管任何框架文件。
|
|
288
173
|
|
|
289
|
-
##
|
|
174
|
+
## Markdown 与 Lodash
|
|
290
175
|
|
|
291
|
-
|
|
176
|
+
Markdown 需要显式组合:
|
|
292
177
|
|
|
293
|
-
|
|
178
|
+
```js
|
|
179
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
180
|
+
import { createMarkdownConfigs } from "@fast-china/eslint-config/configs";
|
|
181
|
+
import { defineConfig } from "eslint/config";
|
|
294
182
|
|
|
295
|
-
|
|
183
|
+
export default defineConfig([...createBaseConfigs(), ...createMarkdownConfigs()]);
|
|
184
|
+
```
|
|
296
185
|
|
|
297
|
-
|
|
186
|
+
Lodash 静态导入策略同样独立:
|
|
298
187
|
|
|
299
188
|
```js
|
|
300
|
-
import
|
|
189
|
+
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
301
190
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
rules: {
|
|
305
|
-
"no-console": "warn",
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
files: ["**/{scripts,tests}/**/*.{js,ts}"],
|
|
310
|
-
name: "project/node-files",
|
|
311
|
-
rules: defineRules({ "no-console": "off" }),
|
|
312
|
-
}
|
|
313
|
-
);
|
|
191
|
+
createLodashConfigs("lodash");
|
|
192
|
+
createLodashConfigs("lodash-unified");
|
|
314
193
|
```
|
|
315
194
|
|
|
316
|
-
|
|
195
|
+
## 公共入口
|
|
317
196
|
|
|
318
|
-
|
|
319
|
-
- `@fast-china/eslint-config/constants` 导出项目维护的全部文件 glob。
|
|
320
|
-
- `@fast-china/eslint-config/rules` 导出带完整注释的原始规则记录和 `RuleOptions`。
|
|
197
|
+
根入口只公开:
|
|
321
198
|
|
|
322
|
-
|
|
323
|
-
|
|
199
|
+
- 默认 Vue 3 + TypeScript + UniApp Flat Config。
|
|
200
|
+
- `fastConfig`、`createBaseConfigs`、`FastConfigOptions`。
|
|
201
|
+
- `defineRules`、`RuleOptions`。
|
|
324
202
|
|
|
325
|
-
|
|
326
|
-
import { GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
|
|
203
|
+
高级组合通过职责明确的子路径提供:
|
|
327
204
|
|
|
328
|
-
|
|
329
|
-
|
|
205
|
+
- `@fast-china/eslint-config/configs`:框架和功能配置片段。
|
|
206
|
+
- `@fast-china/eslint-config/constants`:文件 glob 与 UniApp globals。
|
|
207
|
+
- `@fast-china/eslint-config/rules`:带类型的原始规则记录。
|
|
330
208
|
|
|
331
209
|
## Prettier
|
|
332
210
|
|
|
333
|
-
Prettier
|
|
211
|
+
Prettier 不作为 ESLint 规则运行。默认配置只加载 `eslint-config-prettier` 关闭冲突规则;项目需要自行安装并执行格式化:
|
|
334
212
|
|
|
335
213
|
```sh
|
|
336
214
|
pnpm add -D prettier
|
|
337
215
|
pnpm exec prettier --check .
|
|
338
216
|
```
|
|
339
217
|
|
|
340
|
-
如果使用其他格式化工具,或希望保留完整的样式类 ESLint 规则,请设置 `prettier: false`。
|
|
341
|
-
|
|
342
218
|
## 文档
|
|
343
219
|
|
|
344
220
|
- [默认规则与风险指南](./docs/rules-risk.zh.md)
|
|
@@ -356,9 +232,7 @@ pnpm check
|
|
|
356
232
|
pnpm pack --dry-run
|
|
357
233
|
```
|
|
358
234
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
升级 ESLint 或插件后运行 `pnpm typegen` 并提交 `src/typegen.d.ts`;不要手工编辑生成文件。`pnpm test` 会先重新构建发布产物,再分别执行消费者类型契约、运行时集成和发布包契约测试。`pnpm check` 在此基础上增加源码类型检查、全仓 ESLint 和格式验证。
|
|
235
|
+
升级 ESLint 或插件后运行 `pnpm typegen` 并提交 `src/typegen.d.ts`。`pnpm check` 会验证类型、构建、运行时行为、发布包契约、ESLint 和格式。
|
|
362
236
|
|
|
363
237
|
## 开源协议
|
|
364
238
|
|
package/SECURITY.md
CHANGED
|
@@ -9,8 +9,8 @@ Fixes are not backported to unsupported versions.
|
|
|
9
9
|
|
|
10
10
|
| Version | Supported |
|
|
11
11
|
| --------- | --------- |
|
|
12
|
-
| `2.
|
|
13
|
-
| `< 2.0
|
|
12
|
+
| `2.1.x` | Yes |
|
|
13
|
+
| `< 2.1.0` | No |
|
|
14
14
|
|
|
15
15
|
## Reporting a vulnerability
|
|
16
16
|
|
|
@@ -86,8 +86,8 @@ data that is not yours, degrading services, or disrupting other users.
|
|
|
86
86
|
|
|
87
87
|
| 版本 | 是否支持 |
|
|
88
88
|
| --------- | -------- |
|
|
89
|
-
| `2.
|
|
90
|
-
| `< 2.0
|
|
89
|
+
| `2.1.x` | 是 |
|
|
90
|
+
| `< 2.1.0` | 否 |
|
|
91
91
|
|
|
92
92
|
### 报告安全漏洞
|
|
93
93
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
//#region src/configs/angular.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Angular TypeScript 源码与 HTML 模板检查的细分选项。
|
|
4
5
|
*
|
|
5
6
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
* 被启用;未指定的字段继续使用各自默认值。Angular 配置始终包含框架 TypeScript 规则
|
|
7
|
+
* 该对象直接传给 `createAngularConfigs()`。Angular 配置始终包含框架 TypeScript 规则
|
|
8
8
|
* 和外部 `.html` 模板基础规则,本接口只控制成本或迁移影响较高的可选部分。
|
|
9
9
|
*
|
|
10
|
-
* Angular
|
|
11
|
-
*
|
|
10
|
+
* 这些选项不会修改 Angular 编译器、CLI 或模板类型检查配置。调用方应先组合
|
|
11
|
+
* `createBaseConfigs()`,以提供统一的类型感知 TypeScript 配置。
|
|
12
12
|
*/
|
|
13
13
|
interface AngularConfigOptions {
|
|
14
14
|
/**
|
|
@@ -34,13 +34,13 @@ interface AngularConfigOptions {
|
|
|
34
34
|
* 创建 Angular TypeScript、外部 HTML 模板与内联模板配置。
|
|
35
35
|
*
|
|
36
36
|
* @remarks
|
|
37
|
-
* Angular
|
|
37
|
+
* Angular 支持依赖基础配置先注册 typescript-eslint 解析器;模板由
|
|
38
38
|
* Angular 专用 parser 解析,内联模板通过官方 processor 复用同一套 HTML 规则。
|
|
39
39
|
*
|
|
40
40
|
* @param options - 控制内联模板处理与模板无障碍规则的 Angular 选项。
|
|
41
41
|
* @returns 按 TypeScript 源码、外部模板顺序排列的 ESLint Flat Config 数组。
|
|
42
42
|
*/
|
|
43
|
-
declare const createAngularConfigs: ({ inlineTemplates, templateAccessibility }?: AngularConfigOptions) =>
|
|
43
|
+
declare const createAngularConfigs: ({ inlineTemplates, templateAccessibility }?: AngularConfigOptions) => ReturnType<typeof defineConfig>;
|
|
44
44
|
//#endregion
|
|
45
45
|
export { AngularConfigOptions, createAngularConfigs };
|
|
46
46
|
//# sourceMappingURL=angular.d.mts.map
|
package/dist/configs/angular.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { defineConfig } from "eslint/config";
|
|
|
9
9
|
* 创建 Angular TypeScript、外部 HTML 模板与内联模板配置。
|
|
10
10
|
*
|
|
11
11
|
* @remarks
|
|
12
|
-
* Angular
|
|
12
|
+
* Angular 支持依赖基础配置先注册 typescript-eslint 解析器;模板由
|
|
13
13
|
* Angular 专用 parser 解析,内联模板通过官方 processor 复用同一套 HTML 规则。
|
|
14
14
|
*
|
|
15
15
|
* @param options - 控制内联模板处理与模板无障碍规则的 Angular 选项。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.mjs","names":[],"sources":["../../src/configs/angular.ts"],"sourcesContent":["import angularPlugin from \"@angular-eslint/eslint-plugin\";\nimport angularTemplatePlugin from \"@angular-eslint/eslint-plugin-template\";\nimport angularTemplateParser from \"@angular-eslint/template-parser\";\nimport { defineConfig } from \"eslint/config\";\nimport { GLOB_ANGULAR_TEMPLATE, GLOB_ANGULAR_TYPESCRIPT } from \"../constants\";\nimport { angularRules, angularTemplateAccessibilityRules, angularTemplateRules } from \"../rules\";\nimport type { ESLint, Linter } from \"eslint\";\n\n/**\n * Angular TypeScript 源码与 HTML 模板检查的细分选项。\n *\n * @remarks\n *
|
|
1
|
+
{"version":3,"file":"angular.mjs","names":[],"sources":["../../src/configs/angular.ts"],"sourcesContent":["import angularPlugin from \"@angular-eslint/eslint-plugin\";\nimport angularTemplatePlugin from \"@angular-eslint/eslint-plugin-template\";\nimport angularTemplateParser from \"@angular-eslint/template-parser\";\nimport { defineConfig } from \"eslint/config\";\nimport { GLOB_ANGULAR_TEMPLATE, GLOB_ANGULAR_TYPESCRIPT } from \"../constants\";\nimport { angularRules, angularTemplateAccessibilityRules, angularTemplateRules } from \"../rules\";\nimport type { ESLint, Linter } from \"eslint\";\n\n/**\n * Angular TypeScript 源码与 HTML 模板检查的细分选项。\n *\n * @remarks\n * 该对象直接传给 `createAngularConfigs()`。Angular 配置始终包含框架 TypeScript 规则\n * 和外部 `.html` 模板基础规则,本接口只控制成本或迁移影响较高的可选部分。\n *\n * 这些选项不会修改 Angular 编译器、CLI 或模板类型检查配置。调用方应先组合\n * `createBaseConfigs()`,以提供统一的类型感知 TypeScript 配置。\n */\nexport interface AngularConfigOptions {\n\t/**\n\t * 是否使用 Angular 官方 processor,从 TypeScript 文件的\n\t * `@Component({ template: ... })` 元数据中提取内联 HTML 并复用模板规则进行检查。\n\t *\n\t * 关闭后仍会检查 Angular TypeScript 源码和外部 `.html` 模板,只是不再处理组件中的\n\t * 内联模板。大型项目若主要使用外部模板,或 processor 与其他工具发生冲突,可暂时关闭。\n\t * @defaultValue `true`\n\t */\n\tinlineTemplates?: boolean;\n\t/**\n\t * 是否在模板基础正确性规则之外启用 Angular 模板无障碍规则组。\n\t *\n\t * 该规则组检查替代文本、键盘交互、焦点、表单标签和 ARIA 等可访问性问题,适用于\n\t * 外部模板与已提取的内联模板。关闭后仍保留模板语法、严格比较和现代控制流等基础规则。\n\t * 对旧项目而言可能一次产生较多报告,建议在确认迁移计划后再决定是否临时关闭。\n\t * @defaultValue `true`\n\t */\n\ttemplateAccessibility?: boolean;\n}\n\n/**\n * 创建 Angular TypeScript、外部 HTML 模板与内联模板配置。\n *\n * @remarks\n * Angular 支持依赖基础配置先注册 typescript-eslint 解析器;模板由\n * Angular 专用 parser 解析,内联模板通过官方 processor 复用同一套 HTML 规则。\n *\n * @param options - 控制内联模板处理与模板无障碍规则的 Angular 选项。\n * @returns 按 TypeScript 源码、外部模板顺序排列的 ESLint Flat Config 数组。\n */\nexport const createAngularConfigs = ({ inlineTemplates = true, templateAccessibility = true }: AngularConfigOptions = {}): ReturnType<\n\ttypeof defineConfig\n> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: inlineTemplates ? \"@fast-china/angular/typescript-with-inline-templates\" : \"@fast-china/angular/typescript\",\n\t\t\tfiles: [GLOB_ANGULAR_TYPESCRIPT],\n\t\t\tplugins: {\n\t\t\t\t\"@angular-eslint\": angularPlugin as unknown as ESLint.Plugin,\n\t\t\t},\n\t\t\t...(inlineTemplates\n\t\t\t\t? {\n\t\t\t\t\t\tprocessor: angularTemplatePlugin.processors[\"extract-inline-html\"] as Linter.Processor,\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\trules: angularRules,\n\t\t},\n\t\t{\n\t\t\tname: templateAccessibility ? \"@fast-china/angular/template-accessibility\" : \"@fast-china/angular/template\",\n\t\t\tfiles: [GLOB_ANGULAR_TEMPLATE],\n\t\t\tlanguageOptions: {\n\t\t\t\tparser: angularTemplateParser as unknown as Linter.Parser,\n\t\t\t},\n\t\t\tplugins: {\n\t\t\t\t\"@angular-eslint/template\": angularTemplatePlugin as unknown as ESLint.Plugin,\n\t\t\t},\n\t\t\trules: {\n\t\t\t\t...angularTemplateRules,\n\t\t\t\t...(templateAccessibility ? angularTemplateAccessibilityRules : {}),\n\t\t\t},\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;;;;AAiDA,MAAa,wBAAwB,EAAE,kBAAkB,MAAM,wBAAwB,SAA+B,CAAC,MAGtH,aAAa,CACZ;CACC,MAAM,kBAAkB,yDAAyD;CACjF,OAAO,CAAC,uBAAuB;CAC/B,SAAS,EACR,mBAAmB,cACpB;CACA,GAAI,kBACD,EACA,WAAW,sBAAsB,WAAW,uBAC7C,IACC,CAAC;CACJ,OAAO;AACR,GACA;CACC,MAAM,wBAAwB,+CAA+C;CAC7E,OAAO,CAAC,qBAAqB;CAC7B,iBAAiB,EAChB,QAAQ,sBACT;CACA,SAAS,EACR,4BAA4B,sBAC7B;CACA,OAAO;EACN,GAAG;EACH,GAAI,wBAAwB,oCAAoC,CAAC;CAClE;AACD,CACD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
//#region src/configs/common.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* 创建跨 JavaScript、TypeScript 与 Vue 脚本生效的通用配置。
|
|
@@ -9,7 +10,7 @@
|
|
|
9
10
|
* @param files - 应用公共规则的 ESLint glob 列表。
|
|
10
11
|
* @returns 包含公共规则与无效禁用指令检查的 Flat Config 数组。
|
|
11
12
|
*/
|
|
12
|
-
declare const createCommonConfigs: (files?: readonly string[]) =>
|
|
13
|
+
declare const createCommonConfigs: (files?: readonly string[]) => ReturnType<typeof defineConfig>;
|
|
13
14
|
//#endregion
|
|
14
15
|
export { createCommonConfigs };
|
|
15
16
|
//# sourceMappingURL=common.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.mjs","names":[],"sources":["../../src/configs/common.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport { GLOBS_CODE } from \"../constants\";\nimport { commonRules } from \"../rules\";\n\n/**\n * 创建跨 JavaScript、TypeScript 与 Vue 脚本生效的通用配置。\n *\n * @remarks\n * 除公共规则外,这里还把无效的 `eslint-disable` 指令提升为错误,避免规则被移除后\n * 留下长期失效的抑制注释。\n *\n * @param files - 应用公共规则的 ESLint glob 列表。\n * @returns 包含公共规则与无效禁用指令检查的 Flat Config 数组。\n */\nexport const createCommonConfigs = (files: readonly string[] = GLOBS_CODE) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/common\",\n\t\t\tfiles: [...files],\n\t\t\tlinterOptions: {\n\t\t\t\treportUnusedDisableDirectives: \"error\",\n\t\t\t},\n\t\t\trules: commonRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,uBAAuB,QAA2B,eAC9D,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,eAAe,EACd,+BAA+B,QAChC;CACA,OAAO;AACR,CACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.mjs","names":[],"sources":["../../src/configs/common.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport { GLOBS_CODE } from \"../constants\";\nimport { commonRules } from \"../rules\";\n\n/**\n * 创建跨 JavaScript、TypeScript 与 Vue 脚本生效的通用配置。\n *\n * @remarks\n * 除公共规则外,这里还把无效的 `eslint-disable` 指令提升为错误,避免规则被移除后\n * 留下长期失效的抑制注释。\n *\n * @param files - 应用公共规则的 ESLint glob 列表。\n * @returns 包含公共规则与无效禁用指令检查的 Flat Config 数组。\n */\nexport const createCommonConfigs = (files: readonly string[] = GLOBS_CODE): ReturnType<typeof defineConfig> =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/common\",\n\t\t\tfiles: [...files],\n\t\t\tlinterOptions: {\n\t\t\t\treportUnusedDisableDirectives: \"error\",\n\t\t\t},\n\t\t\trules: commonRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,uBAAuB,QAA2B,eAC9D,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,eAAe,EACd,+BAA+B,QAChC;CACA,OAAO;AACR,CACD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import { Linter } from "eslint";
|
|
2
3
|
//#region src/configs/environment.d.ts
|
|
3
4
|
/**
|
|
@@ -12,9 +13,8 @@ type RuntimeEnvironment = "browser" | "node" | "universal";
|
|
|
12
13
|
* 运行时全局变量配置片段的选项。
|
|
13
14
|
*
|
|
14
15
|
* @remarks
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* 范围在源码中具有明确契约;直接组合配置片段时可从 `./configs` 子路径使用。
|
|
16
|
+
* 固定项目组合会根据自身处理的语言和框架传入 `files`、`nodeFiles`。该接口仍保持独立,
|
|
17
|
+
* 以便低层组合明确控制环境片段的文件范围。
|
|
18
18
|
*
|
|
19
19
|
* 应用代码与 Node.js 工程文件使用两个独立 Flat Config 片段,避免浏览器源码无条件获得
|
|
20
20
|
* `process`、`Buffer` 等 Node.js 全局变量,也避免配置文件误报这些合法全局变量未定义。
|
|
@@ -32,8 +32,8 @@ interface EnvironmentConfigOptions {
|
|
|
32
32
|
/**
|
|
33
33
|
* 需要获得所选运行时全局变量的应用代码 glob 列表。
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* 项目组合会把自身负责的 JavaScript、TypeScript 和框架文件范围传入这里。数组会
|
|
36
|
+
* 复制到生成配置中,不会在函数内部修改调用方传入的值。
|
|
37
37
|
* @defaultValue {@link GLOBS_CODE}
|
|
38
38
|
*/
|
|
39
39
|
files?: readonly string[];
|
|
@@ -41,8 +41,7 @@ interface EnvironmentConfigOptions {
|
|
|
41
41
|
* 当前启用且允许作为 Node.js 工程文件执行的脚本扩展名 glob 列表。
|
|
42
42
|
*
|
|
43
43
|
* 每一项都会与内置的配置文件、脚本目录、测试文件和 CLI 文件模式组合为 ESLint
|
|
44
|
-
* Flat Config 的 AND
|
|
45
|
-
* 因自身模式较宽而意外接管 `.ts` 文件。
|
|
44
|
+
* Flat Config 的 AND 文件条件,避免工程文件模式意外接管组合范围之外的扩展名。
|
|
46
45
|
* @defaultValue {@link GLOBS_JAVASCRIPT}
|
|
47
46
|
*/
|
|
48
47
|
nodeFiles?: readonly string[];
|
|
@@ -61,13 +60,24 @@ interface EnvironmentConfigOptions {
|
|
|
61
60
|
*
|
|
62
61
|
* @remarks
|
|
63
62
|
* 返回两个相互独立的 Flat Config 片段:第一个为应用源码配置所选环境和项目级全局
|
|
64
|
-
* 变量;第二个仅命中配置、脚本、测试与 CLI 等工程文件,为它们配置 Node.js
|
|
65
|
-
*
|
|
63
|
+
* 变量;第二个仅命中配置、脚本、测试与 CLI 等工程文件,为它们配置 Node.js 全局变量。
|
|
64
|
+
* Node 工具文件的规则覆写由 {@link createNodeToolingConfigs} 在语言规则之后应用。
|
|
66
65
|
*
|
|
67
66
|
* @param options - 运行时环境、目标文件范围与项目级全局变量。
|
|
68
67
|
* @returns 依次包含应用运行时环境和 Node.js 工程文件环境的 Flat Config 数组。
|
|
69
68
|
*/
|
|
70
|
-
declare const createEnvironmentConfigs: ({ environment, files, nodeFiles, globals: projectGlobals }?: EnvironmentConfigOptions) =>
|
|
69
|
+
declare const createEnvironmentConfigs: ({ environment, files, nodeFiles, globals: projectGlobals }?: EnvironmentConfigOptions) => ReturnType<typeof defineConfig>;
|
|
70
|
+
/**
|
|
71
|
+
* 创建 Node.js 配置、脚本、测试和 CLI 文件的末尾规则覆写。
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* 该片段必须放在 JavaScript 与 TypeScript 规则之后,确保工具文件可以输出日志并使用
|
|
75
|
+
* CommonJS 兼容加载,而不会放宽浏览器业务源码。
|
|
76
|
+
*
|
|
77
|
+
* @param nodeFiles - 当前已启用的 JavaScript/TypeScript 文件 glob。
|
|
78
|
+
* @returns Node 工具文件规则覆写数组。
|
|
79
|
+
*/
|
|
80
|
+
declare const createNodeToolingConfigs: (nodeFiles?: readonly string[]) => ReturnType<typeof defineConfig>;
|
|
71
81
|
//#endregion
|
|
72
|
-
export { EnvironmentConfigOptions, RuntimeEnvironment, createEnvironmentConfigs };
|
|
82
|
+
export { EnvironmentConfigOptions, RuntimeEnvironment, createEnvironmentConfigs, createNodeToolingConfigs };
|
|
73
83
|
//# sourceMappingURL=environment.d.mts.map
|