@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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,44 @@ 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
|
+
|
|
40
|
+
## 2.0.10 - 2026-08-19
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- Changed the default export to a ready-to-use Flat Config array that can be exported directly or spread into another configuration; configurable usage remains available through the named `fastConfig()` export.
|
|
45
|
+
- Enabled Markdown, `package.json` sorting, and `tsconfig*.json` sorting by default while keeping React and Angular disabled by default.
|
|
46
|
+
|
|
9
47
|
## 2.0.9 - 2026-08-10
|
|
10
48
|
|
|
11
49
|
### 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,319 +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
43
|
import fastChina from "@fast-china/eslint-config";
|
|
49
44
|
|
|
50
|
-
export default fastChina
|
|
45
|
+
export default fastChina;
|
|
51
46
|
```
|
|
52
47
|
|
|
53
|
-
The default
|
|
48
|
+
The default entry includes:
|
|
54
49
|
|
|
55
|
-
|
|
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.
|
|
56
55
|
|
|
57
|
-
|
|
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.
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
## `fastConfig()`
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
The root factory retains only `environment`, whose default is `"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
|
+
| Value | Application globals |
|
|
71
|
+
| ------------- | ------------------- |
|
|
72
|
+
| `"browser"` | Browser |
|
|
73
|
+
| `"node"` | Node.js |
|
|
74
|
+
| `"universal"` | Browser and Node.js |
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
import fastChina from "@fast-china/eslint-config";
|
|
76
|
+
Config, script, test, and CLI files always receive Node.js globals and allow necessary logging and CommonJS interoperability.
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
angular: true,
|
|
81
|
-
vue: false,
|
|
82
|
-
});
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Angular support checks framework TypeScript, external `.html` templates, and inline component templates. Template accessibility and inline-template extraction are enabled by default:
|
|
86
|
-
|
|
87
|
-
```js
|
|
88
|
-
export default fastChina({
|
|
89
|
-
angular: {
|
|
90
|
-
inlineTemplates: true,
|
|
91
|
-
templateAccessibility: true,
|
|
92
|
-
},
|
|
93
|
-
vue: false,
|
|
94
|
-
});
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Angular requires the TypeScript integration; `angular: true` together with `typescript: false` fails early with a clear configuration error.
|
|
78
|
+
## Project overrides
|
|
98
79
|
|
|
99
|
-
|
|
80
|
+
Rules, globals, ignores, and special parser settings use trailing Flat Config objects instead of root factory options:
|
|
100
81
|
|
|
101
82
|
```js
|
|
102
|
-
import
|
|
83
|
+
import { defineRules, fastConfig } from "@fast-china/eslint-config";
|
|
103
84
|
|
|
104
|
-
export default
|
|
105
|
-
environment: "
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
);
|
|
108
105
|
```
|
|
109
106
|
|
|
110
|
-
|
|
107
|
+
Trailing configs have the highest precedence. `defineRules()` leaves the object unchanged and only adds exact type checking.
|
|
111
108
|
|
|
112
|
-
|
|
113
|
-
import fastChina from "@fast-china/eslint-config";
|
|
109
|
+
## TypeScript
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
environment: "node",
|
|
117
|
-
json: false,
|
|
118
|
-
markdown: false,
|
|
119
|
-
typescript: false,
|
|
120
|
-
vue: false,
|
|
121
|
-
});
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
#### Type-aware TypeScript rules
|
|
111
|
+
`createTypeScriptConfigs()`, Vue SFCs, and React TSX always use `recommendedTypeChecked` with:
|
|
125
112
|
|
|
126
113
|
```js
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
typescript: {
|
|
131
|
-
tsconfigRootDir: import.meta.dirname,
|
|
132
|
-
typeChecked: true,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
114
|
+
parserOptions: {
|
|
115
|
+
projectService: true,
|
|
116
|
+
}
|
|
135
117
|
```
|
|
136
118
|
|
|
137
|
-
|
|
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.
|
|
138
120
|
|
|
139
|
-
|
|
121
|
+
## React
|
|
140
122
|
|
|
141
|
-
|
|
123
|
+
React projects compose from the framework-neutral base:
|
|
142
124
|
|
|
143
125
|
```js
|
|
126
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
127
|
+
import { createReactConfigs } from "@fast-china/eslint-config/configs";
|
|
144
128
|
import { defineConfig } from "eslint/config";
|
|
145
129
|
|
|
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
|
-
]);
|
|
130
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs()]);
|
|
174
131
|
```
|
|
175
132
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
## Options
|
|
179
|
-
|
|
180
|
-
| Option | Default | Purpose |
|
|
181
|
-
| ----------------- | ----------- | -------------------------------------------------------------------------- |
|
|
182
|
-
| `angular` | `false` | Enable Angular TypeScript and templates, or pass Angular-specific options. |
|
|
183
|
-
| `environment` | `"browser"` | Use `"browser"`, `"node"`, or `"universal"` globals. |
|
|
184
|
-
| `globals` | none | Add globals supplied by a host platform or test runner. |
|
|
185
|
-
| `gitignore` | `true` | Read ignore patterns from the project `.gitignore`. |
|
|
186
|
-
| `ignores` | `[]` | Append project-specific global ignore patterns. |
|
|
187
|
-
| `imports` | `true` | Enable import-x correctness and ordering rules. |
|
|
188
|
-
| `javascript` | `true` | Process JavaScript and JSX files. |
|
|
189
|
-
| `json` | `true` | Enable recommended JSON, JSONC, and JSON5 rules. |
|
|
190
|
-
| `markdown` | `false` | Enable the official Markdown language rules. |
|
|
191
|
-
| `prettier` | `true` | Disable ESLint rules that conflict with Prettier. |
|
|
192
|
-
| `react` | `false` | Enable React/JSX/Hooks, or pass runtime and React-version settings. |
|
|
193
|
-
| `regexp` | `true` | Enable recommended RegExp rules. |
|
|
194
|
-
| `rules` | none | Add exactly typed project rules to every enabled code file. |
|
|
195
|
-
| `sortPackageJson` | `false` | Sort safe package.json keys without entering conditional `exports`. |
|
|
196
|
-
| `sortTsconfig` | `false` | Sort `tsconfig*.json` by TypeScript documentation topics. |
|
|
197
|
-
| `typescript` | `true` | Disable it or pass `{ typeChecked: true, tsconfigRootDir }`. |
|
|
198
|
-
| `vue` | `true` | Enable Vue 3 single-file components. |
|
|
199
|
-
|
|
200
|
-
## Framework coverage
|
|
201
|
-
|
|
202
|
-
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`.
|
|
203
|
-
|
|
204
|
-
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.
|
|
205
|
-
|
|
206
|
-
## Lodash import policy
|
|
207
|
-
|
|
208
|
-
Lodash policy is not a `fastConfig()` option. Import `createLodashConfigs()` from `@fast-china/eslint-config/configs` only when every static import should use one package:
|
|
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
|
-
- `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.
|
|
212
|
-
|
|
213
|
-
Choose `lodash-unified`:
|
|
214
|
-
|
|
215
|
-
```sh
|
|
216
|
-
pnpm add lodash-unified
|
|
217
|
-
```
|
|
135
|
+
React-compatible runtimes can pass recognition settings:
|
|
218
136
|
|
|
219
137
|
```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")]);
|
|
138
|
+
export default defineConfig([...createBaseConfigs(), ...createReactConfigs({ importSource: "preact", version: "detect" })]);
|
|
227
139
|
```
|
|
228
140
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
```sh
|
|
232
|
-
pnpm add lodash
|
|
233
|
-
pnpm add -D @types/lodash
|
|
234
|
-
```
|
|
141
|
+
## Angular
|
|
235
142
|
|
|
236
143
|
```js
|
|
144
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
145
|
+
import { createAngularConfigs } from "@fast-china/eslint-config/configs";
|
|
237
146
|
import { defineConfig } from "eslint/config";
|
|
238
147
|
|
|
239
|
-
|
|
240
|
-
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
241
|
-
import debounce from "lodash/debounce";
|
|
242
|
-
|
|
243
|
-
export default defineConfig([...fastChina(), ...createLodashConfigs("lodash")]);
|
|
148
|
+
export default defineConfig([...createBaseConfigs(), ...createAngularConfigs()]);
|
|
244
149
|
```
|
|
245
150
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
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.
|
|
249
|
-
|
|
250
|
-
## Exact rule types and completion
|
|
251
|
-
|
|
252
|
-
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:
|
|
253
152
|
|
|
254
153
|
```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"] }],
|
|
154
|
+
createAngularConfigs({
|
|
155
|
+
inlineTemplates: false,
|
|
156
|
+
templateAccessibility: false,
|
|
265
157
|
});
|
|
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
158
|
```
|
|
276
159
|
|
|
277
|
-
|
|
160
|
+
## Node.js / SDK
|
|
161
|
+
|
|
162
|
+
Projects that do not need Vue, UniApp, React, or Angular use the base directly:
|
|
278
163
|
|
|
279
|
-
```
|
|
280
|
-
import
|
|
164
|
+
```js
|
|
165
|
+
import { createBaseConfigs } from "@fast-china/eslint-config";
|
|
281
166
|
|
|
282
|
-
|
|
283
|
-
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
284
|
-
} satisfies RuleOptions;
|
|
167
|
+
export default createBaseConfigs({ environment: "node" });
|
|
285
168
|
```
|
|
286
169
|
|
|
287
|
-
|
|
170
|
+
`createBaseConfigs()` always enables JavaScript, type-aware TypeScript, JSON, Import, RegExp, manifest sorting, `.gitignore`, and Prettier compatibility, but does not claim framework files.
|
|
288
171
|
|
|
289
|
-
##
|
|
172
|
+
## Markdown and Lodash
|
|
290
173
|
|
|
291
|
-
|
|
174
|
+
Markdown composes explicitly:
|
|
292
175
|
|
|
293
|
-
|
|
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";
|
|
294
180
|
|
|
295
|
-
|
|
181
|
+
export default defineConfig([...createBaseConfigs(), ...createMarkdownConfigs()]);
|
|
182
|
+
```
|
|
296
183
|
|
|
297
|
-
|
|
184
|
+
Lodash static-import policies are also standalone:
|
|
298
185
|
|
|
299
186
|
```js
|
|
300
|
-
import
|
|
187
|
+
import { createLodashConfigs } from "@fast-china/eslint-config/configs";
|
|
301
188
|
|
|
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
|
-
);
|
|
189
|
+
createLodashConfigs("lodash");
|
|
190
|
+
createLodashConfigs("lodash-unified");
|
|
314
191
|
```
|
|
315
192
|
|
|
316
|
-
|
|
193
|
+
## Public entries
|
|
317
194
|
|
|
318
|
-
|
|
319
|
-
- `@fast-china/eslint-config/constants` exports all maintained file globs.
|
|
320
|
-
- `@fast-china/eslint-config/rules` exports the fully commented raw rule records and `RuleOptions`.
|
|
195
|
+
The root entry exports only:
|
|
321
196
|
|
|
322
|
-
|
|
323
|
-
|
|
197
|
+
- The default Vue 3 + TypeScript + UniApp Flat Config.
|
|
198
|
+
- `fastConfig`, `createBaseConfigs`, and `FastConfigOptions`.
|
|
199
|
+
- `defineRules` and `RuleOptions`.
|
|
324
200
|
|
|
325
|
-
|
|
326
|
-
import { GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
|
|
201
|
+
Focused subpaths provide advanced composition:
|
|
327
202
|
|
|
328
|
-
|
|
329
|
-
|
|
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.
|
|
330
206
|
|
|
331
207
|
## Prettier
|
|
332
208
|
|
|
333
|
-
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:
|
|
334
210
|
|
|
335
211
|
```sh
|
|
336
212
|
pnpm add -D prettier
|
|
337
213
|
pnpm exec prettier --check .
|
|
338
214
|
```
|
|
339
215
|
|
|
340
|
-
Set `prettier: false` if another formatter or stylistic rule set should remain fully in control.
|
|
341
|
-
|
|
342
216
|
## Documentation
|
|
343
217
|
|
|
344
218
|
- [Default rules and risk guide](./docs/rules-risk.md)
|
|
345
|
-
- [Engineering audit
|
|
219
|
+
- [Engineering quality audit](./docs/engineering-audit.zh.md)
|
|
346
220
|
- [Contributing guide](./CONTRIBUTING.md)
|
|
347
221
|
- [Security policy](./SECURITY.md)
|
|
348
222
|
- [Changelog](./CHANGELOG.md)
|
|
@@ -356,9 +230,7 @@ pnpm check
|
|
|
356
230
|
pnpm pack --dry-run
|
|
357
231
|
```
|
|
358
232
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
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.
|
|
362
234
|
|
|
363
235
|
## License
|
|
364
236
|
|