@st1ggy/linter-config 7.4.0 → 9.0.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/README.md +101 -28
- package/data/linter-config-inventory.json +294 -128
- package/data/oxlint-config-inventory.json +913 -735
- package/data/oxlint-rule-map.json +4684 -1743
- package/data/oxlint-source-inventory.json +10529 -8546
- package/docs/OXLINT_RULE_MAPPING.md +197 -88
- package/docs/RULE_MAPPING.md +2 -2
- package/package.json +122 -18
- package/scripts/README.md +12 -5
- package/scripts/init-angular-ox.sh +4 -0
- package/scripts/init-nuxt-ox.sh +4 -0
- package/scripts/init-vue-ox.sh +4 -0
- package/scripts/linter-init-core.mjs +75 -20
- package/scripts/linter-init.mjs +5 -3
- package/src/eslint/configs/config.import.js +1 -1
- package/src/eslint/configs/config.react.js +17 -24
- package/src/eslint/configs/import-plugin.js +48 -0
- package/src/eslint/configs/svelte-stack.js +4 -11
- package/src/eslint/eslint.config.angular-ox.js +26 -0
- package/src/eslint/eslint.config.astro-ox.js +3 -0
- package/src/eslint/eslint.config.nuxt-ox.js +4 -0
- package/src/eslint/eslint.config.svelte-ox.js +4 -0
- package/src/eslint/eslint.config.vue-ox.js +17 -0
- package/src/eslint/ox-supplement.d.ts +39 -0
- package/src/oxfmt/index.d.ts +32 -0
- package/src/oxfmt/oxfmt.config.angular.js +3 -0
- package/src/oxfmt/oxfmt.config.astro.js +3 -0
- package/src/oxfmt/oxfmt.config.common.js +16 -0
- package/src/oxfmt/oxfmt.config.svelte.js +3 -0
- package/src/oxlint/configs/config.astro.js +89 -42
- package/src/oxlint/configs/config.common.js +73 -28
- package/src/oxlint/configs/config.next.js +330 -173
- package/src/oxlint/configs/config.react.js +330 -173
- package/src/oxlint/configs/config.solid.js +105 -47
- package/src/oxlint/configs/config.svelte.js +85 -61
- package/src/oxlint/create-config.js +1 -1
- package/src/oxlint/framework-rules.js +79 -0
- package/src/oxlint/index.d.ts +24 -0
- package/src/oxlint/oxlint.config.angular.js +14 -0
- package/src/oxlint/oxlint.config.nuxt.js +24 -0
- package/src/oxlint/oxlint.config.vue.js +8 -0
- package/src/oxlint/plugins/angular.js +1 -0
- package/src/oxlint/plugins/import-x.js +1 -1
- package/src/oxlint/plugins/nuxt.js +1 -0
- package/src/oxlint/plugins/react.js +1 -1
- package/src/oxlint/stacks.js +30 -5
package/docs/RULE_MAPPING.md
CHANGED
|
@@ -35,9 +35,9 @@ Inventory rule counts (sample files in this repository):
|
|
|
35
35
|
|
|
36
36
|
## Oxlint counterparts
|
|
37
37
|
|
|
38
|
-
The package also exports `common-ox`, `react-ox`, `solid-ox`, `next-ox`, `svelte-ox` and `
|
|
38
|
+
The package also exports `common-ox`, `react-ox`, `solid-ox`, `next-ox`, `svelte-ox`, `astro-ox`, `angular-ox`, `vue-ox` and `nuxt-ox`. Each is one `OxlintConfig` object, used through `oxlint.config.ts`, with `options.typeAware: true` and Oxlint's own native tsgolint engine. The project compiler and declaration checks stay on TypeScript 6; the original ESLint presets remain available.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
All nine Ox variants use Oxlint and a separate `oxfmt --check`; source `prettier/prettier` checks in the six migrated presets are recorded as `formatter` instead of running a Prettier JS plugin. Svelte/Astro use `oxfmt-svelte`/`oxfmt-astro`, Angular uses `oxfmt-angular`, and other stacks use `oxfmt-common`. Every stack retains Stylelint. Svelte/Astro/Angular/Vue/Nuxt additionally generate an ESLint companion for framework/template checks; running Oxlint alone does not cover templates. See [OXLINT_RULE_MAPPING.md](OXLINT_RULE_MAPPING.md) for the six source-derived presets' correspondence and gaps. Angular/Vue/Nuxt compose the common preset and have separately tested framework integrations, not a claim of complete source/target parity.
|
|
41
41
|
|
|
42
42
|
Regenerate and verify the Oxlint inventory with:
|
|
43
43
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@st1ggy/linter-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "ESLint, Prettier, and Stylelint
|
|
3
|
+
"version": "9.0.0",
|
|
4
|
+
"description": "Shareable ESLint, Oxlint, Oxfmt, Prettier, and Stylelint configs.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
31
31
|
"eslint": "^10.8.0",
|
|
32
32
|
"eslint-config-prettier": "^10.1.8",
|
|
33
|
-
"eslint-import-resolver-custom-alias": "^1.3.2",
|
|
34
33
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
35
34
|
"eslint-plugin-import-x": "^4.17.1",
|
|
36
35
|
"eslint-plugin-prettier": "^5.5.6",
|
|
@@ -123,11 +122,71 @@
|
|
|
123
122
|
"import": "./src/oxlint/oxlint.config.astro.js",
|
|
124
123
|
"default": "./src/oxlint/oxlint.config.astro.js"
|
|
125
124
|
},
|
|
125
|
+
"./angular-ox": {
|
|
126
|
+
"types": "./src/oxlint/index.d.ts",
|
|
127
|
+
"import": "./src/oxlint/oxlint.config.angular.js",
|
|
128
|
+
"default": "./src/oxlint/oxlint.config.angular.js"
|
|
129
|
+
},
|
|
130
|
+
"./vue-ox": {
|
|
131
|
+
"types": "./src/oxlint/index.d.ts",
|
|
132
|
+
"import": "./src/oxlint/oxlint.config.vue.js",
|
|
133
|
+
"default": "./src/oxlint/oxlint.config.vue.js"
|
|
134
|
+
},
|
|
135
|
+
"./nuxt-ox": {
|
|
136
|
+
"types": "./src/oxlint/index.d.ts",
|
|
137
|
+
"import": "./src/oxlint/oxlint.config.nuxt.js",
|
|
138
|
+
"default": "./src/oxlint/oxlint.config.nuxt.js"
|
|
139
|
+
},
|
|
140
|
+
"./eslint-svelte-ox": {
|
|
141
|
+
"types": "./src/eslint/ox-supplement.d.ts",
|
|
142
|
+
"import": "./src/eslint/eslint.config.svelte-ox.js",
|
|
143
|
+
"default": "./src/eslint/eslint.config.svelte-ox.js"
|
|
144
|
+
},
|
|
145
|
+
"./eslint-astro-ox": {
|
|
146
|
+
"types": "./src/eslint/ox-supplement.d.ts",
|
|
147
|
+
"import": "./src/eslint/eslint.config.astro-ox.js",
|
|
148
|
+
"default": "./src/eslint/eslint.config.astro-ox.js"
|
|
149
|
+
},
|
|
150
|
+
"./eslint-angular-ox": {
|
|
151
|
+
"types": "./src/eslint/ox-supplement.d.ts",
|
|
152
|
+
"import": "./src/eslint/eslint.config.angular-ox.js",
|
|
153
|
+
"default": "./src/eslint/eslint.config.angular-ox.js"
|
|
154
|
+
},
|
|
155
|
+
"./eslint-vue-ox": {
|
|
156
|
+
"types": "./src/eslint/ox-supplement.d.ts",
|
|
157
|
+
"import": "./src/eslint/eslint.config.vue-ox.js",
|
|
158
|
+
"default": "./src/eslint/eslint.config.vue-ox.js"
|
|
159
|
+
},
|
|
160
|
+
"./eslint-nuxt-ox": {
|
|
161
|
+
"types": "./src/eslint/ox-supplement.d.ts",
|
|
162
|
+
"import": "./src/eslint/eslint.config.nuxt-ox.js",
|
|
163
|
+
"default": "./src/eslint/eslint.config.nuxt-ox.js"
|
|
164
|
+
},
|
|
126
165
|
"./prettier-common": {
|
|
127
166
|
"types": "./index.d.ts",
|
|
128
167
|
"import": "./src/prettier/prettier.config.common.js",
|
|
129
168
|
"default": "./src/prettier/prettier.config.common.js"
|
|
130
169
|
},
|
|
170
|
+
"./oxfmt-common": {
|
|
171
|
+
"types": "./src/oxfmt/index.d.ts",
|
|
172
|
+
"import": "./src/oxfmt/oxfmt.config.common.js",
|
|
173
|
+
"default": "./src/oxfmt/oxfmt.config.common.js"
|
|
174
|
+
},
|
|
175
|
+
"./oxfmt-svelte": {
|
|
176
|
+
"types": "./src/oxfmt/index.d.ts",
|
|
177
|
+
"import": "./src/oxfmt/oxfmt.config.svelte.js",
|
|
178
|
+
"default": "./src/oxfmt/oxfmt.config.svelte.js"
|
|
179
|
+
},
|
|
180
|
+
"./oxfmt-astro": {
|
|
181
|
+
"types": "./src/oxfmt/index.d.ts",
|
|
182
|
+
"import": "./src/oxfmt/oxfmt.config.astro.js",
|
|
183
|
+
"default": "./src/oxfmt/oxfmt.config.astro.js"
|
|
184
|
+
},
|
|
185
|
+
"./oxfmt-angular": {
|
|
186
|
+
"types": "./src/oxfmt/index.d.ts",
|
|
187
|
+
"import": "./src/oxfmt/oxfmt.config.angular.js",
|
|
188
|
+
"default": "./src/oxfmt/oxfmt.config.angular.js"
|
|
189
|
+
},
|
|
131
190
|
"./prettier-svelte": {
|
|
132
191
|
"types": "./index.d.ts",
|
|
133
192
|
"import": "./src/prettier/prettier-svelte.config.js",
|
|
@@ -153,6 +212,7 @@
|
|
|
153
212
|
"!scripts/fixtures",
|
|
154
213
|
"!scripts/*.test.mjs",
|
|
155
214
|
"!scripts/oxlint-*.mjs",
|
|
215
|
+
"!scripts/oxfmt-*.mjs",
|
|
156
216
|
"!scripts/package-smoke.mjs"
|
|
157
217
|
],
|
|
158
218
|
"scripts": {
|
|
@@ -166,12 +226,14 @@
|
|
|
166
226
|
"changelog:dry": "conventional-changelog -p conventionalcommits",
|
|
167
227
|
"publish:npm": "npm publish --access public",
|
|
168
228
|
"inventory": "node ./scripts/inventory.mjs",
|
|
169
|
-
"typecheck
|
|
229
|
+
"typecheck": "node ./node_modules/typescript/bin/tsc --noEmit",
|
|
170
230
|
"generate:ox": "node scripts/oxlint-generate.mjs",
|
|
171
231
|
"generate:ox:check": "node scripts/oxlint-generate.mjs --check",
|
|
172
232
|
"inventory:ox": "node scripts/oxlint-inventory.mjs --write",
|
|
173
233
|
"inventory:ox:check": "node scripts/oxlint-inventory.mjs --source-only --check && node scripts/oxlint-inventory.mjs --check",
|
|
174
234
|
"test:ox": "node --test --test-concurrency=2 scripts/oxlint-*.test.mjs",
|
|
235
|
+
"format:ox:compare": "node scripts/oxfmt-compare.mjs",
|
|
236
|
+
"format:ox:check": "oxfmt --config ./src/oxfmt/oxfmt.config.common.js --check .",
|
|
175
237
|
"config:init": "node ./scripts/linter-init.mjs init --common --dir ./examples/init-smoke",
|
|
176
238
|
"config:migrate": "node ./scripts/linter-init.mjs migrate --common --dir ./examples/init-smoke",
|
|
177
239
|
"config:reinit": "node ./scripts/linter-init.mjs reinit --common --dir ./examples/init-smoke",
|
|
@@ -179,35 +241,64 @@
|
|
|
179
241
|
"config:remove-current": "bash ./scripts/remove-current.sh"
|
|
180
242
|
},
|
|
181
243
|
"peerDependencies": {
|
|
244
|
+
"@angular-eslint/eslint-plugin": "^22.6.0",
|
|
245
|
+
"@angular-eslint/eslint-plugin-template": "^22.6.0",
|
|
246
|
+
"@angular-eslint/template-parser": "^22.6.0",
|
|
247
|
+
"@astrojs/compiler-rs": "^0.5.2",
|
|
248
|
+
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
249
|
+
"@nuxt/eslint-plugin": "^1.17.0",
|
|
182
250
|
"astro": ">=4.0.0",
|
|
183
251
|
"eslint": "^10.8.0",
|
|
184
252
|
"eslint-plugin-astro": "^3.1.0",
|
|
185
|
-
"eslint-plugin-jsx-a11y": "^
|
|
186
|
-
"eslint-plugin-react": "^7.37.5",
|
|
253
|
+
"eslint-plugin-jsx-a11y-x": "^0.2.0",
|
|
187
254
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
188
255
|
"eslint-plugin-solid": "^0.18.0",
|
|
189
256
|
"eslint-plugin-svelte": "^3.22.0",
|
|
257
|
+
"eslint-plugin-vue": "^10.12.0",
|
|
190
258
|
"next": "^16.3.0",
|
|
191
|
-
"
|
|
192
|
-
"oxlint
|
|
259
|
+
"oxfmt": "0.75.0",
|
|
260
|
+
"oxlint": "1.90.0",
|
|
261
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
193
262
|
"prettier": "^3.9.6",
|
|
194
263
|
"prettier-plugin-astro": "^0.14.1",
|
|
195
264
|
"prettier-plugin-svelte": "^4.1.1",
|
|
196
265
|
"react": "^18.0.0 || ^19.0.0",
|
|
197
266
|
"stylelint": "^17.14.1",
|
|
198
|
-
"svelte": "^4.0.0 || ^5.0.0"
|
|
267
|
+
"svelte": "^4.0.0 || ^5.0.0",
|
|
268
|
+
"vue-eslint-parser": "^10.4.1"
|
|
199
269
|
},
|
|
200
270
|
"peerDependenciesMeta": {
|
|
271
|
+
"@angular-eslint/eslint-plugin": {
|
|
272
|
+
"optional": true
|
|
273
|
+
},
|
|
274
|
+
"@angular-eslint/eslint-plugin-template": {
|
|
275
|
+
"optional": true
|
|
276
|
+
},
|
|
277
|
+
"@angular-eslint/template-parser": {
|
|
278
|
+
"optional": true
|
|
279
|
+
},
|
|
280
|
+
"@astrojs/compiler-rs": {
|
|
281
|
+
"optional": true
|
|
282
|
+
},
|
|
283
|
+
"@nuxt/eslint-plugin": {
|
|
284
|
+
"optional": true
|
|
285
|
+
},
|
|
286
|
+
"eslint-plugin-vue": {
|
|
287
|
+
"optional": true
|
|
288
|
+
},
|
|
289
|
+
"vue-eslint-parser": {
|
|
290
|
+
"optional": true
|
|
291
|
+
},
|
|
201
292
|
"eslint": {
|
|
202
293
|
"optional": true
|
|
203
294
|
},
|
|
204
295
|
"eslint-plugin-astro": {
|
|
205
296
|
"optional": true
|
|
206
297
|
},
|
|
207
|
-
"eslint-plugin-jsx-a11y": {
|
|
298
|
+
"eslint-plugin-jsx-a11y-x": {
|
|
208
299
|
"optional": true
|
|
209
300
|
},
|
|
210
|
-
"eslint-plugin
|
|
301
|
+
"@eslint-react/eslint-plugin": {
|
|
211
302
|
"optional": true
|
|
212
303
|
},
|
|
213
304
|
"eslint-plugin-react-hooks": {
|
|
@@ -225,6 +316,9 @@
|
|
|
225
316
|
"oxlint": {
|
|
226
317
|
"optional": true
|
|
227
318
|
},
|
|
319
|
+
"oxfmt": {
|
|
320
|
+
"optional": true
|
|
321
|
+
},
|
|
228
322
|
"oxlint-tsgolint": {
|
|
229
323
|
"optional": true
|
|
230
324
|
},
|
|
@@ -251,23 +345,33 @@
|
|
|
251
345
|
}
|
|
252
346
|
},
|
|
253
347
|
"devDependencies": {
|
|
254
|
-
"@
|
|
255
|
-
"
|
|
348
|
+
"@angular-eslint/eslint-plugin": "^22.6.0",
|
|
349
|
+
"@angular-eslint/eslint-plugin-template": "^22.6.0",
|
|
350
|
+
"@angular-eslint/template-parser": "^22.6.0",
|
|
351
|
+
"@angular/core": "^22.2.4",
|
|
352
|
+
"@astrojs/compiler-rs": "^0.5.2",
|
|
353
|
+
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
256
354
|
"@next/eslint-plugin-next": "^16.3.0",
|
|
355
|
+
"@nuxt/eslint-plugin": "^1.17.0",
|
|
257
356
|
"@stylistic/eslint-plugin-migrate": "^4.4.1",
|
|
258
357
|
"conventional-changelog": "^8.1.0",
|
|
259
358
|
"conventional-changelog-conventionalcommits": "^10.2.1",
|
|
260
359
|
"eslint-plugin-astro": "^3.1.0",
|
|
261
|
-
"eslint-plugin-jsx-a11y": "
|
|
262
|
-
"eslint-plugin-react": "^7.37.5",
|
|
360
|
+
"eslint-plugin-jsx-a11y-x": "0.2.0",
|
|
263
361
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
264
362
|
"eslint-plugin-solid": "^0.18.0",
|
|
265
363
|
"eslint-plugin-svelte": "^3.22.0",
|
|
266
|
-
"
|
|
267
|
-
"
|
|
364
|
+
"eslint-plugin-vue": "^10.12.0",
|
|
365
|
+
"oxfmt": "0.75.0",
|
|
366
|
+
"oxlint": "1.90.0",
|
|
367
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
368
|
+
"pnpm": "10.34.9",
|
|
268
369
|
"prettier-plugin-astro": "^0.14.1",
|
|
269
370
|
"prettier-plugin-svelte": "^4.1.1",
|
|
371
|
+
"rxjs": "^7.8.2",
|
|
270
372
|
"solid-js": "^1.9.15",
|
|
271
|
-
"svelte": "^5.56.8"
|
|
373
|
+
"svelte": "^5.56.8",
|
|
374
|
+
"vue": "^3.5.44",
|
|
375
|
+
"vue-eslint-parser": "^10.4.1"
|
|
272
376
|
}
|
|
273
377
|
}
|
package/scripts/README.md
CHANGED
|
@@ -42,7 +42,7 @@ npx --yes @st1ggy/linter-config init --astro
|
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
- **ESLint stacks:** `--common` | `--react` | `--solid` | `--next` | `--svelte` | `--astro`.
|
|
45
|
-
- **Oxlint stacks:** `--common-ox` | `--react-ox` | `--solid-ox` | `--next-ox` | `--svelte-ox` | `--astro-ox`.
|
|
45
|
+
- **Oxlint stacks:** `--common-ox` | `--react-ox` | `--solid-ox` | `--next-ox` | `--svelte-ox` | `--astro-ox` | `--angular-ox` | `--vue-ox` | `--nuxt-ox`.
|
|
46
46
|
- Select at most one stack; the default is `common`.
|
|
47
47
|
- **`--skip-install`:** only write wrapper files; do not run npm/pnpm/yarn/bun.
|
|
48
48
|
- Every CLI command opens an interactive wizard. `init` creates missing wrappers; `migrate` can remove selected legacy configs and replaces wrappers.
|
|
@@ -53,17 +53,22 @@ For SolidJS, `init-solid.sh` selects `eslint-solid`, `prettier-common`, and `sty
|
|
|
53
53
|
|
|
54
54
|
## Oxlint wrappers
|
|
55
55
|
|
|
56
|
-
The
|
|
56
|
+
The nine `init-*-ox.sh` shortcuts select the corresponding `*-ox` stack. All write `oxlint.config.ts`, `oxfmt.config.ts` and `stylelint.config.js`. Svelte/Astro/Angular/Vue/Nuxt also write `eslint.config.js` for framework/template checks and install `eslint@10.14.0` directly. The wizard pins `oxlint@1.90.0`, `oxlint-tsgolint@7.0.2005` and `oxfmt@0.75.0` and installs only the selected framework integrations. Svelte Ox requires Svelte 5; Astro formatting requires `@astrojs/compiler-rs`. The Angular runtime and generated Nuxt project types remain the application's responsibility.
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
npx @st1ggy/linter-config init --react-ox
|
|
60
60
|
npx @st1ggy/linter-config migrate --astro-ox
|
|
61
61
|
node ./scripts/linter-init.mjs init --solid-ox --dir ./my-app --skip-install
|
|
62
|
+
npx @st1ggy/linter-config init --angular-ox
|
|
63
|
+
npx @st1ggy/linter-config init --vue-ox
|
|
64
|
+
npx @st1ggy/linter-config init --nuxt-ox
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
`init` preserves existing wrappers, including the other
|
|
67
|
+
`init` preserves existing wrappers, including the other linter/formatter config. `migrate` offers the opposite configs and old `.oxlintrc.*`/`.oxfmtrc.*` files for removal before generating the selected wrappers. It never deletes them without confirmation.
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
For every Ox stack, run `oxlint .` and `oxfmt --check .` separately. Also run `eslint .` for Svelte/Astro/Angular/Vue/Nuxt; otherwise template checks are lost. These configs do not run Prettier's JS rule. `oxfmt --write .` formats after lint fixes; import and package.json sorting are disabled. The shared formatter options are available through `@st1ggy/linter-config/oxfmt-common`; Svelte/Astro/Angular use `oxfmt-svelte`, `oxfmt-astro` and `oxfmt-angular` respectively.
|
|
70
|
+
|
|
71
|
+
The project compiler stays on TypeScript 6. Oxlint uses its own tsgolint engine for typed linting; it does not install or replace the project compiler. That engine has independent tsconfig constraints (such as no `baseUrl` support); the generator does not modify consumer configs. Read the [usage guide](../README.md#oxlint-variants) and [coverage report](../docs/OXLINT_RULE_MAPPING.md) before switching. The generated inventory covers the six source-derived presets; Angular/Vue/Nuxt compose the common preset and have separate integration tests. ESLint companions restore framework/template checks, not every unsupported general-purpose typed rule.
|
|
67
72
|
|
|
68
73
|
## Oxlint development checks
|
|
69
74
|
|
|
@@ -74,7 +79,9 @@ npm run inventory:ox
|
|
|
74
79
|
npm run generate:ox:check
|
|
75
80
|
npm run inventory:ox:check
|
|
76
81
|
npm run test:ox
|
|
77
|
-
npm run
|
|
82
|
+
npm run format:ox:check
|
|
83
|
+
npm run format:ox:compare
|
|
84
|
+
npm run typecheck
|
|
78
85
|
node scripts/package-smoke.mjs
|
|
79
86
|
node scripts/package-smoke.mjs --pm pnpm
|
|
80
87
|
```
|
|
@@ -4,13 +4,19 @@ import { spawnSync } from 'node:child_process'
|
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
5
5
|
import path from 'node:path'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
OXFMT_PRESETS,
|
|
9
|
+
OXFMT_STACKS,
|
|
10
|
+
OX_FRAMEWORK_PACKAGES,
|
|
11
|
+
SUPPLEMENT_STACKS,
|
|
12
|
+
oxStackToolVersions,
|
|
13
|
+
} from '../src/oxlint/stacks.js'
|
|
8
14
|
|
|
9
15
|
export const PACKAGE = '@st1ggy/linter-config'
|
|
10
16
|
|
|
11
17
|
const BASE_STACK_KEYS = ['common', 'react', 'solid', 'next', 'svelte', 'astro']
|
|
12
18
|
|
|
13
|
-
export const STACK_KEYS = [...BASE_STACK_KEYS, ...
|
|
19
|
+
export const STACK_KEYS = [...BASE_STACK_KEYS, ...OXFMT_STACKS.map((key) => `${key}-ox`)]
|
|
14
20
|
|
|
15
21
|
export const STACKS = {
|
|
16
22
|
common: {
|
|
@@ -23,7 +29,7 @@ export const STACKS = {
|
|
|
23
29
|
eslint: 'eslint-react',
|
|
24
30
|
prettier: 'prettier-common',
|
|
25
31
|
stylelint: 'stylelint-scss',
|
|
26
|
-
packages: ['eslint-plugin
|
|
32
|
+
packages: ['@eslint-react/eslint-plugin', 'eslint-plugin-react-hooks'],
|
|
27
33
|
},
|
|
28
34
|
solid: {
|
|
29
35
|
eslint: 'eslint-solid',
|
|
@@ -35,7 +41,7 @@ export const STACKS = {
|
|
|
35
41
|
eslint: 'eslint-next',
|
|
36
42
|
prettier: 'prettier-common',
|
|
37
43
|
stylelint: 'stylelint-scss',
|
|
38
|
-
packages: ['@next/eslint-plugin-next', 'eslint-plugin
|
|
44
|
+
packages: ['@next/eslint-plugin-next', '@eslint-react/eslint-plugin', 'eslint-plugin-react-hooks'],
|
|
39
45
|
},
|
|
40
46
|
svelte: {
|
|
41
47
|
eslint: 'eslint-svelte',
|
|
@@ -47,7 +53,7 @@ export const STACKS = {
|
|
|
47
53
|
eslint: 'eslint-astro',
|
|
48
54
|
prettier: 'prettier-astro',
|
|
49
55
|
stylelint: 'stylelint-scss',
|
|
50
|
-
packages: ['eslint-plugin-astro', 'eslint-plugin-jsx-a11y', 'prettier-plugin-astro'],
|
|
56
|
+
packages: ['eslint-plugin-astro', 'eslint-plugin-jsx-a11y-x', 'prettier-plugin-astro'],
|
|
51
57
|
},
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -83,14 +89,24 @@ for (const key of BASE_STACK_KEYS) {
|
|
|
83
89
|
|
|
84
90
|
base.linterFile = 'eslint.config.js'
|
|
85
91
|
base.linterPreset = base.eslint
|
|
92
|
+
base.formatterFile = 'prettier.config.js'
|
|
93
|
+
base.formatterPreset = base.prettier
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (const key of OXFMT_STACKS) {
|
|
86
97
|
STACKS[`${key}-ox`] = {
|
|
87
98
|
linterFile: 'oxlint.config.ts',
|
|
88
99
|
linterPreset: `${key}-ox`,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
formatterFile: 'oxfmt.config.ts',
|
|
101
|
+
formatterPreset: OXFMT_PRESETS[key] ?? 'oxfmt-common',
|
|
102
|
+
supplementPreset: SUPPLEMENT_STACKS.includes(key) ? `eslint-${key}-ox` : undefined,
|
|
103
|
+
stylelint: 'stylelint-scss',
|
|
104
|
+
packages: [...Object.keys(oxStackToolVersions(key)), ...OX_FRAMEWORK_PACKAGES[key]],
|
|
92
105
|
}
|
|
93
|
-
STACK_CHOICES.push({
|
|
106
|
+
STACK_CHOICES.push({
|
|
107
|
+
value: `${key}-ox`,
|
|
108
|
+
name: `${key}-ox — Oxlint + Oxfmt${SUPPLEMENT_STACKS.includes(key) ? ' + ESLint framework/template checks' : ''}`,
|
|
109
|
+
})
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
export function readPackageJson(directory) {
|
|
@@ -298,9 +314,25 @@ export function stackPackages(stackKey) {
|
|
|
298
314
|
export function stackPackageSpecs(stackKey) {
|
|
299
315
|
stackPackages(stackKey)
|
|
300
316
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
317
|
+
if (!stackKey.endsWith('-ox')) {
|
|
318
|
+
return {}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const versions = oxStackToolVersions(stackKey.slice(0, -3))
|
|
322
|
+
|
|
323
|
+
return Object.fromEntries(Object.entries(versions).map(([name, version]) => [name, `${name}@${version}`]))
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function assertStackRuntime(directory, stackKey) {
|
|
327
|
+
if (stackKey !== 'svelte-ox') {
|
|
328
|
+
return
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const file = packageManifestPath(directory, 'svelte')
|
|
332
|
+
|
|
333
|
+
if (file && !JSON.parse(readFileSync(file, 'utf8')).version.startsWith('5.')) {
|
|
334
|
+
throw new Error('svelte-ox requires Svelte 5 for Oxfmt. Upgrade Svelte explicitly before selecting this stack.')
|
|
335
|
+
}
|
|
304
336
|
}
|
|
305
337
|
|
|
306
338
|
export function printHelp() {
|
|
@@ -317,7 +349,8 @@ Commands:
|
|
|
317
349
|
|
|
318
350
|
Writes (each command):
|
|
319
351
|
ESLint stacks: eslint.config.js, prettier.config.js, stylelint.config.js.
|
|
320
|
-
|
|
352
|
+
All Ox stacks: oxlint.config.ts, oxfmt.config.ts, stylelint.config.js.
|
|
353
|
+
svelte/astro/angular/vue/nuxt-ox also write eslint.config.js for framework/template checks.
|
|
321
354
|
|
|
322
355
|
Unless --skip-install: if package.json exists, runs the detected package manager to add or sync
|
|
323
356
|
${PACKAGE} and the selected stack's integration plugins.
|
|
@@ -325,6 +358,7 @@ ${PACKAGE} and the selected stack's integration plugins.
|
|
|
325
358
|
Stack (at most one; default: common):
|
|
326
359
|
--common | --react | --solid | --next | --svelte | --astro
|
|
327
360
|
--common-ox | --react-ox | --solid-ox | --next-ox | --svelte-ox | --astro-ox
|
|
361
|
+
--angular-ox | --vue-ox | --nuxt-ox
|
|
328
362
|
|
|
329
363
|
Options:
|
|
330
364
|
--dir, -d Target directory (default: current working directory).
|
|
@@ -349,8 +383,8 @@ Repo (paths from root):
|
|
|
349
383
|
`)
|
|
350
384
|
}
|
|
351
385
|
|
|
352
|
-
export function jsReExport(subpath) {
|
|
353
|
-
return `export { default } from '${PACKAGE}/${subpath}'
|
|
386
|
+
export function jsReExport(subpath, hasSemicolon = true) {
|
|
387
|
+
return `export { default } from '${PACKAGE}/${subpath}'${hasSemicolon ? ';' : ''}\n`
|
|
354
388
|
}
|
|
355
389
|
|
|
356
390
|
export function resolveTargetDirectory(raw) {
|
|
@@ -382,7 +416,14 @@ export function writeFile(targetDirectory, name, content, overwrite, options = {
|
|
|
382
416
|
export function wrapperFileNames(stackKey = 'common') {
|
|
383
417
|
stackPackages(stackKey)
|
|
384
418
|
|
|
385
|
-
|
|
419
|
+
const stack = STACKS[stackKey]
|
|
420
|
+
|
|
421
|
+
return [
|
|
422
|
+
stack.linterFile,
|
|
423
|
+
stack.formatterFile,
|
|
424
|
+
'stylelint.config.js',
|
|
425
|
+
...(stack.supplementPreset ? ['eslint.config.js'] : []),
|
|
426
|
+
]
|
|
386
427
|
}
|
|
387
428
|
|
|
388
429
|
export function existingWrapperFiles(targetDirectory, stackKey = 'common') {
|
|
@@ -399,7 +440,7 @@ export function legacyConfigFiles(targetDirectory, stackKey = 'common') {
|
|
|
399
440
|
return readdirSync(targetDirectory, { withFileTypes: true })
|
|
400
441
|
.filter(
|
|
401
442
|
(entry) =>
|
|
402
|
-
entry.isFile() && /(?:eslint|oxlint|prettier|stylelint)/i.test(entry.name) && !wrappers.has(entry.name),
|
|
443
|
+
entry.isFile() && /(?:eslint|oxlint|oxfmt|prettier|stylelint)/i.test(entry.name) && !wrappers.has(entry.name),
|
|
403
444
|
)
|
|
404
445
|
.map((entry) => entry.name)
|
|
405
446
|
.toSorted((left, right) => left.localeCompare(right))
|
|
@@ -441,9 +482,23 @@ export function run(mode, targetDirectory, stackKey, options = {}) {
|
|
|
441
482
|
throw new Error(`Unknown stack "${stackKey}". Use: ${STACK_KEYS.join(', ')}`)
|
|
442
483
|
}
|
|
443
484
|
|
|
485
|
+
assertStackRuntime(targetDirectory, stackKey)
|
|
486
|
+
|
|
444
487
|
const shouldOverwrite = mode === 'migrate' || mode === 'reinit'
|
|
445
488
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
writeFile(targetDirectory,
|
|
489
|
+
const hasSemicolon = !stackKey.endsWith('-ox')
|
|
490
|
+
|
|
491
|
+
writeFile(targetDirectory, stack.linterFile, jsReExport(stack.linterPreset, hasSemicolon), shouldOverwrite, { quiet })
|
|
492
|
+
writeFile(targetDirectory, stack.formatterFile, jsReExport(stack.formatterPreset, hasSemicolon), shouldOverwrite, {
|
|
493
|
+
quiet,
|
|
494
|
+
})
|
|
495
|
+
writeFile(targetDirectory, 'stylelint.config.js', jsReExport(stack.stylelint, hasSemicolon), shouldOverwrite, {
|
|
496
|
+
quiet,
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
if (stack.supplementPreset) {
|
|
500
|
+
writeFile(targetDirectory, 'eslint.config.js', jsReExport(stack.supplementPreset, false), shouldOverwrite, {
|
|
501
|
+
quiet,
|
|
502
|
+
})
|
|
503
|
+
}
|
|
449
504
|
}
|
package/scripts/linter-init.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @st1ggy/linter-config — interactive menu (TTY) or minimist CLI.
|
|
3
3
|
|
|
4
|
-
import { CancelPromptError, ExitPromptError } from '@inquirer/core'
|
|
5
4
|
import { confirm, input, select } from '@inquirer/prompts'
|
|
6
5
|
import minimist from 'minimist'
|
|
7
6
|
import process from 'node:process'
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
PACKAGE,
|
|
12
11
|
STACK_CHOICES,
|
|
13
12
|
STACK_KEYS,
|
|
13
|
+
assertStackRuntime,
|
|
14
14
|
ensureDevDependencies,
|
|
15
15
|
existingWrapperFiles,
|
|
16
16
|
isSelfPackageRoot,
|
|
@@ -60,7 +60,7 @@ async function selectCommand(command) {
|
|
|
60
60
|
choices: [
|
|
61
61
|
{
|
|
62
62
|
value: 'init',
|
|
63
|
-
name: 'init — create missing linter,
|
|
63
|
+
name: 'init — create missing linter, formatter and Stylelint wrappers',
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
value: 'migrate',
|
|
@@ -130,6 +130,8 @@ async function runInteractive(command, values) {
|
|
|
130
130
|
)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
assertStackRuntime(resolved, selectedStack)
|
|
134
|
+
|
|
133
135
|
const shouldSkipInstall = values['skip-install'] === true
|
|
134
136
|
const existing = existingWrapperFiles(resolved, selectedStack)
|
|
135
137
|
const filesToRemove = await selectLegacyFiles(selectedCommand, resolved, selectedStack)
|
|
@@ -215,7 +217,7 @@ async function runInteractiveOrHandleErrors(command, values) {
|
|
|
215
217
|
warnLegacyFlags(values)
|
|
216
218
|
await runInteractive(command, values)
|
|
217
219
|
} catch (error) {
|
|
218
|
-
if (error instanceof ExitPromptError || error
|
|
220
|
+
if (error instanceof Error && (error.name === 'ExitPromptError' || error.name === 'CancelPromptError')) {
|
|
219
221
|
process.stdout.write('\nCancelled.\n')
|
|
220
222
|
process.exitCode = 0
|
|
221
223
|
|
|
@@ -1,40 +1,33 @@
|
|
|
1
|
+
import reactPlugin from '@eslint-react/eslint-plugin'
|
|
1
2
|
import { defineConfig } from 'eslint/config'
|
|
2
|
-
import reactPlugin from 'eslint-plugin-react'
|
|
3
3
|
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
4
4
|
|
|
5
5
|
import { files } from './constants.js'
|
|
6
6
|
|
|
7
|
+
// Keep the official hooks integration (and its existing Oxlint mappings) once.
|
|
8
|
+
const duplicateHooks = Object.fromEntries(
|
|
9
|
+
Object.keys(reactHooksPlugin.configs.recommended.rules)
|
|
10
|
+
.map((id) => id.replace('react-hooks/', '@eslint-react/'))
|
|
11
|
+
.filter((id) => Object.hasOwn(reactPlugin.configs.recommended.rules, id))
|
|
12
|
+
.map((id) => [id, 'off']),
|
|
13
|
+
)
|
|
14
|
+
|
|
7
15
|
export default defineConfig([
|
|
8
|
-
reactPlugin.configs.
|
|
9
|
-
reactPlugin.configs.flat['jsx-runtime'],
|
|
16
|
+
{ ...reactPlugin.configs.recommended, files },
|
|
10
17
|
{
|
|
11
18
|
files,
|
|
12
19
|
plugins: { 'react-hooks': reactHooksPlugin },
|
|
13
20
|
rules: {
|
|
14
|
-
|
|
15
|
-
'react/button-
|
|
16
|
-
'react/
|
|
17
|
-
'react/
|
|
18
|
-
'react/
|
|
19
|
-
'react/
|
|
20
|
-
'error',
|
|
21
|
-
{
|
|
22
|
-
namedComponents: 'arrow-function',
|
|
23
|
-
unnamedComponents: 'arrow-function',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
'react/hook-use-state': 'error',
|
|
27
|
-
'react/jsx-boolean-value': 'error',
|
|
28
|
-
'react/jsx-fragments': 'error',
|
|
29
|
-
'react/jsx-handler-names': 'error',
|
|
30
|
-
'react/jsx-no-constructed-context-values': 'error',
|
|
31
|
-
'react/jsx-no-leaked-render': 'error',
|
|
32
|
-
'react/jsx-no-useless-fragment': 'error',
|
|
33
|
-
'react/no-multi-comp': 'error',
|
|
34
|
-
'react/self-closing-comp': ['error', { component: true, html: true }],
|
|
21
|
+
...duplicateHooks,
|
|
22
|
+
'@eslint-react/dom-no-missing-button-type': 'error',
|
|
23
|
+
'@eslint-react/use-state': 'error',
|
|
24
|
+
'@eslint-react/no-unstable-context-value': 'error',
|
|
25
|
+
'@eslint-react/jsx-no-useless-fragment': 'error',
|
|
26
|
+
'@eslint-react/no-missing-component-display-name': 'error',
|
|
35
27
|
|
|
36
28
|
...reactHooksPlugin.configs.recommended.rules,
|
|
37
29
|
// @stylistic
|
|
30
|
+
'@stylistic/jsx-self-closing-comp': ['error', { component: true, html: true }],
|
|
38
31
|
'@stylistic/jsx-closing-bracket-location': 'error',
|
|
39
32
|
'@stylistic/jsx-closing-tag-location': 'error',
|
|
40
33
|
'@stylistic/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
|