@zayne-labs/eslint-config 0.11.5 → 0.11.6
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 +204 -189
- package/dist/cli/index.js +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +888 -475
- package/dist/index.js +150 -44
- package/dist/index.js.map +1 -1
- package/dist/src-BncWNtPe.js +671 -0
- package/dist/src-BncWNtPe.js.map +1 -0
- package/package.json +35 -34
- package/dist/src-Cr2NVJeY.js +0 -1852
- package/dist/src-Cr2NVJeY.js.map +0 -1
package/README.md
CHANGED
|
@@ -38,9 +38,9 @@ pnpm add -D eslint @zayne-labs/eslint-config
|
|
|
38
38
|
Create `eslint.config.js` in your project root:
|
|
39
39
|
|
|
40
40
|
```js
|
|
41
|
-
import { zayne } from
|
|
41
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
42
42
|
|
|
43
|
-
export default zayne()
|
|
43
|
+
export default zayne();
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Done! Check out [customization](#customization) for more options.
|
|
@@ -51,23 +51,23 @@ Done! Check out [customization](#customization) for more options.
|
|
|
51
51
|
If you have existing eslintrc configs, use [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) to convert them:
|
|
52
52
|
|
|
53
53
|
```js
|
|
54
|
-
import { zayne } from
|
|
55
|
-
import { FlatCompat } from
|
|
54
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
55
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
56
56
|
|
|
57
|
-
const compat = new FlatCompat()
|
|
57
|
+
const compat = new FlatCompat();
|
|
58
58
|
|
|
59
59
|
export default zayne(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
60
|
+
{
|
|
61
|
+
ignores: [],
|
|
62
|
+
},
|
|
63
|
+
...compat.config({
|
|
64
|
+
extends: [
|
|
65
|
+
"eslint:recommended",
|
|
66
|
+
// Other extends...
|
|
67
|
+
],
|
|
68
|
+
})
|
|
69
|
+
// Other flat configs...
|
|
70
|
+
);
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
Note: `.eslintignore` no longer works in flat config. Use the `ignores` option instead (see [customization](#customization)).
|
|
@@ -80,10 +80,10 @@ Add these scripts to your `package.json`:
|
|
|
80
80
|
|
|
81
81
|
```json
|
|
82
82
|
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
"scripts": {
|
|
84
|
+
"lint:eslint": "eslint .",
|
|
85
|
+
"lint:eslint-fix": "eslint . --fix"
|
|
86
|
+
}
|
|
87
87
|
}
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -96,38 +96,38 @@ Configure your editor to auto-fix ESLint issues on save:
|
|
|
96
96
|
|
|
97
97
|
Install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and add to `.vscode/settings.json`:
|
|
98
98
|
|
|
99
|
-
```
|
|
99
|
+
```json
|
|
100
100
|
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
101
|
+
// Auto fix
|
|
102
|
+
"editor.codeActionsOnSave": {
|
|
103
|
+
"source.fixAll.eslint": "explicit",
|
|
104
|
+
"source.organizeImports": "never"
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// Enable eslint for all supported languages
|
|
108
|
+
"eslint.validate": [
|
|
109
|
+
"javascript",
|
|
110
|
+
"javascriptreact",
|
|
111
|
+
"typescript",
|
|
112
|
+
"typescriptreact",
|
|
113
|
+
"vue",
|
|
114
|
+
"html",
|
|
115
|
+
"markdown",
|
|
116
|
+
"json",
|
|
117
|
+
"jsonc",
|
|
118
|
+
"yaml",
|
|
119
|
+
"toml",
|
|
120
|
+
"xml",
|
|
121
|
+
"gql",
|
|
122
|
+
"graphql",
|
|
123
|
+
"astro",
|
|
124
|
+
"svelte",
|
|
125
|
+
"css",
|
|
126
|
+
"less",
|
|
127
|
+
"scss",
|
|
128
|
+
"pcss",
|
|
129
|
+
"postcss"
|
|
130
|
+
]
|
|
131
131
|
}
|
|
132
132
|
```
|
|
133
133
|
|
|
@@ -176,16 +176,16 @@ lspconfig.eslint.setup(
|
|
|
176
176
|
|
|
177
177
|
- Use the built-in `EslintFixAll` command with an autocmd:
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
```lua
|
|
180
|
+
lspconfig.eslint.setup({
|
|
181
|
+
on_attach = function(client, bufnr)
|
|
182
|
+
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
183
|
+
buffer = bufnr,
|
|
184
|
+
command = "EslintFixAll",
|
|
185
|
+
})
|
|
186
|
+
end,
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
189
|
|
|
190
190
|
- Or use [conform.nvim](https://github.com/stevearc/conform.nvim), [none-ls](https://github.com/nvimtools/none-ls.nvim), or [nvim-lint](https://github.com/mfussenegger/nvim-lint)
|
|
191
191
|
|
|
@@ -196,32 +196,44 @@ lspconfig.eslint.setup(
|
|
|
196
196
|
This config works out of the box with zero configuration. Customize it when needed:
|
|
197
197
|
|
|
198
198
|
```js
|
|
199
|
-
import { zayne } from
|
|
199
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
200
200
|
|
|
201
201
|
export default zayne({
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
|
|
203
|
+
// The `ignores` option in the option (first argument) is specifically treated to always be global ignores
|
|
204
|
+
// And will **extend** the config's default ignores, not override them
|
|
205
|
+
// You can also pass a function to modify the default ignores
|
|
206
|
+
ignores: [
|
|
207
|
+
"**/fixtures",
|
|
208
|
+
// ...globs
|
|
209
|
+
],
|
|
204
210
|
|
|
205
|
-
|
|
206
|
-
|
|
211
|
+
// Parse the `.gitignore` file to get the ignores, on by default
|
|
212
|
+
gitignore: true,
|
|
207
213
|
|
|
208
|
-
|
|
209
|
-
|
|
214
|
+
// Project type: 'app' (default) or 'lib'
|
|
215
|
+
type: "app",
|
|
210
216
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
react: true,
|
|
217
|
+
// Disable all optional configs at once (keeps only essentials)
|
|
218
|
+
withDefaults: false,
|
|
214
219
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
yaml: false,
|
|
220
|
+
// Enable stylistic formatting rules
|
|
221
|
+
stylistic: true,
|
|
218
222
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
// Or customize the stylistic rules
|
|
224
|
+
stylistic: {
|
|
225
|
+
jsx: true,
|
|
226
|
+
quotes: "single", // or 'double'
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
// TypeScript and React are auto-detected, but can be explicit
|
|
230
|
+
typescript: true,
|
|
231
|
+
react: true,
|
|
232
|
+
|
|
233
|
+
// Disable specific language support
|
|
234
|
+
jsonc: false,
|
|
235
|
+
yaml: false,
|
|
236
|
+
});
|
|
225
237
|
```
|
|
226
238
|
|
|
227
239
|
### Custom Rules
|
|
@@ -229,25 +241,27 @@ export default zayne({
|
|
|
229
241
|
Pass additional configs as extra arguments:
|
|
230
242
|
|
|
231
243
|
```ts
|
|
232
|
-
import { zayne } from
|
|
244
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
233
245
|
|
|
234
246
|
export default zayne(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
{
|
|
248
|
+
// Configures for zayne's config
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// From the second arguments they are ESLint Flat Configs
|
|
252
|
+
// you can have multiple configs
|
|
253
|
+
{
|
|
254
|
+
files: ["**/*.ts"],
|
|
255
|
+
rules: {
|
|
256
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
rules: {
|
|
261
|
+
"no-console": "warn",
|
|
262
|
+
},
|
|
263
|
+
}
|
|
264
|
+
);
|
|
251
265
|
```
|
|
252
266
|
|
|
253
267
|
### Advanced Composition
|
|
@@ -261,61 +275,62 @@ Import and compose fine-grained configs directly:
|
|
|
261
275
|
|
|
262
276
|
```js
|
|
263
277
|
import {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
} from
|
|
291
|
-
import { FlatConfigComposer } from
|
|
292
|
-
|
|
293
|
-
export default new FlatConfigComposer()
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
)
|
|
278
|
+
astro,
|
|
279
|
+
comments,
|
|
280
|
+
depend,
|
|
281
|
+
expo,
|
|
282
|
+
ignores,
|
|
283
|
+
imports,
|
|
284
|
+
javascript,
|
|
285
|
+
jsdoc,
|
|
286
|
+
jsonc,
|
|
287
|
+
jsx,
|
|
288
|
+
markdown,
|
|
289
|
+
node,
|
|
290
|
+
perfectionist,
|
|
291
|
+
pnpm,
|
|
292
|
+
react,
|
|
293
|
+
solid,
|
|
294
|
+
sortPackageJson,
|
|
295
|
+
sortTsconfig,
|
|
296
|
+
stylistic,
|
|
297
|
+
tailwindcssBetter,
|
|
298
|
+
tanstack,
|
|
299
|
+
toml,
|
|
300
|
+
typescript,
|
|
301
|
+
unicorn,
|
|
302
|
+
vue,
|
|
303
|
+
yaml,
|
|
304
|
+
} from "@zayne-labs/eslint-config";
|
|
305
|
+
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
306
|
+
|
|
307
|
+
export default new FlatConfigComposer().append(
|
|
308
|
+
ignores(),
|
|
309
|
+
javascript(),
|
|
310
|
+
typescript(),
|
|
311
|
+
jsx(),
|
|
312
|
+
comments(),
|
|
313
|
+
node(),
|
|
314
|
+
jsdoc(),
|
|
315
|
+
imports(),
|
|
316
|
+
unicorn(),
|
|
317
|
+
perfectionist(),
|
|
318
|
+
stylistic(),
|
|
319
|
+
react(),
|
|
320
|
+
vue(),
|
|
321
|
+
jsonc(),
|
|
322
|
+
yaml(),
|
|
323
|
+
toml(),
|
|
324
|
+
markdown()
|
|
325
|
+
);
|
|
313
326
|
```
|
|
314
327
|
|
|
315
328
|
</details>
|
|
316
329
|
|
|
317
330
|
See [configs](https://github.com/zayne-labs/eslint-config/blob/main/src/configs) and [factory](https://github.com/zayne-labs/eslint-config/blob/main/src/factory.ts) for implementation details.
|
|
318
331
|
|
|
332
|
+
> Thanks to [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and reference.
|
|
333
|
+
|
|
319
334
|
## Framework & Integration Support
|
|
320
335
|
|
|
321
336
|
Enable framework-specific linting rules and integrations:
|
|
@@ -323,11 +338,11 @@ Enable framework-specific linting rules and integrations:
|
|
|
323
338
|
### Vue
|
|
324
339
|
|
|
325
340
|
```js
|
|
326
|
-
import { zayne } from
|
|
341
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
327
342
|
|
|
328
343
|
export default zayne({
|
|
329
|
-
|
|
330
|
-
})
|
|
344
|
+
vue: true,
|
|
345
|
+
});
|
|
331
346
|
```
|
|
332
347
|
|
|
333
348
|
Install peer dependencies:
|
|
@@ -341,11 +356,11 @@ pnpm i -D eslint-plugin-vue vue-eslint-parser
|
|
|
341
356
|
Auto-detected in most cases, or enable explicitly:
|
|
342
357
|
|
|
343
358
|
```js
|
|
344
|
-
import { zayne } from
|
|
359
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
345
360
|
|
|
346
361
|
export default zayne({
|
|
347
|
-
|
|
348
|
-
})
|
|
362
|
+
react: true,
|
|
363
|
+
});
|
|
349
364
|
```
|
|
350
365
|
|
|
351
366
|
Install peer dependencies (prompted automatically when running ESLint):
|
|
@@ -357,11 +372,11 @@ pnpm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-re
|
|
|
357
372
|
### Svelte
|
|
358
373
|
|
|
359
374
|
```js
|
|
360
|
-
import { zayne } from
|
|
375
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
361
376
|
|
|
362
377
|
export default zayne({
|
|
363
|
-
|
|
364
|
-
})
|
|
378
|
+
svelte: true,
|
|
379
|
+
});
|
|
365
380
|
```
|
|
366
381
|
|
|
367
382
|
Install peer dependencies:
|
|
@@ -373,11 +388,11 @@ pnpm i -D eslint-plugin-svelte
|
|
|
373
388
|
### Astro
|
|
374
389
|
|
|
375
390
|
```js
|
|
376
|
-
import { zayne } from
|
|
391
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
377
392
|
|
|
378
393
|
export default zayne({
|
|
379
|
-
|
|
380
|
-
})
|
|
394
|
+
astro: true,
|
|
395
|
+
});
|
|
381
396
|
```
|
|
382
397
|
|
|
383
398
|
Install peer dependencies:
|
|
@@ -389,11 +404,11 @@ pnpm i -D eslint-plugin-astro
|
|
|
389
404
|
### Solid
|
|
390
405
|
|
|
391
406
|
```js
|
|
392
|
-
import { zayne } from
|
|
407
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
393
408
|
|
|
394
409
|
export default zayne({
|
|
395
|
-
|
|
396
|
-
})
|
|
410
|
+
solid: true,
|
|
411
|
+
});
|
|
397
412
|
```
|
|
398
413
|
|
|
399
414
|
Install peer dependencies:
|
|
@@ -407,11 +422,11 @@ pnpm i -D eslint-plugin-solid
|
|
|
407
422
|
Uses the enhanced `eslint-plugin-better-tailwindcss` for improved class sorting and validation:
|
|
408
423
|
|
|
409
424
|
```js
|
|
410
|
-
import { zayne } from
|
|
425
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
411
426
|
|
|
412
427
|
export default zayne({
|
|
413
|
-
|
|
414
|
-
})
|
|
428
|
+
tailwindcssBetter: true,
|
|
429
|
+
});
|
|
415
430
|
```
|
|
416
431
|
|
|
417
432
|
Install peer dependencies:
|
|
@@ -423,11 +438,11 @@ pnpm i -D eslint-plugin-better-tailwindcss
|
|
|
423
438
|
### Expo (React Native)
|
|
424
439
|
|
|
425
440
|
```js
|
|
426
|
-
import { zayne } from
|
|
441
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
427
442
|
|
|
428
443
|
export default zayne({
|
|
429
|
-
|
|
430
|
-
})
|
|
444
|
+
expo: true,
|
|
445
|
+
});
|
|
431
446
|
```
|
|
432
447
|
|
|
433
448
|
Install peer dependencies:
|
|
@@ -441,14 +456,14 @@ pnpm i -D eslint-config-expo
|
|
|
441
456
|
Support for TanStack Query and Router:
|
|
442
457
|
|
|
443
458
|
```js
|
|
444
|
-
import { zayne } from
|
|
459
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
445
460
|
|
|
446
461
|
export default zayne({
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
})
|
|
462
|
+
tanstack: {
|
|
463
|
+
query: true,
|
|
464
|
+
router: true,
|
|
465
|
+
},
|
|
466
|
+
});
|
|
452
467
|
```
|
|
453
468
|
|
|
454
469
|
Install peer dependencies:
|
|
@@ -462,11 +477,11 @@ pnpm i -D @tanstack/eslint-plugin-query @tanstack/eslint-plugin-router
|
|
|
462
477
|
Lint PNPM catalog protocol usage:
|
|
463
478
|
|
|
464
479
|
```js
|
|
465
|
-
import { zayne } from
|
|
480
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
466
481
|
|
|
467
482
|
export default zayne({
|
|
468
|
-
|
|
469
|
-
})
|
|
483
|
+
pnpm: true,
|
|
484
|
+
});
|
|
470
485
|
```
|
|
471
486
|
|
|
472
487
|
Install peer dependencies:
|
|
@@ -480,11 +495,11 @@ pnpm i -D eslint-plugin-pnpm
|
|
|
480
495
|
Enforce dependency rules with `eslint-plugin-depend`:
|
|
481
496
|
|
|
482
497
|
```js
|
|
483
|
-
import { zayne } from
|
|
498
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
484
499
|
|
|
485
500
|
export default zayne({
|
|
486
|
-
|
|
487
|
-
})
|
|
501
|
+
depend: true,
|
|
502
|
+
});
|
|
488
503
|
```
|
|
489
504
|
|
|
490
505
|
Install peer dependencies:
|
|
@@ -505,25 +520,25 @@ Only specify `tsconfigPath` when you need to:
|
|
|
505
520
|
Single custom tsconfig location:
|
|
506
521
|
|
|
507
522
|
```js
|
|
508
|
-
import { zayne } from
|
|
523
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
509
524
|
|
|
510
525
|
export default zayne({
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
})
|
|
526
|
+
typescript: {
|
|
527
|
+
tsconfigPath: "./config/tsconfig.json",
|
|
528
|
+
},
|
|
529
|
+
});
|
|
515
530
|
```
|
|
516
531
|
|
|
517
532
|
Multiple tsconfigs:
|
|
518
533
|
|
|
519
534
|
```js
|
|
520
|
-
import { zayne } from
|
|
535
|
+
import { zayne } from "@zayne-labs/eslint-config";
|
|
521
536
|
|
|
522
537
|
export default zayne({
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
})
|
|
538
|
+
typescript: {
|
|
539
|
+
tsconfigPath: ["./tsconfig.json", "./tsconfig.node.json"],
|
|
540
|
+
},
|
|
541
|
+
});
|
|
527
542
|
```
|
|
528
543
|
|
|
529
544
|
## Inspecting Config
|
package/dist/cli/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { defineEnum, defineEnumDeep } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
import process from "node:process";
|
|
3
|
+
import fsp from "node:fs/promises";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
3
6
|
import * as p from "@clack/prompts";
|
|
4
7
|
import c, { green } from "ansis";
|
|
5
8
|
import { cac } from "cac";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import fsp from "node:fs/promises";
|
|
9
9
|
import parse from "parse-gitignore";
|
|
10
10
|
import { execSync } from "node:child_process";
|
|
11
11
|
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "0.11.
|
|
13
|
+
var version = "0.11.6";
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/cli/constants.ts
|