@fast-china/eslint-config 2.0.10 → 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 +31 -0
- package/CONTRIBUTING.md +8 -7
- package/README.md +106 -236
- package/README.zh.md +103 -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 +35 -216
- package/dist/index.mjs +52 -108
- 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,317 +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
|
-
import { defineConfig } from "eslint/config";
|
|
49
|
-
|
|
50
43
|
import fastChina from "@fast-china/eslint-config";
|
|
51
44
|
|
|
52
|
-
export default
|
|
45
|
+
export default fastChina;
|
|
53
46
|
```
|
|
54
47
|
|
|
55
|
-
|
|
48
|
+
默认入口固定包含:
|
|
56
49
|
|
|
57
|
-
|
|
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 冲突关闭层。
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
ESLint 不执行 UniApp 的 `#ifdef`/`#endif`,因此只能识别平台对象,不能验证对象是否位于正确的平台分支。当前不处理需要专用解析器的 `.uvue` 与 `.uts`。
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
## `fastConfig()`
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
根工厂只保留 `environment`,默认值为 `"browser"`:
|
|
64
61
|
|
|
65
62
|
```js
|
|
66
63
|
import { fastConfig } from "@fast-china/eslint-config";
|
|
67
64
|
|
|
68
65
|
export default fastConfig({
|
|
69
|
-
|
|
70
|
-
vue: false,
|
|
66
|
+
environment: "universal",
|
|
71
67
|
});
|
|
72
68
|
```
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
#### Angular
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
import { fastConfig } from "@fast-china/eslint-config";
|
|
80
|
-
|
|
81
|
-
export default fastConfig({
|
|
82
|
-
angular: true,
|
|
83
|
-
vue: false,
|
|
84
|
-
});
|
|
85
|
-
```
|
|
70
|
+
可选值:
|
|
86
71
|
|
|
87
|
-
|
|
72
|
+
| 值 | 应用源码 globals |
|
|
73
|
+
| ------------- | ---------------- |
|
|
74
|
+
| `"browser"` | 浏览器 |
|
|
75
|
+
| `"node"` | Node.js |
|
|
76
|
+
| `"universal"` | 浏览器和 Node.js |
|
|
88
77
|
|
|
89
|
-
|
|
90
|
-
export default fastConfig({
|
|
91
|
-
angular: {
|
|
92
|
-
inlineTemplates: true,
|
|
93
|
-
templateAccessibility: true,
|
|
94
|
-
},
|
|
95
|
-
vue: false,
|
|
96
|
-
});
|
|
97
|
-
```
|
|
78
|
+
配置文件、脚本、测试和 CLI 文件始终单独获得 Node.js globals,并允许必要的 `console` 和 CommonJS 兼容加载。
|
|
98
79
|
|
|
99
|
-
|
|
80
|
+
## 项目覆写
|
|
100
81
|
|
|
101
|
-
|
|
82
|
+
规则、globals、ignores 和解析器特殊设置直接使用后置 Flat Config,不再包装成根工厂选项:
|
|
102
83
|
|
|
103
84
|
```js
|
|
104
|
-
import { fastConfig } from "@fast-china/eslint-config";
|
|
85
|
+
import { defineRules, fastConfig } from "@fast-china/eslint-config";
|
|
105
86
|
|
|
106
|
-
export default fastConfig(
|
|
107
|
-
environment: "
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
);
|
|
110
107
|
```
|
|
111
108
|
|
|
112
|
-
|
|
109
|
+
后置配置拥有最高优先级。`defineRules()` 不修改对象,只提供精确的规则类型检查。
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
import { fastConfig } from "@fast-china/eslint-config";
|
|
116
|
-
|
|
117
|
-
export default fastConfig({
|
|
118
|
-
environment: "node",
|
|
119
|
-
json: false,
|
|
120
|
-
markdown: false,
|
|
121
|
-
typescript: false,
|
|
122
|
-
vue: false,
|
|
123
|
-
});
|
|
124
|
-
```
|
|
111
|
+
## TypeScript
|
|
125
112
|
|
|
126
|
-
|
|
113
|
+
`createTypeScriptConfigs()`、Vue SFC 和 React TSX 始终使用 `recommendedTypeChecked` 与:
|
|
127
114
|
|
|
128
115
|
```js
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
typescript: {
|
|
133
|
-
tsconfigRootDir: import.meta.dirname,
|
|
134
|
-
typeChecked: true,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
116
|
+
parserOptions: {
|
|
117
|
+
projectService: true,
|
|
118
|
+
}
|
|
137
119
|
```
|
|
138
120
|
|
|
139
|
-
|
|
121
|
+
被检查文件必须属于可发现的 `tsconfig.json`。不再提供 `typeChecked` 和 `tsconfigRootDir` 包装选项;复杂 monorepo 如需指定根目录,可在后置 Flat Config 中直接覆盖 `languageOptions.parserOptions`。
|
|
140
122
|
|
|
141
|
-
|
|
123
|
+
## React
|
|
142
124
|
|
|
143
|
-
|
|
125
|
+
React 项目从不绑定框架的基础配置开始组合:
|
|
144
126
|
|
|
145
127
|
```js
|
|
128
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
129
|
+
import { createReactConfigs } from "@fast-china/eslint-config/configs";
|
|
146
130
|
import { defineConfig } from "eslint/config";
|
|
147
131
|
|
|
148
|
-
|
|
149
|
-
createCommonConfigs,
|
|
150
|
-
createEnvironmentConfigs,
|
|
151
|
-
createGitignoreConfigs,
|
|
152
|
-
createGlobalIgnores,
|
|
153
|
-
createImportConfigs,
|
|
154
|
-
createJavaScriptConfigs,
|
|
155
|
-
createPrettierConfigs,
|
|
156
|
-
createReactConfigs,
|
|
157
|
-
createRegexpConfigs,
|
|
158
|
-
createTypeScriptConfigs,
|
|
159
|
-
} from "@fast-china/eslint-config/configs";
|
|
160
|
-
import { GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
|
|
161
|
-
|
|
162
|
-
const codeFiles = [...GLOBS_JAVASCRIPT, ...GLOBS_TYPESCRIPT];
|
|
163
|
-
|
|
164
|
-
export default defineConfig([
|
|
165
|
-
...createGlobalIgnores(),
|
|
166
|
-
...createGitignoreConfigs(),
|
|
167
|
-
...createEnvironmentConfigs({ environment: "browser", files: codeFiles, nodeFiles: codeFiles }),
|
|
168
|
-
...createCommonConfigs(codeFiles),
|
|
169
|
-
...createJavaScriptConfigs(),
|
|
170
|
-
...createImportConfigs(codeFiles),
|
|
171
|
-
...createRegexpConfigs(codeFiles),
|
|
172
|
-
...createTypeScriptConfigs(),
|
|
173
|
-
...createReactConfigs({}, { javascript: true, typescript: true }),
|
|
174
|
-
...createPrettierConfigs(),
|
|
175
|
-
]);
|
|
132
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs()]);
|
|
176
133
|
```
|
|
177
134
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
## 配置选项
|
|
181
|
-
|
|
182
|
-
| 选项 | 默认值 | 作用 |
|
|
183
|
-
| ----------------- | ----------- | -------------------------------------------------------------- |
|
|
184
|
-
| `angular` | `false` | 启用 Angular TypeScript 与模板,或传入 Angular 专用选项。 |
|
|
185
|
-
| `environment` | `"browser"` | 可选 `"browser"`、`"node"` 或 `"universal"` 全局变量。 |
|
|
186
|
-
| `globals` | 无 | 增加项目宿主、测试运行器等提供的全局变量。 |
|
|
187
|
-
| `gitignore` | `true` | 读取项目根目录的 `.gitignore`。 |
|
|
188
|
-
| `ignores` | `[]` | 追加项目自己的全局忽略模式。 |
|
|
189
|
-
| `imports` | `true` | 启用 import-x 正确性与排序规则。 |
|
|
190
|
-
| `javascript` | `true` | 处理 JavaScript 与 JSX。 |
|
|
191
|
-
| `json` | `true` | 启用 JSON、JSONC 与 JSON5 推荐规则。 |
|
|
192
|
-
| `markdown` | `true` | 启用官方 Markdown 语言规则。 |
|
|
193
|
-
| `prettier` | `true` | 关闭与 Prettier 冲突的 ESLint 规则。 |
|
|
194
|
-
| `react` | `false` | 启用 React、JSX 与 Hooks,或传入运行时和 React 版本设置。 |
|
|
195
|
-
| `regexp` | `true` | 启用推荐的正则表达式规则。 |
|
|
196
|
-
| `rules` | 无 | 对所有已启用代码文件追加具有精确类型的项目规则。 |
|
|
197
|
-
| `sortPackageJson` | `true` | 按安全白名单排序 `package.json`,不会进入 `exports` 条件对象。 |
|
|
198
|
-
| `sortTsconfig` | `true` | 按 TypeScript 文档主题排序 `tsconfig*.json`。 |
|
|
199
|
-
| `typescript` | `true` | 可关闭,或传入 `{ typeChecked: true, tsconfigRootDir }`。 |
|
|
200
|
-
| `vue` | `true` | 启用 Vue 3 单文件组件支持。 |
|
|
201
|
-
|
|
202
|
-
## 框架覆盖范围
|
|
203
|
-
|
|
204
|
-
Vue 3、React 与 Angular 都有专用解析器或处理器、推荐规则、配置选项、生成规则类型与集成测试。Nuxt 可使用 Vue 基础配置;Next.js 与 Remix 可使用 React 基础配置,并在 `fastConfig()` 后追加各自的框架 Flat Config。兼容 React 的 JSX 运行时可以使用 `react.importSource`。
|
|
205
|
-
|
|
206
|
-
Svelte、Astro 与 Solid 具有不同的模板或编译器语义,目前不会被包装成名义上的“一键支持”。项目已经可以把它们的官方 Flat Config 作为末尾覆写传入;将来只有在解析器、处理器、规则 schema、文档和真实运行时 fixture 一并完成时,才会增加对应的一等开关。
|
|
207
|
-
|
|
208
|
-
## Lodash 导入策略
|
|
135
|
+
基础配置提供统一的 JavaScript、类型感知 TypeScript、JSON、Import、RegExp、清单排序和 Prettier 兼容层;React 片段追加 `@eslint-react`、React 官方 Hooks Recommended 和 DOM 安全规则,不会加载 Vue 或 UniApp globals。
|
|
209
136
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
- `createLodashConfigs("lodash-unified")`:禁止从 `lodash`、`lodash-es` 及其子路径静态导入或重新导出。
|
|
213
|
-
- `createLodashConfigs("lodash")`:禁止从 `lodash-es`、`lodash-unified` 及其子路径静态导入或重新导出;允许 `lodash` 根入口和 `lodash/*` 按方法导入。
|
|
214
|
-
|
|
215
|
-
选择 `lodash-unified`:
|
|
216
|
-
|
|
217
|
-
```sh
|
|
218
|
-
pnpm add lodash-unified
|
|
219
|
-
```
|
|
137
|
+
Preact 等兼容运行时可以传入 React 识别设置:
|
|
220
138
|
|
|
221
139
|
```js
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
import fastChina from "@fast-china/eslint-config";
|
|
225
|
-
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
226
|
-
import { cloneDeep, debounce } from "lodash-unified";
|
|
227
|
-
|
|
228
|
-
export default defineConfig([...fastChina, ...createLodashConfigs("lodash-unified")]);
|
|
140
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs({ importSource: "preact", version: "detect" })]);
|
|
229
141
|
```
|
|
230
142
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
```sh
|
|
234
|
-
pnpm add lodash
|
|
235
|
-
pnpm add -D @types/lodash
|
|
236
|
-
```
|
|
143
|
+
## Angular
|
|
237
144
|
|
|
238
145
|
```js
|
|
146
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
147
|
+
import { createAngularConfigs } from "@fast-china/eslint-config/configs";
|
|
239
148
|
import { defineConfig } from "eslint/config";
|
|
240
149
|
|
|
241
|
-
|
|
242
|
-
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
243
|
-
import debounce from "lodash/debounce";
|
|
244
|
-
|
|
245
|
-
export default defineConfig([...fastChina, ...createLodashConfigs("lodash")]);
|
|
150
|
+
export default defineConfig([...createBaseConfigs(), ...createAngularConfigs()]);
|
|
246
151
|
```
|
|
247
152
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
如果后续 `rules` 或文件级覆写再次设置 `no-restricted-imports`,ESLint 会用后面的完整规则替换这套策略,而不是合并选项。需要组合更多包限制时,可从 `@fast-china/eslint-config/rules` 导入原始 `preferLodashRules` 或 `preferLodashUnifiedRules`,统一维护一份完整规则。
|
|
251
|
-
|
|
252
|
-
## 精确规则类型与自动补全
|
|
253
|
-
|
|
254
|
-
本包根据 ESLint 核心规则和所有随包插件公开的 JSON Schema 生成 `RuleOptions`,并提供不会改变运行时对象的 `defineRules()`。在输入规则名、严重级别或选项时,TypeScript 与支持类型分析的编辑器会给出补全;拼错规则名或填写无效选项时会立即报错。
|
|
153
|
+
Angular 片段检查 TypeScript 源码、外部 HTML 模板和组件内联模板,默认启用官方模板无障碍规则。特殊项目仍可配置:
|
|
255
154
|
|
|
256
155
|
```js
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const projectRules = defineRules({
|
|
261
|
-
"@angular-eslint/template/alt-text": "error",
|
|
262
|
-
"@eslint-react/dom-no-missing-button-type": "error",
|
|
263
|
-
"@typescript-eslint/no-unused-vars": ["error", { args: "after-used" }],
|
|
264
|
-
"import-x/order": ["error", { "newlines-between": "never" }],
|
|
265
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
266
|
-
"vue/attributes-order": ["error", { order: ["DEFINITION", "EVENTS", "CONTENT"] }],
|
|
156
|
+
createAngularConfigs({
|
|
157
|
+
inlineTemplates: false,
|
|
158
|
+
templateAccessibility: false,
|
|
267
159
|
});
|
|
268
|
-
|
|
269
|
-
export default fastConfig(
|
|
270
|
-
{ rules: projectRules },
|
|
271
|
-
{
|
|
272
|
-
files: ["**/*.generated.ts"],
|
|
273
|
-
name: "project/generated",
|
|
274
|
-
rules: defineRules({ "@typescript-eslint/no-unused-vars": "off" }),
|
|
275
|
-
}
|
|
276
|
-
);
|
|
277
160
|
```
|
|
278
161
|
|
|
279
|
-
|
|
162
|
+
## Node.js / SDK
|
|
280
163
|
|
|
281
|
-
|
|
282
|
-
import type { RuleOptions } from "@fast-china/eslint-config";
|
|
164
|
+
不需要 Vue、UniApp、React 或 Angular 的项目直接使用基础配置:
|
|
283
165
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
166
|
+
```js
|
|
167
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
168
|
+
|
|
169
|
+
export default createBaseConfigs({ environment: "node" });
|
|
287
170
|
```
|
|
288
171
|
|
|
289
|
-
|
|
172
|
+
`createBaseConfigs()` 固定启用 JavaScript、类型感知 TypeScript、JSON、Import、RegExp、清单排序、`.gitignore` 和 Prettier 兼容层,但不接管任何框架文件。
|
|
290
173
|
|
|
291
|
-
##
|
|
174
|
+
## Markdown 与 Lodash
|
|
292
175
|
|
|
293
|
-
|
|
176
|
+
Markdown 需要显式组合:
|
|
294
177
|
|
|
295
|
-
|
|
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";
|
|
296
182
|
|
|
297
|
-
|
|
183
|
+
export default defineConfig([...createBaseConfigs(), ...createMarkdownConfigs()]);
|
|
184
|
+
```
|
|
298
185
|
|
|
299
|
-
|
|
186
|
+
Lodash 静态导入策略同样独立:
|
|
300
187
|
|
|
301
188
|
```js
|
|
302
|
-
import {
|
|
189
|
+
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
303
190
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
rules: {
|
|
307
|
-
"no-console": "warn",
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
files: ["**/{scripts,tests}/**/*.{js,ts}"],
|
|
312
|
-
name: "project/node-files",
|
|
313
|
-
rules: defineRules({ "no-console": "off" }),
|
|
314
|
-
}
|
|
315
|
-
);
|
|
191
|
+
createLodashConfigs("lodash");
|
|
192
|
+
createLodashConfigs("lodash-unified");
|
|
316
193
|
```
|
|
317
194
|
|
|
318
|
-
|
|
195
|
+
## 公共入口
|
|
319
196
|
|
|
320
|
-
|
|
321
|
-
- `@fast-china/eslint-config/constants` 导出项目维护的全部文件 glob。
|
|
322
|
-
- `@fast-china/eslint-config/rules` 导出带完整注释的原始规则记录和 `RuleOptions`。
|
|
197
|
+
根入口只公开:
|
|
323
198
|
|
|
324
|
-
|
|
325
|
-
|
|
199
|
+
- 默认 Vue 3 + TypeScript + UniApp Flat Config。
|
|
200
|
+
- `fastConfig`、`createBaseConfigs`、`FastConfigOptions`。
|
|
201
|
+
- `defineRules`、`RuleOptions`。
|
|
326
202
|
|
|
327
|
-
|
|
328
|
-
import { GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
|
|
203
|
+
高级组合通过职责明确的子路径提供:
|
|
329
204
|
|
|
330
|
-
|
|
331
|
-
|
|
205
|
+
- `@fast-china/eslint-config/configs`:框架和功能配置片段。
|
|
206
|
+
- `@fast-china/eslint-config/constants`:文件 glob 与 UniApp globals。
|
|
207
|
+
- `@fast-china/eslint-config/rules`:带类型的原始规则记录。
|
|
332
208
|
|
|
333
209
|
## Prettier
|
|
334
210
|
|
|
335
|
-
Prettier
|
|
211
|
+
Prettier 不作为 ESLint 规则运行。默认配置只加载 `eslint-config-prettier` 关闭冲突规则;项目需要自行安装并执行格式化:
|
|
336
212
|
|
|
337
213
|
```sh
|
|
338
214
|
pnpm add -D prettier
|
|
339
215
|
pnpm exec prettier --check .
|
|
340
216
|
```
|
|
341
217
|
|
|
342
|
-
如果使用其他格式化工具,或希望保留完整的样式类 ESLint 规则,请设置 `prettier: false`。
|
|
343
|
-
|
|
344
218
|
## 文档
|
|
345
219
|
|
|
346
220
|
- [默认规则与风险指南](./docs/rules-risk.zh.md)
|
|
@@ -358,9 +232,7 @@ pnpm check
|
|
|
358
232
|
pnpm pack --dry-run
|
|
359
233
|
```
|
|
360
234
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
升级 ESLint 或插件后运行 `pnpm typegen` 并提交 `src/typegen.d.ts`;不要手工编辑生成文件。`pnpm test` 会先重新构建发布产物,再分别执行消费者类型契约、运行时集成和发布包契约测试。`pnpm check` 在此基础上增加源码类型检查、全仓 ESLint 和格式验证。
|
|
235
|
+
升级 ESLint 或插件后运行 `pnpm typegen` 并提交 `src/typegen.d.ts`。`pnpm check` 会验证类型、构建、运行时行为、发布包契约、ESLint 和格式。
|
|
364
236
|
|
|
365
237
|
## 开源协议
|
|
366
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
|