@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.
Files changed (93) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/CONTRIBUTING.md +8 -7
  3. package/README.md +108 -236
  4. package/README.zh.md +105 -231
  5. package/SECURITY.md +4 -4
  6. package/dist/configs/angular.d.mts +6 -6
  7. package/dist/configs/angular.mjs +1 -1
  8. package/dist/configs/angular.mjs.map +1 -1
  9. package/dist/configs/common.d.mts +2 -1
  10. package/dist/configs/common.mjs.map +1 -1
  11. package/dist/configs/environment.d.mts +21 -11
  12. package/dist/configs/environment.mjs +25 -5
  13. package/dist/configs/environment.mjs.map +1 -1
  14. package/dist/configs/ignores.d.mts +3 -2
  15. package/dist/configs/ignores.mjs +4 -3
  16. package/dist/configs/ignores.mjs.map +1 -1
  17. package/dist/configs/import.d.mts +2 -1
  18. package/dist/configs/import.mjs.map +1 -1
  19. package/dist/configs/index.d.mts +5 -4
  20. package/dist/configs/index.mjs +3 -2
  21. package/dist/configs/javascript.d.mts +2 -1
  22. package/dist/configs/javascript.mjs.map +1 -1
  23. package/dist/configs/json.d.mts +5 -3
  24. package/dist/configs/json.mjs +5 -4
  25. package/dist/configs/json.mjs.map +1 -1
  26. package/dist/configs/lodash.d.mts +2 -1
  27. package/dist/configs/lodash.mjs.map +1 -1
  28. package/dist/configs/markdown.d.mts +2 -1
  29. package/dist/configs/markdown.mjs.map +1 -1
  30. package/dist/configs/prettier.d.mts +2 -1
  31. package/dist/configs/prettier.mjs +4 -1
  32. package/dist/configs/prettier.mjs.map +1 -1
  33. package/dist/configs/react.d.mts +7 -44
  34. package/dist/configs/react.mjs +7 -8
  35. package/dist/configs/react.mjs.map +1 -1
  36. package/dist/configs/regexp.d.mts +4 -4
  37. package/dist/configs/regexp.mjs +5 -4
  38. package/dist/configs/regexp.mjs.map +1 -1
  39. package/dist/configs/sort-package.d.mts +4 -3
  40. package/dist/configs/sort-package.mjs +2 -2
  41. package/dist/configs/sort-package.mjs.map +1 -1
  42. package/dist/configs/sort-tsconfig.d.mts +4 -2
  43. package/dist/configs/sort-tsconfig.mjs +2 -1
  44. package/dist/configs/sort-tsconfig.mjs.map +1 -1
  45. package/dist/configs/typescript.d.mts +9 -56
  46. package/dist/configs/typescript.mjs +20 -29
  47. package/dist/configs/typescript.mjs.map +1 -1
  48. package/dist/configs/uniapp.d.mts +17 -0
  49. package/dist/configs/uniapp.mjs +30 -0
  50. package/dist/configs/uniapp.mjs.map +1 -0
  51. package/dist/configs/vue.d.mts +5 -38
  52. package/dist/configs/vue.mjs +25 -35
  53. package/dist/configs/vue.mjs.map +1 -1
  54. package/dist/constants/index.d.mts +33 -1
  55. package/dist/constants/index.mjs +33 -1
  56. package/dist/constants/index.mjs.map +1 -1
  57. package/dist/index.d.mts +41 -208
  58. package/dist/index.mjs +58 -100
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/rules/angular.d.mts +1 -1
  61. package/dist/rules/angular.mjs +1 -1
  62. package/dist/rules/angular.mjs.map +1 -1
  63. package/dist/rules/common.d.mts +2 -2
  64. package/dist/rules/common.mjs +2 -2
  65. package/dist/rules/common.mjs.map +1 -1
  66. package/dist/rules/import.mjs.map +1 -1
  67. package/dist/rules/index.d.mts +2 -1
  68. package/dist/rules/index.mjs +2 -1
  69. package/dist/rules/javascript.d.mts +10 -6
  70. package/dist/rules/javascript.mjs +12 -6
  71. package/dist/rules/javascript.mjs.map +1 -1
  72. package/dist/rules/react.d.mts +2 -3
  73. package/dist/rules/react.mjs +2 -3
  74. package/dist/rules/react.mjs.map +1 -1
  75. package/dist/rules/regexp.d.mts +38 -0
  76. package/dist/rules/regexp.mjs +39 -0
  77. package/dist/rules/regexp.mjs.map +1 -0
  78. package/dist/rules/sort-package.d.mts +1 -1
  79. package/dist/rules/sort-package.mjs +1 -1
  80. package/dist/rules/sort-package.mjs.map +1 -1
  81. package/dist/rules/sort-tsconfig.d.mts +1 -1
  82. package/dist/rules/sort-tsconfig.mjs +1 -1
  83. package/dist/rules/sort-tsconfig.mjs.map +1 -1
  84. package/dist/rules/typescript.d.mts +11 -3
  85. package/dist/rules/typescript.mjs +10 -4
  86. package/dist/rules/typescript.mjs.map +1 -1
  87. package/dist/rules/vue.d.mts +8 -2
  88. package/dist/rules/vue.mjs +8 -2
  89. package/dist/rules/vue.mjs.map +1 -1
  90. package/docs/engineering-audit.zh.md +53 -77
  91. package/docs/rules-risk.md +104 -101
  92. package/docs/rules-risk.zh.md +104 -105
  93. 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. Keep organization-specific dependency restrictions out of this general-purpose package; projects should own those policies.
31
- 6. Explain the purpose, rationale, and important exception or risk immediately above every local rule override.
32
- 7. Mark disruptive defaults with `[高影响]`; verify `meta.fixable` before using `[可自动修复]`, and keep `docs/rules-risk.md` plus `docs/rules-risk.zh.md` synchronized.
33
- 8. Never sort a map whose key order has semantics, including conditional objects under `package.json#exports`.
34
- 9. Regenerate `src/typegen.d.ts` whenever ESLint or a bundled plugin changes; confirm new rules and changed option schemas intentionally.
35
- 10. 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 `fastConfig`, `defaultConfigOptions`, `defineRules`, and related types.
36
- 11. Document behavior changes in `CHANGELOG.md` and both README files.
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, typed ESLint Flat Config for Vue 3, React, Angular, Vite, TypeScript, and JavaScript projects.
11
+ A practical ESLint Flat Config for Vue 3, UniApp, React, Angular, Vite, TypeScript, and JavaScript projects.
12
12
 
13
- [![npm version](https://img.shields.io/npm/v/@fast-china/eslint-config?color=orange)](https://www.npmjs.com/package/@fast-china/eslint-config) [![node](https://img.shields.io/badge/node-%5E22.18%20%7C%7C%20%5E24.18-brightgreen)](https://nodejs.org/) [![eslint](https://img.shields.io/badge/eslint-%5E10.0-4b32c3)](https://eslint.org/) [![license](https://img.shields.io/npm/l/@fast-china/eslint-config)](./LICENSE)
13
+ [![npm version](https://img.shields.io/npm/v/@fast-china/eslint-config?color=orange)](https://www.npmjs.com/package/@fast-china/eslint-config) [![Node.js](https://img.shields.io/badge/node-%5E22.18%20%7C%7C%20%5E24.18-brightgreen)](https://nodejs.org/) [![ESLint](https://img.shields.io/badge/eslint-%5E10.0-4b32c3)](https://eslint.org/) [![license](https://img.shields.io/npm/l/@fast-china/eslint-config)](./LICENSE)
14
14
 
15
- ## Highlights
15
+ ## Features
16
16
 
17
- - Built for ESLint 10 and the native Flat Config format.
18
- - Vue 3 + TypeScript + Vite defaults; React and Angular are first-class opt-in integrations, so existing Vue projects do not activate unrelated rules.
19
- - First-class JavaScript, TypeScript, Vue SFC, JSX/TSX, Angular TypeScript and templates, JSON dialects, Markdown, RegExp, and import rules.
20
- - One focused `fastConfig()` factory with a compact public API and no project-file reads at module import time.
21
- - Schema-generated rule types provide exact rule-name and rule-option completion.
22
- - Plugins and parsers are regular package dependencies, so consumers do not need to assemble the plugin graph.
23
- - Prettier stays a formatter: the default only disables conflicting ESLint rules and does not run Prettier inside ESLint.
24
- - Manifest sorting is explicit opt-in, preventing an unexpected large first-fix diff.
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
- Equivalent npm, Yarn, and Bun commands work as well.
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 targets a conventional Vue 3 browser-based administration project. It enables Vue 3, TypeScript, JavaScript, JSON dialects, import ordering, RegExp checks, `.gitignore`, browser globals, and Node globals for common config, script, test, and CLI files. Markdown, React, Angular, and manifest sorting remain opt-in. Lodash policies are composed separately from the `configs` subpath.
48
+ The default entry includes:
54
49
 
55
- ## Other project types
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
- Other projects can either configure the root factory or compose focused fragments directly.
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
- ### Use `fastConfig()`
58
+ ## `fastConfig()`
60
59
 
61
- #### React + Vite
60
+ The root factory retains only `environment`, whose default is `"browser"`:
62
61
 
63
62
  ```js
64
- import fastChina from "@fast-china/eslint-config";
63
+ import { fastConfig } from "@fast-china/eslint-config";
65
64
 
66
- export default fastChina({
67
- react: true,
68
- vue: false,
65
+ export default fastConfig({
66
+ environment: "universal",
69
67
  });
70
68
  ```
71
69
 
72
- React support applies the modern `@eslint-react` JavaScript/TypeScript preset, the official React Hooks Flat Config, and additional DOM safety checks. JSX and TSX are parsed by the existing JavaScript and TypeScript integrations. For a React-compatible JSX runtime such as Preact, set `react: { importSource: "preact" }`.
70
+ | Value | Application globals |
71
+ | ------------- | ------------------- |
72
+ | `"browser"` | Browser |
73
+ | `"node"` | Node.js |
74
+ | `"universal"` | Browser and Node.js |
73
75
 
74
- #### Angular
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
- export default fastChina({
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
- #### Node.js + TypeScript
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 fastChina from "@fast-china/eslint-config";
83
+ import { defineRules, fastConfig } from "@fast-china/eslint-config";
103
84
 
104
- export default fastChina({
105
- environment: "node",
106
- vue: false,
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
- #### JavaScript only
107
+ Trailing configs have the highest precedence. `defineRules()` leaves the object unchanged and only adds exact type checking.
111
108
 
112
- ```js
113
- import fastChina from "@fast-china/eslint-config";
109
+ ## TypeScript
114
110
 
115
- export default fastChina({
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
- import fastChina from "@fast-china/eslint-config";
128
-
129
- export default fastChina({
130
- typescript: {
131
- tsconfigRootDir: import.meta.dirname,
132
- typeChecked: true,
133
- },
134
- });
114
+ parserOptions: {
115
+ projectService: true,
116
+ }
135
117
  ```
136
118
 
137
- Type-aware linting uses the typescript-eslint Project Service. Project files must belong to a `tsconfig.json`. Most projects can omit `tsconfigRootDir`; complex monorepos should pass the directory containing the ESLint config explicitly.
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
- ### Compose config fragments directly
121
+ ## React
140
122
 
141
- Projects that do not want the root factory can assemble only the required fragments. This React browser example is fully independent of `fastConfig()`:
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
- import {
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
- Use `createVueConfigs()` for Vue SFCs, `createAngularConfigs()` for Angular, or set `environment: "node"` for Node.js. Fragment order is significant: project overrides should remain last.
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
- - `createLodashConfigs("lodash-unified")` rejects static imports and re-exports from `lodash`, `lodash-es`, and their subpaths.
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
- import { defineConfig } from "eslint/config";
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
- Choose standard `lodash`:
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
- import fastChina from "@fast-china/eslint-config";
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
- This fragment uses ESLint core `no-restricted-imports`, adds no plugin, and does not install Lodash for the project. It checks static `import`/`export` only, not dynamic `import()` or CommonJS `require()`. It is independent of the root factory's `imports` option.
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
- // @ts-check
256
- import fastChina, { defineRules } from "@fast-china/eslint-config";
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
- TypeScript configuration and tooling code can use the generated interface directly:
160
+ ## Node.js / SDK
161
+
162
+ Projects that do not need Vue, UniApp, React, or Angular use the base directly:
278
163
 
279
- ```ts
280
- import type { RuleOptions } from "@fast-china/eslint-config";
164
+ ```js
165
+ import { createBaseConfigs } from "@fast-china/eslint-config";
281
166
 
282
- const rules = {
283
- "no-console": ["warn", { allow: ["warn", "error"] }],
284
- } satisfies RuleOptions;
167
+ export default createBaseConfigs({ environment: "node" });
285
168
  ```
286
169
 
287
- The generated set covers ESLint core and plugins bundled by this package. Rules from additional project-installed plugins are outside this type set, and precision ultimately depends on the schema published by each rule.
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
- ## Rule risk and maintenance
172
+ ## Markdown and Lodash
290
173
 
291
- The default includes a small set of high-impact rules. They can block particular patterns or require a review of import side effects, type-only imports, and public component events. React and Angular are disabled globally by default, but enabling them also enables their documented modern-framework and accessibility policies. Manifest sorting is high-impact and disabled by default. Source comments mark these decisions as `[高影响]`, `[可自动修复]`, `[安全关注]`, or `[按需启用]`.
174
+ Markdown composes explicitly:
292
175
 
293
- See the [default-rule and risk guide](./docs/rules-risk.md) for inherited presets, the high-impact inventory, scoped override examples, and the maintenance contract. Run a read-only lint before `eslint --fix`, apply fixes in an isolated commit, and review imports, `package.json`, component events, and build output.
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
- ## Project overrides
181
+ export default defineConfig([...createBaseConfigs(), ...createMarkdownConfigs()]);
182
+ ```
296
183
 
297
- Put common overrides in `rules`, and pass file-scoped overrides as later arguments. Later configurations take precedence:
184
+ Lodash static-import policies are also standalone:
298
185
 
299
186
  ```js
300
- import fastChina, { defineRules } from "@fast-china/eslint-config";
187
+ import { createLodashConfigs } from "@fast-china/eslint-config/configs";
301
188
 
302
- export default fastChina(
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
- The root entry exports only `fastConfig`, `defaultConfigOptions`, `defineRules`, `FastConfigOptions`, and `RuleOptions`. Advanced composition uses focused subpaths instead of widening the root API:
193
+ ## Public entries
317
194
 
318
- - `@fast-china/eslint-config/configs` exports every configuration creator and its option types.
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
- ```js
323
- import { defineConfig } from "eslint/config";
197
+ - The default Vue 3 + TypeScript + UniApp Flat Config.
198
+ - `fastConfig`, `createBaseConfigs`, and `FastConfigOptions`.
199
+ - `defineRules` and `RuleOptions`.
324
200
 
325
- import { createCommonConfigs, createTypeScriptConfigs } from "@fast-china/eslint-config/configs";
326
- import { GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
201
+ Focused subpaths provide advanced composition:
327
202
 
328
- export default defineConfig([...createCommonConfigs(GLOBS_TYPESCRIPT), ...createTypeScriptConfigs({ typeChecked: true })]);
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 is intentionally not a peer dependency and is not executed as an ESLint rule. Install and run it separately if the project uses it:
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 (Chinese)](./docs/engineering-audit.zh.md)
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
- Use `pnpm dev` to inspect the active Flat Config interactively while changing factories or rules.
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