@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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,37 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Expanded the inline documentation for local ESLint rules and scoped overrides, including their purpose, important exceptions, and ownership of duplicate React checks.
|
|
12
|
+
|
|
13
|
+
## 2.1.0 - 2026-08-26
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Added built-in UniApp support for `.nvue`, cross-platform and conditional-platform runtime globals, comment-compatible `pages.json` and `manifest.json`, and generated `unpackage` output ignores.
|
|
18
|
+
- Added a trailing Node.js tooling override that permits logging and CommonJS interoperability in config, script, test, and CLI files.
|
|
19
|
+
- Added root-exported `createBaseConfigs()` as a fixed, framework-neutral composition for React, Angular, Node.js, and SDK projects.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Replaced project-type strictness with one shared rule set for SDKs, OA systems, administration apps, Vue web apps, and clients.
|
|
24
|
+
- Changed the root entry to a fixed Vue 3, type-aware TypeScript, and UniApp preset; `fastConfig()` now retains only the runtime `environment` option and trailing Flat Config overrides.
|
|
25
|
+
- Changed TypeScript, Vue, and React TypeScript to always use `recommendedTypeChecked` and Project Service.
|
|
26
|
+
- Required explicit parameter and return types at exported TypeScript module boundaries without forcing return annotations on internal functions and callbacks.
|
|
27
|
+
- Changed Vue to inherit `flat/recommended`, enforce kebab-case template attributes, warn on `v-html`, and reject `v-text`/`v-html` on components.
|
|
28
|
+
- Replaced the full RegExp recommended preset with an explicit correctness and safety rule set.
|
|
29
|
+
- Restored JavaScript conventions including camelCase, declaration order, arrow callbacks, logical assignment, object spread, object shorthand, rest/spread, and template literals.
|
|
30
|
+
- Restored `sort-imports`; import ordering is an error again and includes side-effect imports.
|
|
31
|
+
- Enabled the official React Hooks Recommended preset and aligned Angular TypeScript, template, and accessibility rules with the Angular ESLint recommended presets.
|
|
32
|
+
- Enabled `package.json` and `tsconfig*.json` sorting in the fixed root and base compositions; Markdown remains explicitly composed.
|
|
33
|
+
- Corrected the built-in dependency ignore glob so both `.pnpm-store` and `node_modules` are matched without relying on `.gitignore`.
|
|
34
|
+
- Allowed JSONC comments in both VS Code `.vscode/settings.json` and `.vscode/extensions.json`.
|
|
35
|
+
|
|
36
|
+
### Removed
|
|
37
|
+
|
|
38
|
+
- Removed `defaultConfigOptions`, root language/framework/plugin switches, factory-level rules/globals/ignores, `typeChecked`, and `tsconfigRootDir`. Native trailing Flat Config and focused factories replace these wrapper options.
|
|
39
|
+
|
|
9
40
|
## 2.0.10 - 2026-08-19
|
|
10
41
|
|
|
11
42
|
### Changed
|
package/CONTRIBUTING.md
CHANGED
|
@@ -27,13 +27,14 @@ Use `pnpm lint:fix` and `pnpm format` for safe mechanical fixes. `pnpm test` fir
|
|
|
27
27
|
2. Scope every rule group with `files` unless it is intentionally global.
|
|
28
28
|
3. Register each plugin in a configuration that matches the same files as its rules.
|
|
29
29
|
4. Prefer upstream recommended configs before adding local overrides.
|
|
30
|
-
5.
|
|
31
|
-
6.
|
|
32
|
-
7.
|
|
33
|
-
8.
|
|
34
|
-
9.
|
|
35
|
-
10.
|
|
36
|
-
11.
|
|
30
|
+
5. Preserve the documented JavaScript, TypeScript, and Vue behavior unless a release explicitly changes it; keep historical comparisons in the changelog rather than source comments.
|
|
31
|
+
6. Keep organization-specific dependency restrictions out of this general-purpose package; projects should own those policies.
|
|
32
|
+
7. Explain the purpose, rationale, and important exception or risk immediately above every local rule override.
|
|
33
|
+
8. Document every default rule's severity and valid exceptions; verify `meta.fixable` before using `[可自动修复]`, and keep `docs/rules-risk.md` plus `docs/rules-risk.zh.md` synchronized.
|
|
34
|
+
9. Never sort a map whose key order has semantics, including conditional objects under `package.json#exports`.
|
|
35
|
+
10. Regenerate `src/typegen.d.ts` whenever ESLint or a bundled plugin changes; confirm new rules and changed option schemas intentionally.
|
|
36
|
+
11. Add or update an integration test for every parser, plugin, option, auto-fix, generated type, or public export change. The root API is intentionally limited to the default config, `fastConfig`, `defineRules`, and related types.
|
|
37
|
+
12. Document behavior changes in `CHANGELOG.md` and both README files.
|
|
37
38
|
|
|
38
39
|
## Pull requests
|
|
39
40
|
|
package/README.md
CHANGED
|
@@ -8,21 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
# @fast-china/eslint-config
|
|
10
10
|
|
|
11
|
-
A practical
|
|
11
|
+
A practical ESLint Flat Config for Vue 3, UniApp, React, Angular, Vite, TypeScript, and JavaScript projects.
|
|
12
12
|
|
|
13
|
-
[](https://www.npmjs.com/package/@fast-china/eslint-config) [](https://www.npmjs.com/package/@fast-china/eslint-config) [](https://nodejs.org/) [](https://eslint.org/) [](./LICENSE)
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Features
|
|
16
16
|
|
|
17
|
-
- Built for ESLint 10 and
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- An opt-in Lodash policy keeps projects on either `lodash` or `lodash-unified` without mixing package entry points.
|
|
17
|
+
- Built for ESLint 10 and native Flat Config only.
|
|
18
|
+
- The root entry is a fixed Vue 3 + TypeScript + UniApp preset with no language or plugin switches.
|
|
19
|
+
- TypeScript, Vue, and React TypeScript always use type-aware recommended rules and Project Service.
|
|
20
|
+
- SDKs, OA systems, administration apps, and clients use one JavaScript, TypeScript, Import, and RegExp rule set with no strictness tiers.
|
|
21
|
+
- JavaScript, TypeScript, Vue/`.nvue`, UniApp globals, JSON dialects, Import, RegExp, manifest sorting, `.gitignore`, and Prettier compatibility are enabled by default.
|
|
22
|
+
- React, Angular, Markdown, and Lodash policies compose explicitly from `@fast-china/eslint-config/configs`.
|
|
23
|
+
- Schema-generated `RuleOptions` provides exact rule-name and option completion.
|
|
24
|
+
- Plugins and parsers are direct package dependencies, so consumers do not assemble a plugin dependency tree.
|
|
26
25
|
|
|
27
26
|
## Requirements
|
|
28
27
|
|
|
@@ -30,321 +29,194 @@ A practical, typed ESLint Flat Config for Vue 3, React, Angular, Vite, TypeScrip
|
|
|
30
29
|
- ESLint `^10.0.0`
|
|
31
30
|
- TypeScript `^6.0.0`
|
|
32
31
|
|
|
33
|
-
These versions follow the runtime requirements of ESLint 10 and the included language plugins.
|
|
34
|
-
|
|
35
32
|
## Installation
|
|
36
33
|
|
|
37
34
|
```sh
|
|
38
35
|
pnpm add -D eslint typescript @fast-china/eslint-config
|
|
39
36
|
```
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## Quick start: Vue 3 + Vite
|
|
38
|
+
## Vue 3 / UniApp quick start
|
|
44
39
|
|
|
45
40
|
Create `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
|
+
The default entry includes:
|
|
56
49
|
|
|
57
|
-
|
|
50
|
+
- Browser globals plus dedicated Node.js globals for tooling files.
|
|
51
|
+
- JavaScript, type-aware TypeScript, Vue 3, and `.nvue`.
|
|
52
|
+
- `uni`, `uniCloud`, page APIs, and conditional-platform globals such as `wx`, `plus`, `my`, and `tt`.
|
|
53
|
+
- JSON, JSONC, JSON5, comment-compatible `pages.json`, `manifest.json`, and VS Code `settings.json` and `extensions.json`.
|
|
54
|
+
- Import, RegExp, `package.json`/`tsconfig*.json` sorting, `.gitignore`, and Prettier conflict handling.
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
ESLint does not execute UniApp `#ifdef`/`#endif` directives. It recognizes platform objects but cannot verify that they are used in the correct platform branch. `.uvue` and `.uts`, which require dedicated parsers, are not handled.
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
## `fastConfig()`
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
The root factory retains only `environment`, whose default is `"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
|
-
|
|
70
|
+
| Value | Application globals |
|
|
71
|
+
| ------------- | ------------------- |
|
|
72
|
+
| `"browser"` | Browser |
|
|
73
|
+
| `"node"` | Node.js |
|
|
74
|
+
| `"universal"` | Browser and Node.js |
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
import { fastConfig } from "@fast-china/eslint-config";
|
|
76
|
+
Config, script, test, and CLI files always receive Node.js globals and allow necessary logging and CommonJS interoperability.
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
angular: true,
|
|
83
|
-
vue: false,
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Angular support checks framework TypeScript, external `.html` templates, and inline component templates. Template accessibility and inline-template extraction are enabled by default:
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
export default fastConfig({
|
|
91
|
-
angular: {
|
|
92
|
-
inlineTemplates: true,
|
|
93
|
-
templateAccessibility: true,
|
|
94
|
-
},
|
|
95
|
-
vue: false,
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Angular requires the TypeScript integration; `angular: true` together with `typescript: false` fails early with a clear configuration error.
|
|
78
|
+
## Project overrides
|
|
100
79
|
|
|
101
|
-
|
|
80
|
+
Rules, globals, ignores, and special parser settings use trailing Flat Config objects instead of root factory options:
|
|
102
81
|
|
|
103
82
|
```js
|
|
104
|
-
import { fastConfig } from "@fast-china/eslint-config";
|
|
83
|
+
import { defineRules, fastConfig } from "@fast-china/eslint-config";
|
|
105
84
|
|
|
106
|
-
export default fastConfig(
|
|
107
|
-
environment: "
|
|
108
|
-
|
|
109
|
-
|
|
85
|
+
export default fastConfig(
|
|
86
|
+
{ environment: "browser" },
|
|
87
|
+
{
|
|
88
|
+
ignores: ["public/vendor/**"],
|
|
89
|
+
languageOptions: {
|
|
90
|
+
globals: {
|
|
91
|
+
__APP_VERSION__: "readonly",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
rules: defineRules({
|
|
95
|
+
"no-console": "warn",
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
files: ["**/*.generated.ts"],
|
|
100
|
+
rules: defineRules({
|
|
101
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
102
|
+
}),
|
|
103
|
+
}
|
|
104
|
+
);
|
|
110
105
|
```
|
|
111
106
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
```js
|
|
115
|
-
import { fastConfig } from "@fast-china/eslint-config";
|
|
107
|
+
Trailing configs have the highest precedence. `defineRules()` leaves the object unchanged and only adds exact type checking.
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
environment: "node",
|
|
119
|
-
json: false,
|
|
120
|
-
markdown: false,
|
|
121
|
-
typescript: false,
|
|
122
|
-
vue: false,
|
|
123
|
-
});
|
|
124
|
-
```
|
|
109
|
+
## TypeScript
|
|
125
110
|
|
|
126
|
-
|
|
111
|
+
`createTypeScriptConfigs()`, Vue SFCs, and React TSX always use `recommendedTypeChecked` with:
|
|
127
112
|
|
|
128
113
|
```js
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
typescript: {
|
|
133
|
-
tsconfigRootDir: import.meta.dirname,
|
|
134
|
-
typeChecked: true,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
114
|
+
parserOptions: {
|
|
115
|
+
projectService: true,
|
|
116
|
+
}
|
|
137
117
|
```
|
|
138
118
|
|
|
139
|
-
|
|
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.
|
|
140
120
|
|
|
141
|
-
|
|
121
|
+
## React
|
|
142
122
|
|
|
143
|
-
|
|
123
|
+
React projects compose from the framework-neutral base:
|
|
144
124
|
|
|
145
125
|
```js
|
|
126
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
127
|
+
import { createReactConfigs } from "@fast-china/eslint-config/configs";
|
|
146
128
|
import { defineConfig } from "eslint/config";
|
|
147
129
|
|
|
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
|
-
]);
|
|
130
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs()]);
|
|
176
131
|
```
|
|
177
132
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
## Options
|
|
181
|
-
|
|
182
|
-
| Option | Default | Purpose |
|
|
183
|
-
| ----------------- | ----------- | -------------------------------------------------------------------------- |
|
|
184
|
-
| `angular` | `false` | Enable Angular TypeScript and templates, or pass Angular-specific options. |
|
|
185
|
-
| `environment` | `"browser"` | Use `"browser"`, `"node"`, or `"universal"` globals. |
|
|
186
|
-
| `globals` | none | Add globals supplied by a host platform or test runner. |
|
|
187
|
-
| `gitignore` | `true` | Read ignore patterns from the project `.gitignore`. |
|
|
188
|
-
| `ignores` | `[]` | Append project-specific global ignore patterns. |
|
|
189
|
-
| `imports` | `true` | Enable import-x correctness and ordering rules. |
|
|
190
|
-
| `javascript` | `true` | Process JavaScript and JSX files. |
|
|
191
|
-
| `json` | `true` | Enable recommended JSON, JSONC, and JSON5 rules. |
|
|
192
|
-
| `markdown` | `true` | Enable the official Markdown language rules. |
|
|
193
|
-
| `prettier` | `true` | Disable ESLint rules that conflict with Prettier. |
|
|
194
|
-
| `react` | `false` | Enable React/JSX/Hooks, or pass runtime and React-version settings. |
|
|
195
|
-
| `regexp` | `true` | Enable recommended RegExp rules. |
|
|
196
|
-
| `rules` | none | Add exactly typed project rules to every enabled code file. |
|
|
197
|
-
| `sortPackageJson` | `true` | Sort safe package.json keys without entering conditional `exports`. |
|
|
198
|
-
| `sortTsconfig` | `true` | Sort `tsconfig*.json` by TypeScript documentation topics. |
|
|
199
|
-
| `typescript` | `true` | Disable it or pass `{ typeChecked: true, tsconfigRootDir }`. |
|
|
200
|
-
| `vue` | `true` | Enable Vue 3 single-file components. |
|
|
201
|
-
|
|
202
|
-
## Framework coverage
|
|
203
|
-
|
|
204
|
-
Vue 3, React, and Angular have dedicated parsers or processors, presets, options, generated rule types, and integration tests. Nuxt can use the Vue base; Next.js and Remix can use the React base, then append their framework-specific Flat Config after `fastConfig()` when needed. React-compatible JSX runtimes can use `react.importSource`.
|
|
205
|
-
|
|
206
|
-
Svelte, Astro, and Solid use different template or compiler semantics and are not presented as first-class integrations yet. Their official Flat Config can already be appended as a trailing override, but first-class switches should only be added together with the correct parser, processor, rule schemas, documentation, and runtime fixtures.
|
|
207
|
-
|
|
208
|
-
## Lodash import policy
|
|
133
|
+
The base provides the shared JavaScript, type-aware TypeScript, JSON, Import, RegExp, manifest sorting, and Prettier compatibility. The React fragment adds `@eslint-react`, the official Hooks Recommended preset, and DOM safety rules without loading Vue or UniApp globals.
|
|
209
134
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
- `createLodashConfigs("lodash-unified")` rejects static imports and re-exports from `lodash`, `lodash-es`, and their subpaths.
|
|
213
|
-
- `createLodashConfigs("lodash")` rejects static imports and re-exports from `lodash-es`, `lodash-unified`, and their subpaths. The `lodash` root and `lodash/*` method imports remain valid.
|
|
214
|
-
|
|
215
|
-
Choose `lodash-unified`:
|
|
216
|
-
|
|
217
|
-
```sh
|
|
218
|
-
pnpm add lodash-unified
|
|
219
|
-
```
|
|
135
|
+
React-compatible runtimes can pass recognition settings:
|
|
220
136
|
|
|
221
137
|
```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")]);
|
|
138
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs({ importSource: "preact", version: "detect" })]);
|
|
229
139
|
```
|
|
230
140
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
```sh
|
|
234
|
-
pnpm add lodash
|
|
235
|
-
pnpm add -D @types/lodash
|
|
236
|
-
```
|
|
141
|
+
## Angular
|
|
237
142
|
|
|
238
143
|
```js
|
|
144
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
145
|
+
import { createAngularConfigs } from "@fast-china/eslint-config/configs";
|
|
239
146
|
import { defineConfig } from "eslint/config";
|
|
240
147
|
|
|
241
|
-
|
|
242
|
-
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
243
|
-
import debounce from "lodash/debounce";
|
|
244
|
-
|
|
245
|
-
export default defineConfig([...fastChina, ...createLodashConfigs("lodash")]);
|
|
148
|
+
export default defineConfig([...createBaseConfigs(), ...createAngularConfigs()]);
|
|
246
149
|
```
|
|
247
150
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
If a later `rules` record or file-scoped override sets `no-restricted-imports`, ESLint replaces this complete policy instead of merging its options. Projects that need additional package restrictions can import raw `preferLodashRules` or `preferLodashUnifiedRules` from `@fast-china/eslint-config/rules` and maintain one combined rule.
|
|
251
|
-
|
|
252
|
-
## Exact rule types and completion
|
|
253
|
-
|
|
254
|
-
The package generates `RuleOptions` from the JSON Schemas published by ESLint core and every bundled plugin. The identity helper `defineRules()` adds editor completion for rule names, severities, and options while rejecting misspelled rules and invalid options at type-checking time.
|
|
151
|
+
The Angular fragment checks TypeScript source, external HTML templates, and component inline templates. Official template accessibility rules are enabled by default. Exceptional projects can still configure:
|
|
255
152
|
|
|
256
153
|
```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"] }],
|
|
154
|
+
createAngularConfigs({
|
|
155
|
+
inlineTemplates: false,
|
|
156
|
+
templateAccessibility: false,
|
|
267
157
|
});
|
|
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
158
|
```
|
|
278
159
|
|
|
279
|
-
|
|
160
|
+
## Node.js / SDK
|
|
280
161
|
|
|
281
|
-
|
|
282
|
-
import type { RuleOptions } from "@fast-china/eslint-config";
|
|
162
|
+
Projects that do not need Vue, UniApp, React, or Angular use the base directly:
|
|
283
163
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
164
|
+
```js
|
|
165
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
166
|
+
|
|
167
|
+
export default createBaseConfigs({ environment: "node" });
|
|
287
168
|
```
|
|
288
169
|
|
|
289
|
-
|
|
170
|
+
`createBaseConfigs()` always enables JavaScript, type-aware TypeScript, JSON, Import, RegExp, manifest sorting, `.gitignore`, and Prettier compatibility, but does not claim framework files.
|
|
290
171
|
|
|
291
|
-
##
|
|
172
|
+
## Markdown and Lodash
|
|
292
173
|
|
|
293
|
-
|
|
174
|
+
Markdown composes explicitly:
|
|
294
175
|
|
|
295
|
-
|
|
176
|
+
```js
|
|
177
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
178
|
+
import { createMarkdownConfigs } from "@fast-china/eslint-config/configs";
|
|
179
|
+
import { defineConfig } from "eslint/config";
|
|
296
180
|
|
|
297
|
-
|
|
181
|
+
export default defineConfig([...createBaseConfigs(), ...createMarkdownConfigs()]);
|
|
182
|
+
```
|
|
298
183
|
|
|
299
|
-
|
|
184
|
+
Lodash static-import policies are also standalone:
|
|
300
185
|
|
|
301
186
|
```js
|
|
302
|
-
import {
|
|
187
|
+
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
303
188
|
|
|
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
|
-
);
|
|
189
|
+
createLodashConfigs("lodash");
|
|
190
|
+
createLodashConfigs("lodash-unified");
|
|
316
191
|
```
|
|
317
192
|
|
|
318
|
-
|
|
193
|
+
## Public entries
|
|
319
194
|
|
|
320
|
-
|
|
321
|
-
- `@fast-china/eslint-config/constants` exports all maintained file globs.
|
|
322
|
-
- `@fast-china/eslint-config/rules` exports the fully commented raw rule records and `RuleOptions`.
|
|
195
|
+
The root entry exports only:
|
|
323
196
|
|
|
324
|
-
|
|
325
|
-
|
|
197
|
+
- The default Vue 3 + TypeScript + UniApp Flat Config.
|
|
198
|
+
- `fastConfig`, `createBaseConfigs`, and `FastConfigOptions`.
|
|
199
|
+
- `defineRules` and `RuleOptions`.
|
|
326
200
|
|
|
327
|
-
|
|
328
|
-
import { GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
|
|
201
|
+
Focused subpaths provide advanced composition:
|
|
329
202
|
|
|
330
|
-
|
|
331
|
-
|
|
203
|
+
- `@fast-china/eslint-config/configs`: framework and capability fragments.
|
|
204
|
+
- `@fast-china/eslint-config/constants`: file globs and UniApp globals.
|
|
205
|
+
- `@fast-china/eslint-config/rules`: typed raw rule records.
|
|
332
206
|
|
|
333
207
|
## Prettier
|
|
334
208
|
|
|
335
|
-
Prettier
|
|
209
|
+
Prettier does not run as an ESLint rule. The default only loads `eslint-config-prettier` to disable conflicting rules. Install and run formatting separately:
|
|
336
210
|
|
|
337
211
|
```sh
|
|
338
212
|
pnpm add -D prettier
|
|
339
213
|
pnpm exec prettier --check .
|
|
340
214
|
```
|
|
341
215
|
|
|
342
|
-
Set `prettier: false` if another formatter or stylistic rule set should remain fully in control.
|
|
343
|
-
|
|
344
216
|
## Documentation
|
|
345
217
|
|
|
346
218
|
- [Default rules and risk guide](./docs/rules-risk.md)
|
|
347
|
-
- [Engineering audit
|
|
219
|
+
- [Engineering quality audit](./docs/engineering-audit.zh.md)
|
|
348
220
|
- [Contributing guide](./CONTRIBUTING.md)
|
|
349
221
|
- [Security policy](./SECURITY.md)
|
|
350
222
|
- [Changelog](./CHANGELOG.md)
|
|
@@ -358,9 +230,7 @@ pnpm check
|
|
|
358
230
|
pnpm pack --dry-run
|
|
359
231
|
```
|
|
360
232
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
Run `pnpm typegen` after upgrading ESLint or a plugin and commit `src/typegen.d.ts`; never edit the generated file manually. `pnpm test` rebuilds the package before running consumer type-contract, runtime integration, and package-contract tests. `pnpm check` adds source type-checking, full-repository linting, and formatting verification.
|
|
233
|
+
Run `pnpm typegen` after upgrading ESLint or plugins and commit `src/typegen.d.ts`. `pnpm check` verifies types, builds, runtime behavior, package contracts, ESLint, and formatting.
|
|
364
234
|
|
|
365
235
|
## License
|
|
366
236
|
|