@st1ggy/linter-config 8.0.0 → 10.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 +94 -34
- package/data/linter-config-inventory.json +451 -216
- package/data/oxlint-config-inventory.json +1075 -1074
- package/data/oxlint-rule-map.json +5329 -2075
- package/data/oxlint-source-inventory.json +8175 -5661
- package/docs/OXLINT_RULE_MAPPING.md +213 -105
- package/docs/RULE_MAPPING.md +2 -2
- package/package.json +110 -19
- package/scripts/README.md +9 -6
- 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 +32 -15
- package/scripts/linter-init.mjs +4 -2
- package/src/eslint/configs/config.common.js +4 -1
- package/src/eslint/configs/config.import.js +1 -1
- package/src/eslint/configs/config.prettier.js +1 -1
- package/src/eslint/configs/config.react.js +19 -26
- package/src/eslint/configs/config.solid.js +1 -1
- package/src/eslint/configs/config.sonarjs.js +1 -1
- package/src/eslint/configs/config.typescript.js +6 -0
- package/src/eslint/configs/config.unicorn.js +8 -19
- package/src/eslint/configs/import-plugin.js +48 -0
- package/src/eslint/configs/svelte-stack.js +5 -12
- 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.common.js +9 -1
- package/src/oxfmt/oxfmt.config.svelte.js +3 -0
- package/src/oxlint/configs/config.astro.js +134 -176
- package/src/oxlint/configs/config.common.js +107 -151
- package/src/oxlint/configs/config.next.js +365 -300
- package/src/oxlint/configs/config.react.js +365 -300
- package/src/oxlint/configs/config.solid.js +157 -223
- package/src/oxlint/configs/config.svelte.js +121 -190
- 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 +22 -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 and `import-x/order` in the six migrated presets are recorded as `formatter` instead of running competing JS rules. Import ordering is an intentional formatter-policy change, not identical source diagnostics. Svelte/Astro use `oxfmt-svelte`/`oxfmt-astro`, Angular uses `oxfmt-angular`, and other stacks use `oxfmt-common`. Every stack retains Stylelint. No Ox stack generates an ESLint companion; Vue/Nuxt/Svelte/Astro/Angular templates are not linted. Old `eslint-*-ox` exports remain available only for explicit opt-in use. 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": "10.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 only `oxlint.config.ts`, `oxfmt.config.ts` and `stylelint.config.js`. No Ox stack generates or installs an ESLint companion or template parser. Existing ESLint configs are preserved unless explicitly selected for removal. The wizard pins `oxlint@1.90.0`, `oxlint-tsgolint@7.0.2005` and `oxfmt@0.75.0` and installs only the selected script/formatter 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, with no ESLint command. This intentionally omits template/accessibility linting for Svelte/Astro/Angular/Vue/Nuxt. These configs do not run Prettier's JS rule. `oxfmt --write .` formats after lint fixes and sorts import declarations within comment partitions, adding empty lines between groups. Empty lines alone are not partitions. Bare side-effect imports retain their relative order but are not barriers themselves. Named-specifier sorting and the gap after imports remain lint rules; package.json sorting stays 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. Typed rules require an included tsconfig; nullish-coalescing analysis needs `strictNullChecks`. 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. The retained ESLint compatibility exports are optional and require explicit installation/setup, not part of the Ox workflow.
|
|
69
72
|
|
|
70
73
|
## Oxlint development checks
|
|
71
74
|
|
|
@@ -78,9 +81,9 @@ 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
|
```
|
|
85
88
|
|
|
86
|
-
The parity corpus asserts source and target diagnostics; guardrails reject missing mappings, option/severity drift, absent fixtures and unverified claims of complete SFC coverage. Inventory regeneration is deterministic and does not silently adopt new upstream rules: generated artifacts and fixtures must be reviewed together after dependency updates.
|
|
89
|
+
The parity corpus asserts source and target diagnostics; guardrails reject missing mappings, option/severity drift, absent fixtures and unverified claims of complete SFC coverage. Import ordering is separately tested as an intentional Oxfmt policy, not source-linter parity; formatter comparisons exclude this feature explicitly. Inventory regeneration is deterministic and does not silently adopt new upstream rules: generated artifacts and fixtures must be reviewed together after dependency updates.
|
|
@@ -4,13 +4,13 @@ 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 { OXFMT_STACKS, OX_FRAMEWORK_PACKAGES, oxStackToolVersions } from '../src/oxlint/stacks.js'
|
|
7
|
+
import { OXFMT_PRESETS, OXFMT_STACKS, OX_FRAMEWORK_PACKAGES, oxStackToolVersions } from '../src/oxlint/stacks.js'
|
|
8
8
|
|
|
9
9
|
export const PACKAGE = '@st1ggy/linter-config'
|
|
10
10
|
|
|
11
11
|
const BASE_STACK_KEYS = ['common', 'react', 'solid', 'next', 'svelte', 'astro']
|
|
12
12
|
|
|
13
|
-
export const STACK_KEYS = [...BASE_STACK_KEYS, ...
|
|
13
|
+
export const STACK_KEYS = [...BASE_STACK_KEYS, ...OXFMT_STACKS.map((key) => `${key}-ox`)]
|
|
14
14
|
|
|
15
15
|
export const STACKS = {
|
|
16
16
|
common: {
|
|
@@ -23,7 +23,7 @@ export const STACKS = {
|
|
|
23
23
|
eslint: 'eslint-react',
|
|
24
24
|
prettier: 'prettier-common',
|
|
25
25
|
stylelint: 'stylelint-scss',
|
|
26
|
-
packages: ['eslint-plugin
|
|
26
|
+
packages: ['@eslint-react/eslint-plugin', 'eslint-plugin-react-hooks'],
|
|
27
27
|
},
|
|
28
28
|
solid: {
|
|
29
29
|
eslint: 'eslint-solid',
|
|
@@ -35,7 +35,7 @@ export const STACKS = {
|
|
|
35
35
|
eslint: 'eslint-next',
|
|
36
36
|
prettier: 'prettier-common',
|
|
37
37
|
stylelint: 'stylelint-scss',
|
|
38
|
-
packages: ['@next/eslint-plugin-next', 'eslint-plugin
|
|
38
|
+
packages: ['@next/eslint-plugin-next', '@eslint-react/eslint-plugin', 'eslint-plugin-react-hooks'],
|
|
39
39
|
},
|
|
40
40
|
svelte: {
|
|
41
41
|
eslint: 'eslint-svelte',
|
|
@@ -47,7 +47,7 @@ export const STACKS = {
|
|
|
47
47
|
eslint: 'eslint-astro',
|
|
48
48
|
prettier: 'prettier-astro',
|
|
49
49
|
stylelint: 'stylelint-scss',
|
|
50
|
-
packages: ['eslint-plugin-astro', 'eslint-plugin-jsx-a11y', 'prettier-plugin-astro'],
|
|
50
|
+
packages: ['eslint-plugin-astro', 'eslint-plugin-jsx-a11y-x', 'prettier-plugin-astro'],
|
|
51
51
|
},
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -85,20 +85,20 @@ for (const key of BASE_STACK_KEYS) {
|
|
|
85
85
|
base.linterPreset = base.eslint
|
|
86
86
|
base.formatterFile = 'prettier.config.js'
|
|
87
87
|
base.formatterPreset = base.prettier
|
|
88
|
-
|
|
88
|
+
}
|
|
89
89
|
|
|
90
|
+
for (const key of OXFMT_STACKS) {
|
|
90
91
|
STACKS[`${key}-ox`] = {
|
|
91
92
|
linterFile: 'oxlint.config.ts',
|
|
92
93
|
linterPreset: `${key}-ox`,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
stylelint: base.stylelint,
|
|
94
|
+
formatterFile: 'oxfmt.config.ts',
|
|
95
|
+
formatterPreset: OXFMT_PRESETS[key] ?? 'oxfmt-common',
|
|
96
|
+
stylelint: 'stylelint-scss',
|
|
97
97
|
packages: [...Object.keys(oxStackToolVersions(key)), ...OX_FRAMEWORK_PACKAGES[key]],
|
|
98
98
|
}
|
|
99
99
|
STACK_CHOICES.push({
|
|
100
100
|
value: `${key}-ox`,
|
|
101
|
-
name: `${key}-ox — Oxlint +
|
|
101
|
+
name: `${key}-ox — Oxlint + Oxfmt`,
|
|
102
102
|
})
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -316,6 +316,18 @@ export function stackPackageSpecs(stackKey) {
|
|
|
316
316
|
return Object.fromEntries(Object.entries(versions).map(([name, version]) => [name, `${name}@${version}`]))
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
export function assertStackRuntime(directory, stackKey) {
|
|
320
|
+
if (stackKey !== 'svelte-ox') {
|
|
321
|
+
return
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const file = packageManifestPath(directory, 'svelte')
|
|
325
|
+
|
|
326
|
+
if (file && !JSON.parse(readFileSync(file, 'utf8')).version.startsWith('5.')) {
|
|
327
|
+
throw new Error('svelte-ox requires Svelte 5 for Oxfmt. Upgrade Svelte explicitly before selecting this stack.')
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
319
331
|
export function printHelp() {
|
|
320
332
|
process.stdout.write(`\
|
|
321
333
|
${PACKAGE} — generate local wrapper configs in a consumer project.
|
|
@@ -330,8 +342,8 @@ Commands:
|
|
|
330
342
|
|
|
331
343
|
Writes (each command):
|
|
332
344
|
ESLint stacks: eslint.config.js, prettier.config.js, stylelint.config.js.
|
|
333
|
-
|
|
334
|
-
|
|
345
|
+
All Ox stacks: oxlint.config.ts, oxfmt.config.ts, stylelint.config.js.
|
|
346
|
+
Ox stacks do not generate or run ESLint companions. Framework templates are not linted.
|
|
335
347
|
|
|
336
348
|
Unless --skip-install: if package.json exists, runs the detected package manager to add or sync
|
|
337
349
|
${PACKAGE} and the selected stack's integration plugins.
|
|
@@ -339,6 +351,7 @@ ${PACKAGE} and the selected stack's integration plugins.
|
|
|
339
351
|
Stack (at most one; default: common):
|
|
340
352
|
--common | --react | --solid | --next | --svelte | --astro
|
|
341
353
|
--common-ox | --react-ox | --solid-ox | --next-ox | --svelte-ox | --astro-ox
|
|
354
|
+
--angular-ox | --vue-ox | --nuxt-ox
|
|
342
355
|
|
|
343
356
|
Options:
|
|
344
357
|
--dir, -d Target directory (default: current working directory).
|
|
@@ -396,7 +409,9 @@ export function writeFile(targetDirectory, name, content, overwrite, options = {
|
|
|
396
409
|
export function wrapperFileNames(stackKey = 'common') {
|
|
397
410
|
stackPackages(stackKey)
|
|
398
411
|
|
|
399
|
-
|
|
412
|
+
const stack = STACKS[stackKey]
|
|
413
|
+
|
|
414
|
+
return [stack.linterFile, stack.formatterFile, 'stylelint.config.js']
|
|
400
415
|
}
|
|
401
416
|
|
|
402
417
|
export function existingWrapperFiles(targetDirectory, stackKey = 'common') {
|
|
@@ -455,9 +470,11 @@ export function run(mode, targetDirectory, stackKey, options = {}) {
|
|
|
455
470
|
throw new Error(`Unknown stack "${stackKey}". Use: ${STACK_KEYS.join(', ')}`)
|
|
456
471
|
}
|
|
457
472
|
|
|
473
|
+
assertStackRuntime(targetDirectory, stackKey)
|
|
474
|
+
|
|
458
475
|
const shouldOverwrite = mode === 'migrate' || mode === 'reinit'
|
|
459
476
|
|
|
460
|
-
const hasSemicolon =
|
|
477
|
+
const hasSemicolon = !stackKey.endsWith('-ox')
|
|
461
478
|
|
|
462
479
|
writeFile(targetDirectory, stack.linterFile, jsReExport(stack.linterPreset, hasSemicolon), shouldOverwrite, { quiet })
|
|
463
480
|
writeFile(targetDirectory, stack.formatterFile, jsReExport(stack.formatterPreset, hasSemicolon), shouldOverwrite, {
|
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
|
|
|
@@ -17,7 +17,10 @@ export default defineConfig([
|
|
|
17
17
|
'prefer-template': 'error',
|
|
18
18
|
'arrow-body-style': ['error', 'as-needed'],
|
|
19
19
|
'no-return-assign': 'off',
|
|
20
|
-
'newline-before-return':
|
|
20
|
+
'newline-before-return': 'off',
|
|
21
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
22
|
+
'no-else-return': ['warn', { allowElseIf: false }],
|
|
23
|
+
'max-depth': ['warn', 4],
|
|
21
24
|
radix: 'off',
|
|
22
25
|
camelcase: [
|
|
23
26
|
'error',
|
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import reactPlugin from 'eslint-plugin-react'
|
|
1
|
+
import reactPlugin from '@eslint-react/eslint-plugin'
|
|
3
2
|
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
3
|
+
import { defineConfig } from 'eslint/config'
|
|
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' }],
|
|
@@ -50,7 +43,7 @@ export default defineConfig([
|
|
|
50
43
|
'@stylistic/jsx-equals-spacing': ['error', 'never'],
|
|
51
44
|
'@stylistic/jsx-first-prop-new-line': ['error', 'multiline'],
|
|
52
45
|
'@stylistic/jsx-max-props-per-line': ['error', { when: 'multiline' }],
|
|
53
|
-
'@stylistic/jsx-props-no-multi-spaces': '
|
|
46
|
+
'@stylistic/jsx-props-no-multi-spaces': 'off',
|
|
54
47
|
'@stylistic/jsx-tag-spacing': 'error',
|
|
55
48
|
},
|
|
56
49
|
},
|
|
@@ -40,6 +40,12 @@ export default defineConfig([
|
|
|
40
40
|
},
|
|
41
41
|
],
|
|
42
42
|
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
43
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
44
|
+
'@typescript-eslint/no-misused-promises': 'error',
|
|
45
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
46
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
|
|
47
|
+
'@typescript-eslint/no-unnecessary-type-parameters': 'warn',
|
|
48
|
+
'@typescript-eslint/prefer-nullish-coalescing': ['warn', { ignorePrimitives: true }],
|
|
43
49
|
'@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
|
|
44
50
|
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
|
|
45
51
|
},
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
import { defineConfig } from 'eslint/config'
|
|
2
1
|
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
2
|
+
import { defineConfig } from 'eslint/config'
|
|
3
3
|
|
|
4
4
|
import { files } from './constants.js'
|
|
5
5
|
|
|
6
6
|
export default defineConfig([
|
|
7
7
|
unicornPlugin.configs.recommended,
|
|
8
|
+
{
|
|
9
|
+
rules: {
|
|
10
|
+
'unicorn/consistent-destructuring': 'off',
|
|
11
|
+
'unicorn/no-unused-properties': 'off',
|
|
12
|
+
'unicorn/name-replacements': 'off',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
8
15
|
{
|
|
9
16
|
files,
|
|
10
17
|
rules: {
|
|
11
|
-
'unicorn/consistent-destructuring': 'error',
|
|
12
18
|
'unicorn/custom-error-definition': 'error',
|
|
13
|
-
'unicorn/no-unused-properties': 'error',
|
|
14
19
|
'unicorn/no-null': 'off',
|
|
15
|
-
'unicorn/name-replacements': [
|
|
16
|
-
'error',
|
|
17
|
-
{
|
|
18
|
-
replacements: {
|
|
19
|
-
dev: false,
|
|
20
|
-
prod: false,
|
|
21
|
-
props: false,
|
|
22
|
-
ref: false,
|
|
23
|
-
refs: false,
|
|
24
|
-
args: false,
|
|
25
|
-
params: false,
|
|
26
|
-
utils: false,
|
|
27
|
-
env: false,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
20
|
},
|
|
32
21
|
},
|
|
33
22
|
])
|