@zayne-labs/eslint-config 0.10.9 → 0.11.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 CHANGED
@@ -1,50 +1,56 @@
1
1
  # @zayne-labs/eslint-config
2
2
 
3
- - Reasonable defaults, best practices, only one line of config
4
- - Designed to work with TypeScript, JSX, Vue, JSON, YAML, Toml, Markdown, etc. Out-of-box.
5
- - Opinionated, but [very customizable](#customization)
6
- - [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
7
- - Optional [React](#react), [Svelte](#svelte), [TailwindCSS](#tailwindcss), [Astro](#astro), [Solid](#solid) support
3
+ Opinionated ESLint config with sensible defaults and zero-config setup.
4
+
5
+ - One-line setup with reasonable defaults and best practices
6
+ - Works out-of-the-box with TypeScript, JSX, Vue, JSON, YAML, TOML, Markdown, and more
7
+ - [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) for easy composition
8
+ - Optional framework support: [Vue](#vue), [React](#react), [Svelte](#svelte), [Astro](#astro), [Solid](#solid)
8
9
  - Respects `.gitignore` by default
9
- - Requires ESLint v9.5.0+
10
- - Inspired by the legendary open sourcerer, [antfu](https://github.com/antfu/eslint-config)
10
+ - Highly [customizable](#customization) when you need it
11
+ - Requires ESLint v9.5.0+ and Node.js v20+
12
+ - Interactive CLI for easy setup
11
13
 
12
- ## Usage
14
+ Inspired by [antfu/eslint-config](https://github.com/antfu/eslint-config)
13
15
 
14
- Hey there! 👋 Let's get you started with this ESLint config. Here's how to set it up:
16
+ ## Usage
15
17
 
16
- ### Installation
18
+ ### Quick Setup (Recommended)
17
19
 
18
- Just run one of these commands in your project:
20
+ Use the interactive CLI to set up your config:
19
21
 
20
22
  ```bash
21
- pnpm add -D eslint @zayne-labs/eslint-config
23
+ pnpx @zayne-labs/eslint-config@latest
24
+ ```
25
+
26
+ The CLI will guide you through:
27
+
28
+ - Framework selection (React, Vue, Svelte, Astro)
29
+ - Additional integrations (TailwindCSS, etc.)
30
+ - Automatic dependency installation
22
31
 
23
- # Using npm
24
- npm install -D eslint @zayne-labs/eslint-config
32
+ ### Manual Installation
25
33
 
26
- # Using yarn
27
- yarn add -D eslint @zayne-labs/eslint-config
34
+ ```bash
35
+ pnpm add -D eslint @zayne-labs/eslint-config
28
36
  ```
29
37
 
30
- Then create an `eslint.config.js` in your project root:
38
+ Create `eslint.config.js` in your project root:
31
39
 
32
40
  ```js
33
- // eslint.config.js
34
41
  import { zayne } from '@zayne-labs/eslint-config'
35
42
 
36
43
  export default zayne()
37
44
  ```
38
45
 
39
- That's it! You're ready to go. Want to do more? Check out the customization options below.
46
+ Done! Check out [customization](#customization) for more options.
40
47
 
41
48
  <details>
42
- <summary>Combined with legacy config:</summary>
49
+ <summary>Combining with legacy config</summary>
43
50
 
44
- If you still use some configs from the legacy eslintrc format, you can use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
51
+ If you have existing eslintrc configs, use [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) to convert them:
45
52
 
46
53
  ```js
47
- // eslint.config.mjs
48
54
  import { zayne } from '@zayne-labs/eslint-config'
49
55
  import { FlatCompat } from '@eslint/eslintrc'
50
56
 
@@ -54,26 +60,23 @@ export default zayne(
54
60
  {
55
61
  ignores: [],
56
62
  },
57
-
58
- // Legacy config
59
- ...compat.config({
60
- extends: [
61
- 'eslint:recommended',
62
- // Other extends...
63
- ],
64
- }),
65
-
66
- // Other flat configs...
63
+ ...compat.config({
64
+ extends: [
65
+ 'eslint:recommended',
66
+ // Other extends...
67
+ ],
68
+ }),
69
+ // Other flat configs...
67
70
  )
68
71
  ```
69
72
 
70
- > Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
73
+ Note: `.eslintignore` no longer works in flat config. Use the `ignores` option instead (see [customization](#customization)).
71
74
 
72
75
  </details>
73
76
 
74
- ### Add script for package.json
77
+ ### Package Scripts
75
78
 
76
- Add these handy scripts to your `package.json`:
79
+ Add these scripts to your `package.json`:
77
80
 
78
81
  ```json
79
82
  {
@@ -84,18 +87,14 @@ Add these handy scripts to your `package.json`:
84
87
  }
85
88
  ```
86
89
 
87
- ## IDE Support (auto fix on save)
90
+ ## IDE Support
88
91
 
89
- Let's set up your editor to automatically fix ESLint issues when you save. Here's how:
92
+ Configure your editor to auto-fix ESLint issues on save:
90
93
 
91
94
  <details>
92
- <summary>🟦 VS Code support</summary>
95
+ <summary>VS Code</summary>
93
96
 
94
- <br>
95
-
96
- Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
97
-
98
- Add the following settings to your `.vscode/settings.json`:
97
+ Install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and add to `.vscode/settings.json`:
99
98
 
100
99
  ```jsonc
101
100
  {
@@ -135,11 +134,9 @@ Add the following settings to your `.vscode/settings.json`:
135
134
  </details>
136
135
 
137
136
  <details>
138
- <summary>🟩 Neovim Support</summary>
139
-
140
- <br>
137
+ <summary>Neovim</summary>
141
138
 
142
- Update your configuration to use the following:
139
+ Update your configuration:
143
140
 
144
141
  ```lua
145
142
  local lspconfig = require('lspconfig')
@@ -175,147 +172,175 @@ lspconfig.eslint.setup(
175
172
  )
176
173
  ```
177
174
 
178
- ### Neovim format on save
175
+ **Format on save options:**
179
176
 
180
- There's few ways you can achieve format on save in neovim:
177
+ - Use the built-in `EslintFixAll` command with an autocmd:
181
178
 
182
- - `nvim-lspconfig` has a `EslintFixAll` command predefined, you can create a autocmd to call this command after saving file.
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
+ ```
183
189
 
184
- ```lua
185
- lspconfig.eslint.setup({
186
- --- ...
187
- on_attach = function(client, bufnr)
188
- vim.api.nvim_create_autocmd("BufWritePre", {
189
- buffer = bufnr,
190
- command = "EslintFixAll",
191
- })
192
- end,
193
- })
194
- ```
195
-
196
- - Use [conform.nvim](https://github.com/stevearc/conform.nvim)
197
- - Use [none-ls](https://github.com/nvimtools/none-ls.nvim)
198
- - Use [nvim-lint](https://github.com/mfussenegger/nvim-lint)
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)
199
191
 
200
192
  </details>
201
193
 
202
194
  ## Customization
203
195
 
204
- The great thing about this config is that it works out of the box with zero config. But if you want to tweak things (and who doesn't?), here's how:
196
+ This config works out of the box with zero configuration. Customize it when needed:
205
197
 
206
198
  ```js
207
- // eslint.config.js
208
199
  import { zayne } from '@zayne-labs/eslint-config'
209
200
 
210
201
  export default zayne({
202
+ // Project type: 'app' (default) or 'lib'
203
+ type: 'app',
204
+
205
+ // Disable all optional configs at once (keeps only essentials)
206
+ withDefaults: false,
207
+
211
208
  // Enable stylistic formatting rules
212
209
  stylistic: true,
213
210
 
214
- // TypeScript and React are auto-detected, but you can be explicit:
211
+ // TypeScript and React are auto-detected, but can be explicit
215
212
  typescript: true,
216
213
  react: true,
217
214
 
218
- // Don't need JSON or YAML? Turn them off:
215
+ // Disable specific language support
219
216
  jsonc: false,
220
217
  yaml: false,
221
218
 
222
- // Since `.eslintignore` isn't supported in Flat config, use `ignores`:
219
+ // Custom ignores (replaces .eslintignore)
223
220
  ignores: [
224
221
  'build/**',
225
- // ...globs
222
+ 'dist/**',
226
223
  ]
227
224
  })
228
225
  ```
229
226
 
230
- Need more control? The `zayne` function takes a second argument for custom overrides:
227
+ ### Custom Rules
228
+
229
+ Pass additional configs as extra arguments:
231
230
 
232
231
  ```js
233
- // eslint.config.js
234
232
  import { zayne } from '@zayne-labs/eslint-config'
235
233
 
236
234
  export default zayne(
237
235
  {
238
- // Your base config
236
+ // Base config
239
237
  },
240
-
241
- // Custom ESLint configs
242
- {
243
- files: ['**/*.ts'],
244
- rules: {
245
- '@typescript-eslint/no-explicit-any': 'off',
246
- },
238
+ // Custom overrides
239
+ {
240
+ files: ['**/*.ts'],
241
+ rules: {
242
+ '@typescript-eslint/no-explicit-any': 'off',
247
243
  },
248
- {
249
- rules: {
250
- 'no-console': 'warn',
251
- },
252
- },
244
+ },
245
+ {
246
+ rules: {
247
+ 'no-console': 'warn',
248
+ },
249
+ },
253
250
  )
254
251
  ```
255
252
 
256
- Going more advanced, you can also import fine-grained configs and compose them as you wish:
253
+ ### Advanced Composition
254
+
255
+ Import and compose fine-grained configs directly:
257
256
 
258
257
  <details>
259
- <summary>Advanced Example</summary>
258
+ <summary>Show example</summary>
260
259
 
261
- We wouldn't recommend using this style in general unless you know exactly what they are doing, as there are shared options between configs and might need extra care to make them consistent.
260
+ **Note**: This low-level approach is for advanced use cases only. The `zayne()` factory handles option coordination automatically, so use this only if you need granular control over config composition. Not necessarily recommended
262
261
 
263
262
  ```js
264
- // eslint.config.js
265
263
  import {
266
- combine,
264
+ astro,
267
265
  comments,
266
+ depend,
267
+ expo,
268
268
  ignores,
269
269
  imports,
270
270
  javascript,
271
271
  jsdoc,
272
272
  jsonc,
273
+ jsx,
273
274
  markdown,
274
275
  node,
276
+ perfectionist,
277
+ pnpm,
278
+ react,
279
+ solid,
275
280
  sortPackageJson,
276
281
  sortTsconfig,
277
282
  stylistic,
283
+ tailwindcssBetter,
284
+ tanstack,
278
285
  toml,
279
286
  typescript,
280
287
  unicorn,
281
288
  vue,
282
289
  yaml,
283
290
  } from '@zayne-labs/eslint-config'
284
-
285
- export default combine(
286
- ignores(),
287
- javascript(/* Options */),
288
- comments(),
289
- node(),
290
- jsdoc(),
291
- imports(),
292
- unicorn(),
293
- typescript(/* Options */),
294
- stylistic(),
295
- vue(),
296
- jsonc(),
297
- yaml(),
298
- toml(),
299
- markdown(),
300
- )
291
+ import { FlatConfigComposer } from 'eslint-flat-config-utils'
292
+
293
+ export default new FlatConfigComposer()
294
+ .append(
295
+ ignores(),
296
+ javascript(),
297
+ typescript(),
298
+ jsx(),
299
+ comments(),
300
+ node(),
301
+ jsdoc(),
302
+ imports(),
303
+ unicorn(),
304
+ perfectionist(),
305
+ stylistic(),
306
+ react(),
307
+ vue(),
308
+ jsonc(),
309
+ yaml(),
310
+ toml(),
311
+ markdown(),
312
+ )
301
313
  ```
302
314
 
303
315
  </details>
304
316
 
305
- Check out the [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 more details.
317
+ 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
+
319
+ ## Framework & Integration Support
320
+
321
+ Enable framework-specific linting rules and integrations:
322
+
323
+ ### Vue
324
+
325
+ ```js
326
+ import { zayne } from '@zayne-labs/eslint-config'
306
327
 
307
- > Thanks to [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and reference.
328
+ export default zayne({
329
+ vue: true,
330
+ })
331
+ ```
308
332
 
309
- ### Framework Support
333
+ Install peer dependencies:
310
334
 
311
- Need to lint your favorite framework? We've got you covered! Here's how to enable support for various frameworks:
335
+ ```bash
336
+ pnpm i -D eslint-plugin-vue vue-eslint-parser
337
+ ```
312
338
 
313
- #### React
339
+ ### React
314
340
 
315
- React support is usually auto-detected, but you can explicitly enable it:
341
+ Auto-detected in most cases, or enable explicitly:
316
342
 
317
343
  ```js
318
- // eslint.config.js
319
344
  import { zayne } from '@zayne-labs/eslint-config'
320
345
 
321
346
  export default zayne({
@@ -323,18 +348,15 @@ export default zayne({
323
348
  })
324
349
  ```
325
350
 
326
- When you run `pnpm eslint`, it'll let you know if you need to install any dependencies. But if you prefer to install them manually:
351
+ Install peer dependencies (prompted automatically when running ESLint):
327
352
 
328
353
  ```bash
329
354
  pnpm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
330
355
  ```
331
356
 
332
- #### Svelte
333
-
334
- To enable svelte support, you need to explicitly turn it on:
357
+ ### Svelte
335
358
 
336
359
  ```js
337
- // eslint.config.js
338
360
  import { zayne } from '@zayne-labs/eslint-config'
339
361
 
340
362
  export default zayne({
@@ -342,18 +364,15 @@ export default zayne({
342
364
  })
343
365
  ```
344
366
 
345
- Running `pnpm eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
367
+ Install peer dependencies:
346
368
 
347
369
  ```bash
348
370
  pnpm i -D eslint-plugin-svelte
349
371
  ```
350
372
 
351
- #### Astro
352
-
353
- To enable astro support, you need to explicitly turn it on:
373
+ ### Astro
354
374
 
355
375
  ```js
356
- // eslint.config.js
357
376
  import { zayne } from '@zayne-labs/eslint-config'
358
377
 
359
378
  export default zayne({
@@ -361,18 +380,15 @@ export default zayne({
361
380
  })
362
381
  ```
363
382
 
364
- Running `pnpm eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
383
+ Install peer dependencies:
365
384
 
366
385
  ```bash
367
386
  pnpm i -D eslint-plugin-astro
368
387
  ```
369
388
 
370
- #### Solid
371
-
372
- To enable Solid support, you need to explicitly turn it on:
389
+ ### Solid
373
390
 
374
391
  ```js
375
- // eslint.config.js
376
392
  import { zayne } from '@zayne-labs/eslint-config'
377
393
 
378
394
  export default zayne({
@@ -380,85 +396,175 @@ export default zayne({
380
396
  })
381
397
  ```
382
398
 
383
- Running `pnpm eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
399
+ Install peer dependencies:
384
400
 
385
401
  ```bash
386
402
  pnpm i -D eslint-plugin-solid
387
403
  ```
388
404
 
389
- #### TailwindCSS
405
+ ### TailwindCSS
390
406
 
391
- To enable Tailwindcss support, you need to explicitly turn it on:
407
+ Uses the enhanced `eslint-plugin-better-tailwindcss` for improved class sorting and validation:
392
408
 
393
409
  ```js
394
- // eslint.config.js
395
410
  import { zayne } from '@zayne-labs/eslint-config'
396
411
 
397
412
  export default zayne({
398
- tailwindcss: true,
413
+ tailwindcssBetter: true,
399
414
  })
400
415
  ```
401
416
 
402
- Running `pnpm eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
417
+ Install peer dependencies:
403
418
 
404
419
  ```bash
405
- pnpm i -D eslint-plugin-tailwindcss
420
+ pnpm i -D eslint-plugin-better-tailwindcss
406
421
  ```
407
422
 
408
- ### Type Aware Rules
423
+ ### Expo (React Native)
424
+
425
+ ```js
426
+ import { zayne } from '@zayne-labs/eslint-config'
427
+
428
+ export default zayne({
429
+ expo: true,
430
+ })
431
+ ```
432
+
433
+ Install peer dependencies:
434
+
435
+ ```bash
436
+ pnpm i -D eslint-config-expo
437
+ ```
438
+
439
+ ### TanStack
440
+
441
+ Support for TanStack Query and Router:
442
+
443
+ ```js
444
+ import { zayne } from '@zayne-labs/eslint-config'
445
+
446
+ export default zayne({
447
+ tanstack: {
448
+ query: true,
449
+ router: true,
450
+ },
451
+ })
452
+ ```
453
+
454
+ Install peer dependencies:
455
+
456
+ ```bash
457
+ pnpm i -D @tanstack/eslint-plugin-query @tanstack/eslint-plugin-router
458
+ ```
459
+
460
+ ### PNPM Catalogs
461
+
462
+ Lint PNPM catalog protocol usage:
463
+
464
+ ```js
465
+ import { zayne } from '@zayne-labs/eslint-config'
466
+
467
+ export default zayne({
468
+ pnpm: true,
469
+ })
470
+ ```
471
+
472
+ Install peer dependencies:
473
+
474
+ ```bash
475
+ pnpm i -D eslint-plugin-pnpm
476
+ ```
477
+
478
+ ### Dependency Management
479
+
480
+ Enforce dependency rules with `eslint-plugin-depend`:
481
+
482
+ ```js
483
+ import { zayne } from '@zayne-labs/eslint-config'
484
+
485
+ export default zayne({
486
+ depend: true,
487
+ })
488
+ ```
489
+
490
+ Install peer dependencies:
491
+
492
+ ```bash
493
+ pnpm i -D eslint-plugin-depend
494
+ ```
495
+
496
+ ## Type-Aware Rules
497
+
498
+ Type-aware linting is automatically enabled when TypeScript is detected. It uses the nearest `tsconfig.json` by default.
499
+
500
+ Only specify `tsconfigPath` when you need to:
501
+
502
+ - Point to a tsconfig in a different location
503
+ - Use multiple tsconfigs
504
+
505
+ Single custom tsconfig location:
506
+
507
+ ```js
508
+ import { zayne } from '@zayne-labs/eslint-config'
509
+
510
+ export default zayne({
511
+ typescript: {
512
+ tsconfigPath: './config/tsconfig.json',
513
+ },
514
+ })
515
+ ```
409
516
 
410
- Working with TypeScript? You can enable type-aware linting by pointing to your `tsconfig.json`:
517
+ Multiple tsconfigs:
411
518
 
412
519
  ```js
413
- // eslint.config.js
414
520
  import { zayne } from '@zayne-labs/eslint-config'
415
521
 
416
522
  export default zayne({
417
523
  typescript: {
418
- tsconfigPath: 'tsconfig.json',
524
+ tsconfigPath: ['./tsconfig.json', './tsconfig.node.json'],
419
525
  },
420
526
  })
421
527
  ```
422
528
 
423
- ## View what rules are enabled
529
+ ## Inspecting Config
424
530
 
425
- Want to see what rules are active in your project? There's a cool tool for that! Use the ESLint config inspector (created by [Anthony Fu](https://github.com/antfu)):
531
+ View active rules using the [ESLint Config Inspector](https://github.com/eslint/config-inspector):
426
532
 
427
533
  ```bash
428
- pnpx @eslint/config-inspector@latest
534
+ npx @eslint/config-inspector@latest
429
535
  ```
430
536
 
431
- ## Versioning Policy
537
+ ## Versioning
432
538
 
433
- We follow [Semantic Versioning](https://semver.org/), but with a twist since this is a config package. Here's what we consider breaking changes and what we don't:
539
+ Follows [Semantic Versioning](https://semver.org/) with config-specific considerations:
434
540
 
435
- ### Breaking Changes ⚠️
541
+ **Breaking changes:**
436
542
 
437
- - Node.js version changes
438
- - Major refactors that could break your setup
439
- - Big plugin updates that change behavior
543
+ - Node.js version requirements
544
+ - Major refactors affecting setup
545
+ - Plugin updates with significant behavior changes
440
546
  - Changes affecting most codebases
441
547
 
442
- ### Non-Breaking Changes 🌟
548
+ **Non-breaking changes:**
443
549
 
444
- - Enabling/disabling rules (even if they get stricter)
445
- - Tweaking rule options
446
- - Updating dependencies
550
+ - Rule additions, removals, or option changes
551
+ - Dependency updates
552
+ - Stricter linting (considered improvements)
447
553
 
448
554
  ## FAQ
449
555
 
450
- ### "I prefer X instead of Y..."
556
+ ### I prefer different rules
451
557
 
452
- No worries! This config is just our take on things. Feel free to override rules locally to match your style. If that's not enough, you can always fork the repo and make it your own.
558
+ Override any rules locally using the [customization](#customization) options. For extensive changes, consider forking the repo.
453
559
 
454
- ## 🤝 Contributing
560
+ ## Contributing
455
561
 
456
- We welcome contributions! Please check out our [contribution guidelines](https://github.com/zayne-labs/contribute) for details on how to get started.
562
+ Contributions welcome! See our [contribution guidelines](https://github.com/zayne-labs/contribute) for details.
457
563
 
458
- ## 📄 License
564
+ ## License
459
565
 
460
- MIT © [Ryan Zayne]
566
+ MIT © Ryan Zayne
461
567
 
462
- ## 💖 Credits
568
+ ## Credits
463
569
 
464
- Inspired by the legendary open sourcerer, [antfu](https://github.com/antfu/eslint-config)
570
+ Inspired by [antfu/eslint-config](https://github.com/antfu/eslint-config)
package/dist/cli/index.js CHANGED
@@ -10,7 +10,7 @@ import parse from "parse-gitignore";
10
10
  import { execSync } from "node:child_process";
11
11
 
12
12
  //#region package.json
13
- var version = "0.10.9";
13
+ var version = "0.11.0";
14
14
 
15
15
  //#endregion
16
16
  //#region src/cli/constants.ts