@fast-china/eslint-config 1.1.0 → 2.0.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and releases should follow [Semantic Versioning](https://semver.org/).
6
+
7
+ ## Unreleased
8
+
9
+ ## 2.0.1 - 2026-07-26
10
+
11
+ ### Added
12
+
13
+ - Added first-class opt-in React support with JavaScript/TypeScript presets, official Hooks and React Compiler diagnostics, DOM safety rules, React-compatible JSX runtime settings, generated rule types, and runtime tests.
14
+ - Added first-class opt-in Angular support for framework TypeScript, external and inline templates, modern recommended rules, configurable template accessibility, generated rule types, and runtime tests.
15
+
16
+ ### Changed
17
+
18
+ - Changed the newly bundled React and Angular dependencies to caret ranges so compatible minor and patch releases can be installed without editing the manifest.
19
+ - Completed the TypeScript 6 migration with TypeScript 6.0.3, removed the deprecated compiler-option suppression, and replaced tsup with tsdown 0.22.14 for native `.mjs`, `.d.mts`, and source-map builds.
20
+ - Raised the verified runtime baselines to Node.js 22.18.0 and 24.11.0 to match the current tsdown toolchain.
21
+ - Updated the development baseline to ESLint 10.8.0, then upgraded `actions/checkout` plus `actions/setup-node` to their current v7 major releases.
22
+
23
+ ## 2.0.0 - 2026-07-26
24
+
25
+ ### Added
26
+
27
+ - Published the ESM-only `fastConfig(options, ...overrides)` factory for Vue 3, Vite, TypeScript, JavaScript, Node.js, JSON dialects, Markdown, RegExp, import rules, Prettier conflict handling, and project overrides.
28
+ - Added environment-aware globals, `.gitignore` support, global ignore patterns, language switches, and file-scoped trailing overrides.
29
+ - Added optional type-aware TypeScript and Vue linting through typescript-eslint Project Service.
30
+ - Added opt-in `lodash` and `lodash-unified` static import policies without requiring an additional ESLint plugin.
31
+ - Added opt-in, semantics-aware `package.json` and `tsconfig*.json` sorting that preserves conditional export order.
32
+ - Added schema-generated `RuleOptions`, factory-level typed rules, and `defineRules()` for exact rule-name and rule-option completion.
33
+ - Published fully commented raw rule records through `@fast-china/eslint-config/rules`.
34
+ - Added bilingual usage and risk documentation, contribution guidance, and an engineering quality audit.
35
+ - Added deterministic type-generation checks, consumer type tests, runtime integration tests, multi-version Node.js CI, and publish-archive inspection.
36
+
37
+ ### Changed
38
+
39
+ - Raised the minimum supported Node.js version to 22.13.0 so the package, local development workflow, and pnpm 11 CI use one consistent runtime baseline.
40
+ - Upgraded `pnpm/action-setup` to v6 so GitHub Actions uses its Node.js 24 runtime without Node.js 20 deprecation warnings.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @fast-china/eslint-config
4
4
 
5
- A practical, typed ESLint Flat Config for Vue 3, Vite, TypeScript, and JavaScript projects.
5
+ A practical, typed ESLint Flat Config for Vue 3, React, Angular, Vite, TypeScript, and JavaScript projects.
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/@fast-china/eslint-config?color=orange)](https://www.npmjs.com/package/@fast-china/eslint-config)
8
8
  [![license](https://img.shields.io/npm/l/@fast-china/eslint-config)](./LICENSE)
@@ -10,18 +10,20 @@ A practical, typed ESLint Flat Config for Vue 3, Vite, TypeScript, and JavaScrip
10
10
  ## Highlights
11
11
 
12
12
  - Built for ESLint 10 and the native Flat Config format.
13
- - Vue 3 + TypeScript + Vite defaults, with Vue 2 and type-aware linting available explicitly.
14
- - First-class JavaScript, TypeScript, Vue SFC, JSON, JSONC, JSON5, Markdown, RegExp, and import rules.
15
- - A zero-configuration default array plus a small `createConfig()` factory for other project types.
13
+ - Vue 3 + TypeScript + Vite defaults; React and Angular are first-class opt-in integrations, so existing Vue projects do not activate unrelated rules.
14
+ - First-class JavaScript, TypeScript, Vue SFC, JSX/TSX, Angular TypeScript and templates, JSON dialects, Markdown, RegExp, and import rules.
15
+ - One focused `fastConfig()` factory with a compact public API and no project-file reads at module import time.
16
16
  - Schema-generated rule types provide exact rule-name and rule-option completion.
17
17
  - Plugins and parsers are regular package dependencies, so consumers do not need to assemble the plugin graph.
18
18
  - Prettier stays a formatter: the default only disables conflicting ESLint rules and does not run Prettier inside ESLint.
19
+ - Manifest sorting is explicit opt-in, preventing an unexpected large first-fix diff.
20
+ - An opt-in Lodash policy keeps projects on either `lodash` or `lodash-unified` without mixing package entry points.
19
21
 
20
22
  ## Requirements
21
23
 
22
- - Node.js `^20.19.0`, `^22.13.0`, or `>=24`
24
+ - Node.js `^22.18.0` or `>=24.11.0`
23
25
  - ESLint `^10.0.0`
24
- - TypeScript `>=5.3.0 <6.1.0`
26
+ - TypeScript `>=6.0.0 <6.1.0`
25
27
 
26
28
  These versions follow the runtime requirements of ESLint 10 and the included language plugins.
27
29
 
@@ -38,83 +40,161 @@ Equivalent npm, Yarn, and Bun commands work as well.
38
40
  Create `eslint.config.mjs`:
39
41
 
40
42
  ```js
41
- import { defineConfig } from "eslint/config";
42
-
43
43
  import fastChina from "@fast-china/eslint-config";
44
44
 
45
- export default defineConfig([...fastChina]);
45
+ export default fastChina();
46
46
  ```
47
47
 
48
48
  The default enables Vue 3, TypeScript, JavaScript, JSON dialects, Markdown, import ordering, RegExp checks, `.gitignore`, browser globals, and Node globals for common config, script, test, and CLI files.
49
49
 
50
50
  ## Other project types
51
51
 
52
- Use `createConfig()` to keep only what a project needs.
52
+ Use the default `fastConfig()` factory to keep only what a project needs.
53
53
 
54
- ### Node.js + TypeScript
54
+ ### React + Vite
55
55
 
56
56
  ```js
57
- import { defineConfig } from "eslint/config";
57
+ import fastChina from "@fast-china/eslint-config";
58
58
 
59
- import { createConfig } from "@fast-china/eslint-config";
59
+ export default fastChina({
60
+ react: true,
61
+ vue: false,
62
+ });
63
+ ```
60
64
 
61
- export default defineConfig(
62
- createConfig({
63
- environment: "node",
64
- vue: false,
65
- })
66
- );
65
+ 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" }`.
66
+
67
+ ### Angular
68
+
69
+ ```js
70
+ import fastChina from "@fast-china/eslint-config";
71
+
72
+ export default fastChina({
73
+ angular: true,
74
+ vue: false,
75
+ });
76
+ ```
77
+
78
+ Angular support checks framework TypeScript, external `.html` templates, and inline component templates. Template accessibility and inline-template extraction are enabled by default:
79
+
80
+ ```js
81
+ export default fastChina({
82
+ angular: {
83
+ inlineTemplates: true,
84
+ templateAccessibility: true,
85
+ },
86
+ vue: false,
87
+ });
88
+ ```
89
+
90
+ Angular requires the TypeScript integration; `angular: true` together with `typescript: false` fails early with a clear configuration error.
91
+
92
+ ### Node.js + TypeScript
93
+
94
+ ```js
95
+ import fastChina from "@fast-china/eslint-config";
96
+
97
+ export default fastChina({
98
+ environment: "node",
99
+ vue: false,
100
+ });
67
101
  ```
68
102
 
69
103
  ### JavaScript only
70
104
 
71
105
  ```js
72
- import { defineConfig } from "eslint/config";
73
-
74
- import { createConfig } from "@fast-china/eslint-config";
75
-
76
- export default defineConfig(
77
- createConfig({
78
- environment: "node",
79
- json: false,
80
- markdown: false,
81
- typescript: false,
82
- vue: false,
83
- })
84
- );
106
+ import fastChina from "@fast-china/eslint-config";
107
+
108
+ export default fastChina({
109
+ environment: "node",
110
+ json: false,
111
+ markdown: false,
112
+ typescript: false,
113
+ vue: false,
114
+ });
85
115
  ```
86
116
 
87
117
  ### Type-aware TypeScript rules
88
118
 
89
119
  ```js
90
- import { defineConfig } from "eslint/config";
91
-
92
- import { createConfig } from "@fast-china/eslint-config";
120
+ import fastChina from "@fast-china/eslint-config";
93
121
 
94
- export default defineConfig(
95
- createConfig({
96
- typescript: { typeChecked: true },
97
- vue: { typeChecked: true, version: 3 },
98
- })
99
- );
122
+ export default fastChina({
123
+ typescript: {
124
+ tsconfigRootDir: import.meta.dirname,
125
+ typeChecked: true,
126
+ },
127
+ });
100
128
  ```
101
129
 
102
- Type-aware linting uses the typescript-eslint project service. Project files must belong to a `tsconfig.json`.
130
+ 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.
103
131
 
104
132
  ## Options
105
133
 
106
- | Option | Default | Purpose |
107
- | ------------- | ----------- | ----------------------------------------------------------- |
108
- | `environment` | `"browser"` | Use `"browser"`, `"node"`, or `"universal"` globals. |
109
- | `gitignore` | `true` | Read ignore patterns from the project `.gitignore`. |
110
- | `ignores` | `[]` | Add project-specific global ignore patterns. |
111
- | `imports` | `true` | Enable import-x correctness and ordering rules. |
112
- | `json` | `true` | Enable JSON/JSONC/JSON5 rules and package/tsconfig sorting. |
113
- | `markdown` | `true` | Enable the official Markdown language rules. |
114
- | `prettier` | `true` | Disable ESLint rules that conflict with Prettier. |
115
- | `regexp` | `true` | Enable recommended RegExp rules. |
116
- | `typescript` | `true` | Disable it or pass `{ typeChecked: true }`. |
117
- | `vue` | `3` | Disable it, use `2`/`3`, or pass Vue options. |
134
+ | Option | Default | Purpose |
135
+ | ----------------- | ----------- | -------------------------------------------------------------------------- |
136
+ | `angular` | `false` | Enable Angular TypeScript and templates, or pass Angular-specific options. |
137
+ | `environment` | `"browser"` | Use `"browser"`, `"node"`, or `"universal"` globals. |
138
+ | `globals` | none | Add globals supplied by a host platform or test runner. |
139
+ | `gitignore` | `true` | Read ignore patterns from the project `.gitignore`. |
140
+ | `ignores` | `[]` | Append project-specific global ignore patterns. |
141
+ | `imports` | `true` | Enable import-x correctness and ordering rules. |
142
+ | `javascript` | `true` | Process JavaScript and JSX files. |
143
+ | `json` | `true` | Enable recommended JSON, JSONC, and JSON5 rules. |
144
+ | `lodash` | `false` | Select `"lodash"` or `"lodash-unified"` for static imports. |
145
+ | `markdown` | `true` | Enable the official Markdown language rules. |
146
+ | `prettier` | `true` | Disable ESLint rules that conflict with Prettier. |
147
+ | `react` | `false` | Enable React/JSX/Hooks, or pass runtime and React-version settings. |
148
+ | `regexp` | `true` | Enable recommended RegExp rules. |
149
+ | `rules` | none | Add exactly typed project rules to every enabled code file. |
150
+ | `sortPackageJson` | `false` | Sort safe package.json keys without entering conditional `exports`. |
151
+ | `sortTsconfig` | `false` | Sort `tsconfig*.json` by TypeScript documentation topics. |
152
+ | `typescript` | `true` | Disable it or pass `{ typeChecked: true, tsconfigRootDir }`. |
153
+ | `vue` | `true` | Enable Vue 3 single-file components. |
154
+
155
+ ## Framework coverage
156
+
157
+ 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`.
158
+
159
+ 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.
160
+
161
+ ## Lodash import policy
162
+
163
+ The default, `lodash: false`, leaves the dependency choice to the project. Select one policy when every static import should use the same package:
164
+
165
+ - `lodash: "lodash-unified"` rejects static imports and re-exports from `lodash`, `lodash-es`, and their subpaths.
166
+ - `lodash: "lodash"` rejects static imports and re-exports from `lodash-es`, `lodash-unified`, and their subpaths. The `lodash` root and `lodash/*` method imports remain valid.
167
+
168
+ Choose `lodash-unified`:
169
+
170
+ ```sh
171
+ pnpm add lodash-unified
172
+ ```
173
+
174
+ ```js
175
+ import fastChina from "@fast-china/eslint-config";
176
+ import { cloneDeep, debounce } from "lodash-unified";
177
+
178
+ export default fastChina({ lodash: "lodash-unified" });
179
+ ```
180
+
181
+ Choose standard `lodash`:
182
+
183
+ ```sh
184
+ pnpm add lodash
185
+ pnpm add -D @types/lodash
186
+ ```
187
+
188
+ ```js
189
+ import fastChina from "@fast-china/eslint-config";
190
+ import debounce from "lodash/debounce";
191
+
192
+ export default fastChina({ lodash: "lodash" });
193
+ ```
194
+
195
+ This feature 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()`. Setting `imports: false` disables import-x but leaves an explicitly selected Lodash policy active.
196
+
197
+ 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.
118
198
 
119
199
  ## Exact rule types and completion
120
200
 
@@ -122,23 +202,25 @@ The package generates `RuleOptions` from the JSON Schemas published by ESLint co
122
202
 
123
203
  ```js
124
204
  // @ts-check
125
- import { defineConfig } from "eslint/config";
126
-
127
- import { createConfig, defineRules } from "@fast-china/eslint-config";
205
+ import fastChina, { defineRules } from "@fast-china/eslint-config";
128
206
 
129
207
  const projectRules = defineRules({
208
+ "@angular-eslint/template/alt-text": "error",
209
+ "@eslint-react/dom-no-missing-button-type": "error",
130
210
  "@typescript-eslint/no-unused-vars": ["error", { args: "after-used" }],
131
211
  "import-x/order": ["error", { "newlines-between": "always" }],
212
+ "react-hooks/exhaustive-deps": "warn",
132
213
  "vue/attributes-order": ["error", { order: ["DEFINITION", "EVENTS", "CONTENT"] }],
133
214
  });
134
215
 
135
- export default defineConfig([
136
- ...createConfig(),
216
+ export default fastChina(
217
+ { rules: projectRules },
137
218
  {
138
- name: "project/rules",
139
- rules: projectRules,
140
- },
141
- ]);
219
+ files: ["**/*.generated.ts"],
220
+ name: "project/generated",
221
+ rules: defineRules({ "@typescript-eslint/no-unused-vars": "off" }),
222
+ }
223
+ );
142
224
  ```
143
225
 
144
226
  TypeScript configuration and tooling code can use the generated interface directly:
@@ -155,31 +237,32 @@ The generated set covers ESLint core and plugins bundled by this package. Rules
155
237
 
156
238
  ## Rule risk and maintenance
157
239
 
158
- The default includes a small set of high-impact rules. They can create a large first-run sorting diff, block legacy patterns, or require a review of import side effects, type-only imports, and public component events. Source comments mark these decisions as `[高影响]`, `[可自动修复]`, or `[安全关注]`.
240
+ 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 `[按需启用]`.
159
241
 
160
242
  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.
161
243
 
162
244
  ## Project overrides
163
245
 
164
- Append project rules after the shared config so they take precedence:
246
+ Put common overrides in `rules`, and pass file-scoped overrides as later arguments. Later configurations take precedence:
165
247
 
166
248
  ```js
167
- import { defineConfig } from "eslint/config";
168
-
169
- import { createConfig } from "@fast-china/eslint-config";
249
+ import fastChina, { defineRules } from "@fast-china/eslint-config";
170
250
 
171
- export default defineConfig([
172
- ...createConfig({ vue: 3 }),
251
+ export default fastChina(
173
252
  {
174
- name: "project/overrides",
175
253
  rules: {
176
- "no-console": "off",
254
+ "no-console": "warn",
177
255
  },
178
256
  },
179
- ]);
257
+ {
258
+ files: ["**/{scripts,tests}/**/*.{js,ts}"],
259
+ name: "project/node-files",
260
+ rules: defineRules({ "no-console": "off" }),
261
+ }
262
+ );
180
263
  ```
181
264
 
182
- Reusable named exports include `PresetJavascriptConfigs`, `PresetTypeScriptConfigs`, `PresetBasicConfigs`, `PresetJsonConfigs`, `PresetVueConfigs`, individual config groups, constants, and raw rule records from `@fast-china/eslint-config/rules`.
265
+ The root entry exports only `fastConfig`, `defaultConfigOptions`, `defineRules`, and their related types. Advanced consumers can import the fully commented raw rule records from `@fast-china/eslint-config/rules`.
183
266
 
184
267
  ## Prettier
185
268
 
@@ -198,21 +281,13 @@ Set `prettier: false` if another formatter or stylistic rule set should remain f
198
281
  pnpm install
199
282
  pnpm typegen
200
283
  pnpm check
284
+ pnpm pack --dry-run
201
285
  ```
202
286
 
203
287
  Run `pnpm typegen` after upgrading ESLint or a plugin and commit `src/typegen.d.ts`; never edit the generated file manually. `pnpm check` verifies that generated types are current, builds the package, type-checks source, lints all supported file types, checks formatting, and runs both runtime and consumer type tests against the built package.
204
288
 
205
289
  See [CONTRIBUTING.md](./CONTRIBUTING.md) for the contribution workflow, the [default-rule and risk guide](./docs/rules-risk.md) for rule maintenance, and [the engineering audit](./docs/engineering-audit.zh.md) for the current quality baseline.
206
290
 
207
- ## Migration from 1.0.48 and earlier
208
-
209
- - Existing `export default [...fastChina]` usage still works.
210
- - The package is ESM-only and no longer exposes a misleading CommonJS condition.
211
- - Vue 3 is the explicit default; use `createConfig({ vue: 2 })` for Vue 2.
212
- - `lodash` and `lodash-es` are no longer banned by default. The organization-specific rule records remain available from the rules subpath.
213
- - Prettier no longer runs inside ESLint. Run the Prettier CLI or editor integration separately.
214
- - ESLint 10 now determines the Node.js minimum shown above.
215
-
216
291
  ## License
217
292
 
218
293
  [Apache-2.0](./LICENSE)