@st1ggy/linter-config 8.0.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 +65 -31
- package/data/linter-config-inventory.json +294 -128
- package/data/oxlint-config-inventory.json +787 -786
- package/data/oxlint-rule-map.json +4709 -1805
- package/data/oxlint-source-inventory.json +10529 -8546
- package/docs/OXLINT_RULE_MAPPING.md +192 -87
- package/docs/RULE_MAPPING.md +2 -2
- package/package.json +110 -19
- package/scripts/README.md +8 -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 +50 -15
- package/scripts/linter-init.mjs +4 -2
- 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 +24 -0
- package/src/oxfmt/oxfmt.config.angular.js +3 -0
- package/src/oxfmt/oxfmt.config.astro.js +3 -0
- package/src/oxfmt/oxfmt.config.svelte.js +3 -0
- package/src/oxlint/configs/config.astro.js +89 -43
- package/src/oxlint/configs/config.common.js +71 -23
- package/src/oxlint/configs/config.next.js +329 -168
- package/src/oxlint/configs/config.react.js +329 -168
- package/src/oxlint/configs/config.solid.js +103 -31
- package/src/oxlint/configs/config.svelte.js +85 -62
- 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 +27 -8
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@st1ggy/linter-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Shareable ESLint, Oxlint, Oxfmt, Prettier, and Stylelint configs.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -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,6 +122,46 @@
|
|
|
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",
|
|
@@ -133,6 +172,21 @@
|
|
|
133
172
|
"import": "./src/oxfmt/oxfmt.config.common.js",
|
|
134
173
|
"default": "./src/oxfmt/oxfmt.config.common.js"
|
|
135
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
|
+
},
|
|
136
190
|
"./prettier-svelte": {
|
|
137
191
|
"types": "./index.d.ts",
|
|
138
192
|
"import": "./src/prettier/prettier-svelte.config.js",
|
|
@@ -172,7 +226,7 @@
|
|
|
172
226
|
"changelog:dry": "conventional-changelog -p conventionalcommits",
|
|
173
227
|
"publish:npm": "npm publish --access public",
|
|
174
228
|
"inventory": "node ./scripts/inventory.mjs",
|
|
175
|
-
"typecheck
|
|
229
|
+
"typecheck": "node ./node_modules/typescript/bin/tsc --noEmit",
|
|
176
230
|
"generate:ox": "node scripts/oxlint-generate.mjs",
|
|
177
231
|
"generate:ox:check": "node scripts/oxlint-generate.mjs --check",
|
|
178
232
|
"inventory:ox": "node scripts/oxlint-inventory.mjs --write",
|
|
@@ -187,36 +241,64 @@
|
|
|
187
241
|
"config:remove-current": "bash ./scripts/remove-current.sh"
|
|
188
242
|
},
|
|
189
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",
|
|
190
250
|
"astro": ">=4.0.0",
|
|
191
251
|
"eslint": "^10.8.0",
|
|
192
252
|
"eslint-plugin-astro": "^3.1.0",
|
|
193
|
-
"eslint-plugin-jsx-a11y": "^
|
|
194
|
-
"eslint-plugin-react": "^7.37.5",
|
|
253
|
+
"eslint-plugin-jsx-a11y-x": "^0.2.0",
|
|
195
254
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
196
255
|
"eslint-plugin-solid": "^0.18.0",
|
|
197
256
|
"eslint-plugin-svelte": "^3.22.0",
|
|
257
|
+
"eslint-plugin-vue": "^10.12.0",
|
|
198
258
|
"next": "^16.3.0",
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"oxlint-tsgolint": "7.0.
|
|
259
|
+
"oxfmt": "0.75.0",
|
|
260
|
+
"oxlint": "1.90.0",
|
|
261
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
202
262
|
"prettier": "^3.9.6",
|
|
203
263
|
"prettier-plugin-astro": "^0.14.1",
|
|
204
264
|
"prettier-plugin-svelte": "^4.1.1",
|
|
205
265
|
"react": "^18.0.0 || ^19.0.0",
|
|
206
266
|
"stylelint": "^17.14.1",
|
|
207
|
-
"svelte": "^4.0.0 || ^5.0.0"
|
|
267
|
+
"svelte": "^4.0.0 || ^5.0.0",
|
|
268
|
+
"vue-eslint-parser": "^10.4.1"
|
|
208
269
|
},
|
|
209
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
|
+
},
|
|
210
292
|
"eslint": {
|
|
211
293
|
"optional": true
|
|
212
294
|
},
|
|
213
295
|
"eslint-plugin-astro": {
|
|
214
296
|
"optional": true
|
|
215
297
|
},
|
|
216
|
-
"eslint-plugin-jsx-a11y": {
|
|
298
|
+
"eslint-plugin-jsx-a11y-x": {
|
|
217
299
|
"optional": true
|
|
218
300
|
},
|
|
219
|
-
"eslint-plugin
|
|
301
|
+
"@eslint-react/eslint-plugin": {
|
|
220
302
|
"optional": true
|
|
221
303
|
},
|
|
222
304
|
"eslint-plugin-react-hooks": {
|
|
@@ -263,24 +345,33 @@
|
|
|
263
345
|
}
|
|
264
346
|
},
|
|
265
347
|
"devDependencies": {
|
|
266
|
-
"@
|
|
267
|
-
"
|
|
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",
|
|
268
354
|
"@next/eslint-plugin-next": "^16.3.0",
|
|
355
|
+
"@nuxt/eslint-plugin": "^1.17.0",
|
|
269
356
|
"@stylistic/eslint-plugin-migrate": "^4.4.1",
|
|
270
357
|
"conventional-changelog": "^8.1.0",
|
|
271
358
|
"conventional-changelog-conventionalcommits": "^10.2.1",
|
|
272
359
|
"eslint-plugin-astro": "^3.1.0",
|
|
273
|
-
"eslint-plugin-jsx-a11y": "
|
|
274
|
-
"eslint-plugin-react": "^7.37.5",
|
|
360
|
+
"eslint-plugin-jsx-a11y-x": "0.2.0",
|
|
275
361
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
276
362
|
"eslint-plugin-solid": "^0.18.0",
|
|
277
363
|
"eslint-plugin-svelte": "^3.22.0",
|
|
278
|
-
"
|
|
279
|
-
"oxfmt": "0.
|
|
280
|
-
"oxlint
|
|
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",
|
|
281
369
|
"prettier-plugin-astro": "^0.14.1",
|
|
282
370
|
"prettier-plugin-svelte": "^4.1.1",
|
|
371
|
+
"rxjs": "^7.8.2",
|
|
283
372
|
"solid-js": "^1.9.15",
|
|
284
|
-
"svelte": "^5.56.8"
|
|
373
|
+
"svelte": "^5.56.8",
|
|
374
|
+
"vue": "^3.5.44",
|
|
375
|
+
"vue-eslint-parser": "^10.4.1"
|
|
285
376
|
}
|
|
286
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,19 +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
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
|
-
For
|
|
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.
|
|
67
70
|
|
|
68
|
-
Oxlint uses
|
|
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.
|
|
69
72
|
|
|
70
73
|
## Oxlint development checks
|
|
71
74
|
|
|
@@ -78,7 +81,7 @@ npm run inventory:ox:check
|
|
|
78
81
|
npm run test:ox
|
|
79
82
|
npm run format:ox:check
|
|
80
83
|
npm run format:ox:compare
|
|
81
|
-
npm run typecheck
|
|
84
|
+
npm run typecheck
|
|
82
85
|
node scripts/package-smoke.mjs
|
|
83
86
|
node scripts/package-smoke.mjs --pm pnpm
|
|
84
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
|
|
|
@@ -85,20 +91,21 @@ for (const key of BASE_STACK_KEYS) {
|
|
|
85
91
|
base.linterPreset = base.eslint
|
|
86
92
|
base.formatterFile = 'prettier.config.js'
|
|
87
93
|
base.formatterPreset = base.prettier
|
|
88
|
-
|
|
94
|
+
}
|
|
89
95
|
|
|
96
|
+
for (const key of OXFMT_STACKS) {
|
|
90
97
|
STACKS[`${key}-ox`] = {
|
|
91
98
|
linterFile: 'oxlint.config.ts',
|
|
92
99
|
linterPreset: `${key}-ox`,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
stylelint:
|
|
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',
|
|
97
104
|
packages: [...Object.keys(oxStackToolVersions(key)), ...OX_FRAMEWORK_PACKAGES[key]],
|
|
98
105
|
}
|
|
99
106
|
STACK_CHOICES.push({
|
|
100
107
|
value: `${key}-ox`,
|
|
101
|
-
name: `${key}-ox — Oxlint +
|
|
108
|
+
name: `${key}-ox — Oxlint + Oxfmt${SUPPLEMENT_STACKS.includes(key) ? ' + ESLint framework/template checks' : ''}`,
|
|
102
109
|
})
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -316,6 +323,18 @@ export function stackPackageSpecs(stackKey) {
|
|
|
316
323
|
return Object.fromEntries(Object.entries(versions).map(([name, version]) => [name, `${name}@${version}`]))
|
|
317
324
|
}
|
|
318
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
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
319
338
|
export function printHelp() {
|
|
320
339
|
process.stdout.write(`\
|
|
321
340
|
${PACKAGE} — generate local wrapper configs in a consumer project.
|
|
@@ -330,8 +349,8 @@ Commands:
|
|
|
330
349
|
|
|
331
350
|
Writes (each command):
|
|
332
351
|
ESLint stacks: eslint.config.js, prettier.config.js, stylelint.config.js.
|
|
333
|
-
|
|
334
|
-
|
|
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.
|
|
335
354
|
|
|
336
355
|
Unless --skip-install: if package.json exists, runs the detected package manager to add or sync
|
|
337
356
|
${PACKAGE} and the selected stack's integration plugins.
|
|
@@ -339,6 +358,7 @@ ${PACKAGE} and the selected stack's integration plugins.
|
|
|
339
358
|
Stack (at most one; default: common):
|
|
340
359
|
--common | --react | --solid | --next | --svelte | --astro
|
|
341
360
|
--common-ox | --react-ox | --solid-ox | --next-ox | --svelte-ox | --astro-ox
|
|
361
|
+
--angular-ox | --vue-ox | --nuxt-ox
|
|
342
362
|
|
|
343
363
|
Options:
|
|
344
364
|
--dir, -d Target directory (default: current working directory).
|
|
@@ -396,7 +416,14 @@ export function writeFile(targetDirectory, name, content, overwrite, options = {
|
|
|
396
416
|
export function wrapperFileNames(stackKey = 'common') {
|
|
397
417
|
stackPackages(stackKey)
|
|
398
418
|
|
|
399
|
-
|
|
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
|
+
]
|
|
400
427
|
}
|
|
401
428
|
|
|
402
429
|
export function existingWrapperFiles(targetDirectory, stackKey = 'common') {
|
|
@@ -455,9 +482,11 @@ export function run(mode, targetDirectory, stackKey, options = {}) {
|
|
|
455
482
|
throw new Error(`Unknown stack "${stackKey}". Use: ${STACK_KEYS.join(', ')}`)
|
|
456
483
|
}
|
|
457
484
|
|
|
485
|
+
assertStackRuntime(targetDirectory, stackKey)
|
|
486
|
+
|
|
458
487
|
const shouldOverwrite = mode === 'migrate' || mode === 'reinit'
|
|
459
488
|
|
|
460
|
-
const hasSemicolon =
|
|
489
|
+
const hasSemicolon = !stackKey.endsWith('-ox')
|
|
461
490
|
|
|
462
491
|
writeFile(targetDirectory, stack.linterFile, jsReExport(stack.linterPreset, hasSemicolon), shouldOverwrite, { quiet })
|
|
463
492
|
writeFile(targetDirectory, stack.formatterFile, jsReExport(stack.formatterPreset, hasSemicolon), shouldOverwrite, {
|
|
@@ -466,4 +495,10 @@ export function run(mode, targetDirectory, stackKey, options = {}) {
|
|
|
466
495
|
writeFile(targetDirectory, 'stylelint.config.js', jsReExport(stack.stylelint, hasSemicolon), shouldOverwrite, {
|
|
467
496
|
quiet,
|
|
468
497
|
})
|
|
498
|
+
|
|
499
|
+
if (stack.supplementPreset) {
|
|
500
|
+
writeFile(targetDirectory, 'eslint.config.js', jsReExport(stack.supplementPreset, false), shouldOverwrite, {
|
|
501
|
+
quiet,
|
|
502
|
+
})
|
|
503
|
+
}
|
|
469
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,
|
|
@@ -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' }],
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import importPlugin, { flatConfigs as importConfigs, rules as importRules } from 'eslint-plugin-import-x'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import process from 'node:process'
|
|
4
|
+
|
|
5
|
+
function aliasContext(context) {
|
|
6
|
+
const aliases = context.settings['st1ggy/import-aliases']
|
|
7
|
+
|
|
8
|
+
if (!aliases) {
|
|
9
|
+
return context
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const settings = context.settings
|
|
13
|
+
const resolvers = settings['import-x/resolver'] ?? {}
|
|
14
|
+
const typescript = typeof resolvers.typescript === 'object' ? resolvers.typescript : {}
|
|
15
|
+
const alias = Object.fromEntries(
|
|
16
|
+
Object.entries(aliases).map(([name, target]) => [name, [path.resolve(context.cwd ?? process.cwd(), target)]]),
|
|
17
|
+
)
|
|
18
|
+
const wrapped = Object.create(context)
|
|
19
|
+
|
|
20
|
+
Object.defineProperty(wrapped, 'settings', {
|
|
21
|
+
value: {
|
|
22
|
+
...settings,
|
|
23
|
+
'import-x/resolver': { ...resolvers, typescript: { ...typescript, alias: { ...alias, ...typescript.alias } } },
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return wrapped
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const plugin = {
|
|
31
|
+
...importPlugin,
|
|
32
|
+
rules: Object.fromEntries(
|
|
33
|
+
Object.entries(importRules).map(([name, rule]) => [
|
|
34
|
+
name,
|
|
35
|
+
{ ...rule, create: (context) => rule.create(aliasContext(context)) },
|
|
36
|
+
]),
|
|
37
|
+
),
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const flatConfigs = Object.fromEntries(
|
|
41
|
+
Object.entries(importConfigs).map(([name, config]) => [
|
|
42
|
+
name,
|
|
43
|
+
{ ...config, ...(config.plugins && { plugins: { ...config.plugins, 'import-x': plugin } }) },
|
|
44
|
+
]),
|
|
45
|
+
)
|
|
46
|
+
export const rules = plugin.rules
|
|
47
|
+
|
|
48
|
+
export default plugin
|
|
@@ -4,8 +4,6 @@ import { parser } from 'typescript-eslint'
|
|
|
4
4
|
|
|
5
5
|
const svelteFiles = ['**/*.svelte', '**/*.svelte.ts']
|
|
6
6
|
|
|
7
|
-
const extensions = ['.js']
|
|
8
|
-
|
|
9
7
|
export default defineConfig([
|
|
10
8
|
sveltePlugin.configs['flat/recommended'],
|
|
11
9
|
{
|
|
@@ -22,15 +20,10 @@ export default defineConfig([
|
|
|
22
20
|
},
|
|
23
21
|
},
|
|
24
22
|
settings: {
|
|
25
|
-
'import-
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
$app: 'node_modules/@sveltejs/kit/src/runtime/app',
|
|
30
|
-
'@sveltejs/kit': 'node_modules/@sveltejs/kit/src/exports/index.js',
|
|
31
|
-
},
|
|
32
|
-
extensions,
|
|
33
|
-
},
|
|
23
|
+
'st1ggy/import-aliases': {
|
|
24
|
+
$lib: 'src/lib',
|
|
25
|
+
$app: 'node_modules/@sveltejs/kit/src/runtime/app',
|
|
26
|
+
'@sveltejs/kit': 'node_modules/@sveltejs/kit/src/exports/index.js',
|
|
34
27
|
},
|
|
35
28
|
},
|
|
36
29
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import template from '@angular-eslint/eslint-plugin-template'
|
|
2
|
+
import * as templateParser from '@angular-eslint/template-parser'
|
|
3
|
+
import { parser } from 'typescript-eslint'
|
|
4
|
+
|
|
5
|
+
import { recommendedAngularRules } from '../oxlint/framework-rules.js'
|
|
6
|
+
|
|
7
|
+
const accessibility = Object.fromEntries(
|
|
8
|
+
Object.entries(template.rules)
|
|
9
|
+
.filter(([, rule]) => rule.meta.docs?.description.startsWith('[Accessibility]'))
|
|
10
|
+
.map(([name]) => [`@angular-eslint/template/${name}`, 'error']),
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
export default [
|
|
14
|
+
{ ignores: ['**/node_modules/**', '**/.angular/**', '**/dist/**'] },
|
|
15
|
+
{
|
|
16
|
+
files: ['**/*.ts'],
|
|
17
|
+
languageOptions: { parser },
|
|
18
|
+
processor: template.processors['extract-inline-html'],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
files: ['**/*.html'],
|
|
22
|
+
languageOptions: { parser: templateParser },
|
|
23
|
+
plugins: { '@angular-eslint/template': template },
|
|
24
|
+
rules: { ...recommendedAngularRules(template, '@angular-eslint/template'), ...accessibility },
|
|
25
|
+
},
|
|
26
|
+
]
|