@fast-china/eslint-config 2.0.10 → 2.1.1

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 (97) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/CONTRIBUTING.md +8 -7
  3. package/README.md +106 -236
  4. package/README.zh.md +103 -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 +10 -2
  19. package/dist/configs/import.mjs.map +1 -1
  20. package/dist/configs/index.d.mts +5 -4
  21. package/dist/configs/index.mjs +3 -2
  22. package/dist/configs/javascript.d.mts +2 -1
  23. package/dist/configs/javascript.mjs.map +1 -1
  24. package/dist/configs/json.d.mts +5 -3
  25. package/dist/configs/json.mjs +5 -4
  26. package/dist/configs/json.mjs.map +1 -1
  27. package/dist/configs/lodash.d.mts +2 -1
  28. package/dist/configs/lodash.mjs.map +1 -1
  29. package/dist/configs/markdown.d.mts +2 -1
  30. package/dist/configs/markdown.mjs.map +1 -1
  31. package/dist/configs/prettier.d.mts +2 -1
  32. package/dist/configs/prettier.mjs +4 -1
  33. package/dist/configs/prettier.mjs.map +1 -1
  34. package/dist/configs/react.d.mts +7 -44
  35. package/dist/configs/react.mjs +7 -8
  36. package/dist/configs/react.mjs.map +1 -1
  37. package/dist/configs/regexp.d.mts +4 -4
  38. package/dist/configs/regexp.mjs +5 -4
  39. package/dist/configs/regexp.mjs.map +1 -1
  40. package/dist/configs/sort-package.d.mts +4 -3
  41. package/dist/configs/sort-package.mjs +2 -2
  42. package/dist/configs/sort-package.mjs.map +1 -1
  43. package/dist/configs/sort-tsconfig.d.mts +4 -2
  44. package/dist/configs/sort-tsconfig.mjs +2 -1
  45. package/dist/configs/sort-tsconfig.mjs.map +1 -1
  46. package/dist/configs/typescript.d.mts +9 -56
  47. package/dist/configs/typescript.mjs +20 -29
  48. package/dist/configs/typescript.mjs.map +1 -1
  49. package/dist/configs/uniapp.d.mts +17 -0
  50. package/dist/configs/uniapp.mjs +30 -0
  51. package/dist/configs/uniapp.mjs.map +1 -0
  52. package/dist/configs/vue.d.mts +5 -38
  53. package/dist/configs/vue.mjs +25 -35
  54. package/dist/configs/vue.mjs.map +1 -1
  55. package/dist/constants/index.d.mts +33 -1
  56. package/dist/constants/index.mjs +33 -1
  57. package/dist/constants/index.mjs.map +1 -1
  58. package/dist/index.d.mts +35 -216
  59. package/dist/index.mjs +52 -108
  60. package/dist/index.mjs.map +1 -1
  61. package/dist/plugins/import.mjs +61 -0
  62. package/dist/plugins/import.mjs.map +1 -0
  63. package/dist/rules/angular.d.mts +1 -1
  64. package/dist/rules/angular.mjs +1 -1
  65. package/dist/rules/angular.mjs.map +1 -1
  66. package/dist/rules/common.d.mts +2 -2
  67. package/dist/rules/common.mjs +2 -2
  68. package/dist/rules/common.mjs.map +1 -1
  69. package/dist/rules/import.mjs.map +1 -1
  70. package/dist/rules/index.d.mts +2 -1
  71. package/dist/rules/index.mjs +2 -1
  72. package/dist/rules/javascript.d.mts +10 -6
  73. package/dist/rules/javascript.mjs +12 -6
  74. package/dist/rules/javascript.mjs.map +1 -1
  75. package/dist/rules/react.d.mts +2 -3
  76. package/dist/rules/react.mjs +2 -3
  77. package/dist/rules/react.mjs.map +1 -1
  78. package/dist/rules/regexp.d.mts +38 -0
  79. package/dist/rules/regexp.mjs +39 -0
  80. package/dist/rules/regexp.mjs.map +1 -0
  81. package/dist/rules/sort-package.d.mts +1 -1
  82. package/dist/rules/sort-package.mjs +1 -1
  83. package/dist/rules/sort-package.mjs.map +1 -1
  84. package/dist/rules/sort-tsconfig.d.mts +1 -1
  85. package/dist/rules/sort-tsconfig.mjs +1 -1
  86. package/dist/rules/sort-tsconfig.mjs.map +1 -1
  87. package/dist/rules/typescript.d.mts +11 -3
  88. package/dist/rules/typescript.mjs +10 -4
  89. package/dist/rules/typescript.mjs.map +1 -1
  90. package/dist/rules/vue.d.mts +8 -2
  91. package/dist/rules/vue.mjs +8 -2
  92. package/dist/rules/vue.mjs.map +1 -1
  93. package/dist/typegen.d.mts +4 -0
  94. package/docs/engineering-audit.zh.md +54 -77
  95. package/docs/rules-risk.md +105 -101
  96. package/docs/rules-risk.zh.md +105 -105
  97. 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
+ ## 2.1.1 - 2026-08-29
10
+
11
+ ### Added
12
+
13
+ - Added `import-x/style-imports-last` to require one final, stable stylesheet import group without automatic reordering.
14
+
15
+ ### Changed
16
+
17
+ - Expanded the inline documentation for local ESLint rules and scoped overrides, including their purpose, important exceptions, and ownership of duplicate React checks.
18
+ - Excluded stylesheet imports from `import-x/order` while preserving its grouping, alphabetizing, and `warnOnUnassignedImports` checks for all other imports.
19
+
20
+ ## 2.1.0 - 2026-08-26
21
+
22
+ ### Added
23
+
24
+ - 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.
25
+ - Added a trailing Node.js tooling override that permits logging and CommonJS interoperability in config, script, test, and CLI files.
26
+ - Added root-exported `createBaseConfigs()` as a fixed, framework-neutral composition for React, Angular, Node.js, and SDK projects.
27
+
28
+ ### Changed
29
+
30
+ - Replaced project-type strictness with one shared rule set for SDKs, OA systems, administration apps, Vue web apps, and clients.
31
+ - 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.
32
+ - Changed TypeScript, Vue, and React TypeScript to always use `recommendedTypeChecked` and Project Service.
33
+ - Required explicit parameter and return types at exported TypeScript module boundaries without forcing return annotations on internal functions and callbacks.
34
+ - Changed Vue to inherit `flat/recommended`, enforce kebab-case template attributes, warn on `v-html`, and reject `v-text`/`v-html` on components.
35
+ - Replaced the full RegExp recommended preset with an explicit correctness and safety rule set.
36
+ - Restored JavaScript conventions including camelCase, declaration order, arrow callbacks, logical assignment, object spread, object shorthand, rest/spread, and template literals.
37
+ - Restored `sort-imports`; import ordering is an error again and includes side-effect imports.
38
+ - Enabled the official React Hooks Recommended preset and aligned Angular TypeScript, template, and accessibility rules with the Angular ESLint recommended presets.
39
+ - Enabled `package.json` and `tsconfig*.json` sorting in the fixed root and base compositions; Markdown remains explicitly composed.
40
+ - Corrected the built-in dependency ignore glob so both `.pnpm-store` and `node_modules` are matched without relying on `.gitignore`.
41
+ - Allowed JSONC comments in both VS Code `.vscode/settings.json` and `.vscode/extensions.json`.
42
+
43
+ ### Removed
44
+
45
+ - 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.
46
+
9
47
  ## 2.0.10 - 2026-08-19
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
- - A ready-to-use default Flat Config array that can be exported directly or spread, plus a named `fastConfig()` factory for customization.
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
- - Markdown and safe manifest sorting are enabled by default; React and Angular remain opt-in.
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
- 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
- import { defineConfig } from "eslint/config";
49
-
50
43
  import fastChina from "@fast-china/eslint-config";
51
44
 
52
- export default defineConfig([fastChina]);
45
+ export default fastChina;
53
46
  ```
54
47
 
55
- You can also use `export default fastChina` directly, or `...fastChina` when composing other configs. The default targets a conventional Vue 3 browser-based administration project. It enables Vue 3, TypeScript, JavaScript, JSON dialects, Markdown, manifest sorting, import ordering, RegExp checks, `.gitignore`, browser globals, and Node globals for common config, script, test, and CLI files. React and Angular remain opt-in. Lodash policies are composed separately from the `configs` subpath.
48
+ The default entry includes:
56
49
 
57
- ## 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.
58
55
 
59
- Other projects can configure the named `fastConfig()` 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.
60
57
 
61
- ### Use `fastConfig()`
58
+ ## `fastConfig()`
62
59
 
63
- #### React + Vite
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
- react: true,
70
- vue: false,
66
+ environment: "universal",
71
67
  });
72
68
  ```
73
69
 
74
- 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 |
75
75
 
76
- #### Angular
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
- export default fastConfig({
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
- #### Node.js + TypeScript
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: "node",
108
- vue: false,
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
- #### JavaScript only
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
- export default fastConfig({
118
- environment: "node",
119
- json: false,
120
- markdown: false,
121
- typescript: false,
122
- vue: false,
123
- });
124
- ```
109
+ ## TypeScript
125
110
 
126
- #### Type-aware TypeScript rules
111
+ `createTypeScriptConfigs()`, Vue SFCs, and React TSX always use `recommendedTypeChecked` with:
127
112
 
128
113
  ```js
129
- import { fastConfig } from "@fast-china/eslint-config";
130
-
131
- export default fastConfig({
132
- typescript: {
133
- tsconfigRootDir: import.meta.dirname,
134
- typeChecked: true,
135
- },
136
- });
114
+ parserOptions: {
115
+ projectService: true,
116
+ }
137
117
  ```
138
118
 
139
- 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.
140
120
 
141
- ### Compose config fragments directly
121
+ ## React
142
122
 
143
- 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:
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
- import {
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
- Use `createVueConfigs()` for Vue SFCs, `createAngularConfigs()` for Angular, or set `environment: "node"` for Node.js. Fragment order is significant: project overrides should remain last.
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
- Lodash policy is not a `fastConfig()` option. Import `createLodashConfigs()` from `@fast-china/eslint-config/configs` only when every static import should use one package:
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
- import { defineConfig } from "eslint/config";
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
- Choose standard `lodash`:
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
- import fastChina from "@fast-china/eslint-config";
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
- 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.
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
- // @ts-check
258
- import { defineRules, fastConfig } from "@fast-china/eslint-config";
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
- TypeScript configuration and tooling code can use the generated interface directly:
160
+ ## Node.js / SDK
280
161
 
281
- ```ts
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
- const rules = {
285
- "no-console": ["warn", { allow: ["warn", "error"] }],
286
- } satisfies RuleOptions;
164
+ ```js
165
+ import { createBaseConfigs } from "@fast-china/eslint-config";
166
+
167
+ export default createBaseConfigs({ environment: "node" });
287
168
  ```
288
169
 
289
- 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.
290
171
 
291
- ## Rule risk and maintenance
172
+ ## Markdown and Lodash
292
173
 
293
- 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, public component events, and manifest sorting results. React and Angular are disabled globally by default, but enabling them also enables their documented modern-framework and accessibility policies. Source comments mark these decisions as `[High impact]`, `[Auto-fixable]`, or `[Security]`.
174
+ Markdown composes explicitly:
294
175
 
295
- 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";
296
180
 
297
- ## Project overrides
181
+ export default defineConfig([...createBaseConfigs(), ...createMarkdownConfigs()]);
182
+ ```
298
183
 
299
- 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:
300
185
 
301
186
  ```js
302
- import { defineRules, fastConfig } from "@fast-china/eslint-config";
187
+ import { createLodashConfigs } from "@fast-china/eslint-config/configs";
303
188
 
304
- export default fastConfig(
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
- 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
319
194
 
320
- - `@fast-china/eslint-config/configs` exports every configuration creator and its option types.
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
- ```js
325
- import { defineConfig } from "eslint/config";
197
+ - The default Vue 3 + TypeScript + UniApp Flat Config.
198
+ - `fastConfig`, `createBaseConfigs`, and `FastConfigOptions`.
199
+ - `defineRules` and `RuleOptions`.
326
200
 
327
- import { createCommonConfigs, createTypeScriptConfigs } from "@fast-china/eslint-config/configs";
328
- import { GLOBS_TYPESCRIPT } from "@fast-china/eslint-config/constants";
201
+ Focused subpaths provide advanced composition:
329
202
 
330
- export default defineConfig([...createCommonConfigs(GLOBS_TYPESCRIPT), ...createTypeScriptConfigs({ typeChecked: true })]);
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 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:
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 (Chinese)](./docs/engineering-audit.zh.md)
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
- Use `pnpm dev` to inspect the active Flat Config interactively while changing factories or rules.
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