@infernodesign/eslint-config 1.0.0 → 1.2.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.
Files changed (5) hide show
  1. package/README.md +287 -246
  2. package/bin/index.js +2 -0
  3. package/dist/index.d.ts +5262 -1670
  4. package/dist/index.js +920 -643
  5. package/package.json +149 -65
package/README.md CHANGED
@@ -15,95 +15,52 @@ Shared ESLint flat config presets for Inferno Design projects.
15
15
  - Respects `.gitignore` by default
16
16
  - Requires ESLint v9.5.0+
17
17
 
18
- ## Setup
19
-
20
- > [!NOTE]
21
- > Since this package is hosted in the GitHub Packages registry and is private to just Inferno Design, you must configure your `.npmrc` file to access the private registry.
22
-
23
- ### `.npmrc` Configuration
24
-
25
- To configure your `.npmrc` file, add the following line:
26
-
27
- ```ini
28
- //npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
29
- @infernodesign:registry=https://npm.pkg.github.com/
30
- ```
31
-
32
- Then, create an environment variable `GITHUB_TOKEN` with a personal access token that has the `read:packages` scope. Alternatively, you can replace `$GITHUB_TOKEN` with your personal access token directly in the `.npmrc` file. Make sure you don't commit this file to VCS to avoid exposing your token.
33
-
34
- ### Registry Configuration
35
-
36
- Alternatively, you can configure the registry for the `@infernodesign` packages registry scope using the following command:
37
-
38
- ```bash
39
- pnpm config set @infernodesign:registry https://npm.pkg.github.com/
40
- ```
41
-
42
- This command sets the registry for the `@infernodesign` scope to the GitHub Packages registry.
43
-
44
- ### Authentication
45
-
46
- Ensure that your authentication is set up correctly to access the packages. You can add your GitHub token to the `.npmrc` file as shown above or use the following command:
47
-
48
- ```bash
49
- pnpm config set //npm.pkg.github.com/:_authToken <your-personal-access-token>
50
- ```
51
-
52
- Replace `<your-personal-access-token>` with your actual GitHub personal access token.
53
-
54
18
  ## Usage
55
19
 
56
- ### Quick Start
20
+ ### Starter Wizard
57
21
 
58
- To quickly set up ESLint with the Inferno Design configuration or migrate from the legacy config to the new flat config, run the following CLI command in the root of your project:
22
+ We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
59
23
 
60
24
  ```bash
61
25
  pnpm dlx @infernodesign/eslint-config@latest
62
26
  ```
63
27
 
64
- ### Manual Installation
28
+ ### Manual Install
65
29
 
66
- To manually install and configure ESLint with the Inferno Design configuration, follow these steps:
30
+ If you prefer to set up manually:
67
31
 
68
- Install the necessary dependencies:
69
-
70
- ```shell
32
+ ```bash
71
33
  pnpm i -D eslint @infernodesign/eslint-config
72
34
  ```
73
35
 
74
- Create a `eslint.config.js` in your project root:
36
+ And create `eslint.config.mjs` in your project root:
75
37
 
76
38
  ```js
77
39
  // eslint.config.mjs
78
- import config from '@infernodesign/eslint-config'
79
-
80
- export default config()
81
- ```
82
-
83
- That's it! You can now run ESLint in your project:
40
+ import { inferno } from '@infernodesign/eslint-config'
84
41
 
85
- ```shell
86
- eslint . --fix
42
+ export default inferno()
87
43
  ```
88
44
 
89
45
  <details>
90
46
  <summary>
91
- Combine with legacy config:
47
+ Combined with legacy config:
92
48
  </summary>
93
49
 
94
- To use configs from the legacy `eslintrc` format, use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
50
+ 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.
95
51
 
96
52
  ```js
97
53
  // eslint.config.mjs
98
54
  import { FlatCompat } from '@eslint/eslintrc'
99
- import config from '@infernodesign/eslint-config'
55
+ import { inferno } from '@infernodesign/eslint-config'
100
56
 
101
57
  const compat = new FlatCompat()
102
58
 
103
- export default config(
59
+ export default inferno(
104
60
  {
105
61
  ignores: [],
106
62
  },
63
+
107
64
  // Legacy config
108
65
  ...compat.config( {
109
66
  extends: [
@@ -111,59 +68,49 @@ export default config(
111
68
  // Other extends...
112
69
  ],
113
70
  } )
71
+
114
72
  // Other flat configs...
115
73
  )
116
74
  ```
117
75
 
118
- > [!NOTE]
119
- > `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
76
+ > Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
120
77
 
121
78
  </details>
122
79
 
123
- ### Node Package Scripts
80
+ ### Add script for package.json
124
81
 
125
- To lint your project, add the following scripts to your `package.json`:
82
+ For example:
126
83
 
127
84
  ```json
128
85
  {
129
86
  "scripts": {
130
- "lint": "eslint .",
131
- "lint:fix": "eslint . --fix"
87
+ "lint": "eslint",
88
+ "lint:fix": "eslint --fix"
132
89
  }
133
90
  }
134
91
  ```
135
92
 
136
- ### Precommit Hook
137
-
138
- To lint your project before committing, use a precommit hook with [husky](https://typicode.github.io/husky/#/):
93
+ ## IDE Support (auto fix on save)
139
94
 
140
- ```bash
141
- pnpm install husky --save-dev
142
- pnpx husky install
143
- pnpx husky add .husky/pre-commit "eslint . --fix && git add ."
144
- ```
95
+ ### VS Code support
145
96
 
146
- This will automatically lint and fix your code before each commit.
97
+ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
147
98
 
148
- ## VS Code Support (Autofix on Save)
99
+ Add the following settings to your `.vscode/settings.json`:
149
100
 
150
- Install the [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
151
-
152
- Then, add the following settings to your `.vscode/settings.json`:
153
-
154
- ```json5
101
+ ```jsonc
155
102
  {
156
103
  // Disable the default formatter, use eslint instead
157
104
  "prettier.enable": false,
158
105
  "editor.formatOnSave": false,
159
106
 
160
- // Autofix on save
107
+ // Auto fix
161
108
  "editor.codeActionsOnSave": {
162
109
  "source.fixAll.eslint": "explicit",
163
110
  "source.organizeImports": "never"
164
111
  },
165
112
 
166
- // (Optional) Silent the stylistic rules in the IDE, but still autofix them
113
+ // Silent the stylistic rules in you IDE, but still auto fix them
167
114
  "eslint.rules.customizations": [
168
115
  { "rule": "style/*", "severity": "off", "fixable": true },
169
116
  { "rule": "format/*", "severity": "off", "fixable": true },
@@ -206,45 +153,45 @@ Then, add the following settings to your `.vscode/settings.json`:
206
153
 
207
154
  ## Customization
208
155
 
209
- This package uses the new [ESLint Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition.
156
+ Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition.
210
157
 
211
- Normally you only need to import the `config` preset:
158
+ Normally you only need to import the `antfu` preset:
212
159
 
213
160
  ```js
214
161
  // eslint.config.js
215
- import config from '@infernodesign/eslint-config'
162
+ import { inferno } from '@infernodesign/eslint-config'
216
163
 
217
- export default config()
164
+ export default inferno()
218
165
  ```
219
166
 
220
167
  And that's it! Or you can configure each integration individually, for example:
221
168
 
222
169
  ```js
223
170
  // eslint.config.js
224
- import config from '@infernodesign/eslint-config'
171
+ import { inferno } from '@infernodesign/eslint-config'
225
172
 
226
- export default config( {
227
- // Type of the project. 'lib' for libraries, the default is 'app'
173
+ export default inferno( {
174
+ // Type of the project. 'lib' for libraries, the default is 'app'
228
175
  type: 'lib',
229
176
 
230
177
  // Enable stylistic formatting rules
231
178
  // stylistic: true,
232
179
 
233
- // Or, customize the stylistic rules
180
+ // Or customize the stylistic rules
234
181
  stylistic: {
235
182
  indent: 2, // 4, or 'tab'
236
183
  quotes: 'single', // or 'double'
237
184
  },
238
185
 
239
- // TypeScript and Vue are auto-detected, you can also explicitly enable them:
186
+ // TypeScript and Vue are autodetected, you can also explicitly enable them:
240
187
  typescript: true,
241
188
  vue: true,
242
189
 
243
- // Enable React
244
- react: true,
245
-
246
190
  // Enable Next.js
247
- next: true,
191
+ nextjs: true,
192
+
193
+ // Enable Storybook
194
+ storybook: true,
248
195
 
249
196
  // Disable jsonc and yaml support
250
197
  jsonc: false,
@@ -253,38 +200,40 @@ export default config( {
253
200
  // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
254
201
  ignores: [
255
202
  '**/fixtures',
256
- // ... Additional globs
203
+ // ...globs
257
204
  ]
258
205
  } )
259
206
  ```
260
207
 
261
- The `config` factory function accepts any amount of custom config overrides:
208
+ The `antfu` factory function also accepts any number of arbitrary custom config overrides:
262
209
 
263
210
  ```js
264
211
  // eslint.config.js
265
- import config from '@infernodesign/eslint-config'
212
+ import { inferno } from '@infernodesign/eslint-config'
266
213
 
267
- export default config(
214
+ export default inferno(
268
215
  {
269
- // Configurations for `config`
216
+ // Configures for antfu's config
270
217
  },
271
- // ESLint Flat Configs
218
+
219
+ // From the second arguments they are ESLint Flat Configs
220
+ // you can have multiple configs
272
221
  {
273
222
  files: [ '**/*.ts' ],
274
223
  rules: {},
275
224
  },
276
225
  {
277
- files: [ '**/*.vue' ],
278
226
  rules: {},
279
227
  },
280
228
  )
281
229
  ```
282
230
 
283
- A more advanced usage, import fine-grained configs and compose them together:
231
+ Going more advanced, you can also import fine-grained configs and compose them as you wish:
284
232
 
285
- ### Advanced Example
233
+ <details>
234
+ <summary>Advanced Example</summary>
286
235
 
287
- Using this style is not recommended as the shared options between configs might need extra care to be consistent.
236
+ 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.
288
237
 
289
238
  ```js
290
239
  // eslint.config.js
@@ -297,11 +246,11 @@ import {
297
246
  jsdoc,
298
247
  jsonc,
299
248
  markdown,
300
- next,
249
+ nextjs,
301
250
  node,
302
- react,
303
251
  sortPackageJson,
304
252
  sortTsconfig,
253
+ storybook,
305
254
  stylistic,
306
255
  toml,
307
256
  typescript,
@@ -311,46 +260,48 @@ import {
311
260
  } from '@infernodesign/eslint-config'
312
261
 
313
262
  export default combine(
314
- combine(),
315
- comments(),
316
263
  ignores(),
317
- imports(),
318
- javascript( /* options */ ),
319
- jsdoc(),
320
- jsonc(),
321
- markdown(),
322
- next(),
264
+ javascript( /* Options */ ),
265
+ comments(),
323
266
  node(),
324
- react( /* options */ ),
325
- sortPackageJson(),
326
- sortTsconfig(),
327
- stylistic(),
328
- toml(),
329
- typescript( /* options */ ),
267
+ jsdoc(),
268
+ imports(),
269
+ nextjs(),
270
+ storybook(),
330
271
  unicorn(),
272
+ typescript( /* Options */ ),
273
+ stylistic(),
331
274
  vue(),
275
+ jsonc(),
332
276
  yaml(),
277
+ toml(),
278
+ markdown(),
333
279
  )
334
280
  ```
335
281
 
336
- Refer to the [configs](https://github.com/infernodesign/tooling/tree/main/tooling/eslint/src/configs) and [factory](https://github.com/infernodesign/tooling/tree/main/tooling/eslint/src/factory.ts) source files for more details.
282
+ </details>
283
+
284
+ Check out the [configs](https://github.com/antfu/eslint-config/blob/main/src/configs) and [factory](https://github.com/antfu/eslint-config/blob/main/src/factory.ts) for more details.
337
285
 
338
- ### Plugin Renaming
286
+ > Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) for the inspiration and reference.
339
287
 
340
- Since ESLint Flat Config requires explicitly providing the plugin names (instead of the mandatory convention from npm package name), some plugins have been renamed to make the overall scope more consistent and easier to write.
288
+ ### Plugins Renaming
341
289
 
342
- | New Prefix | Original Prefix | Source Plugin |
343
- |------------|------------------------|----------------------------------------------------------------------------------------------------------------------|
344
- | `import/*` | `import-x/*` | [eslint-plugin-import-x](https://github.com/un-es/eslint-plugin-import-x) |
345
- | `next/*` | `@next/next/*` | [@next/eslint-plugin-next](https://nextjs.org/docs/pages/building-your-application/configuring/eslint#eslint-plugin) |
346
- | `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
347
- | `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
348
- | `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
349
- | `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
350
- | `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
351
- | `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
290
+ Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm package name), we renamed some plugins to make the overall scope more consistent and easier to write.
352
291
 
353
- To override rules, or disable them inline, use the new prefix:
292
+ | New Prefix | Original Prefix | Source Plugin |
293
+ | ---------- | ---------------------- | ----------------------------------------------------------------------------------------------------- |
294
+ | `import/*` | `import-lite/*` | [eslint-plugin-import-lite](https://github.com/9romise/eslint-plugin-import-lite) |
295
+ | `nextjs/*` | `@next/next` | [@next/eslint-plugin-next](https://github.com/vercel/next.js/tree/canary/packages/eslint-plugin-next) |
296
+ | `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
297
+ | `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
298
+ | `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
299
+ | `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
300
+ | `test/*` | `vitest/*` | [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest) |
301
+ | `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
302
+ | `next/*` | `@next/next` | [@next/eslint-plugin-next](https://github.com/vercel/next.js/tree/canary/packages/eslint-plugin-next) |
303
+
304
+ When you want to override rules, or disable them inline, you need to update to the new prefix:
354
305
 
355
306
  ```diff
356
307
  -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
@@ -358,22 +309,34 @@ To override rules, or disable them inline, use the new prefix:
358
309
  type foo = { bar: 2 }
359
310
  ```
360
311
 
361
- > [!NOTE]
362
- > This preset will automatically rename the plugins for your custom configs. Use the original prefix to override the rules directly.
312
+ ### Change back to original prefix
313
+
314
+ If you really want to use the original prefix, you can revert the plugin renaming by:
315
+
316
+ ```ts
317
+ import { inferno } from '@infernodesign/eslint-config'
318
+
319
+ export default inferno()
320
+ .renamePlugins( {
321
+ ts: '@typescript-eslint',
322
+ yaml: 'yml',
323
+ node: 'n'
324
+ // ...
325
+ } )
326
+ ```
363
327
 
364
328
  ### Rules Overrides
365
329
 
366
- Certain rules would only be enabled for specific files. For example, `ts/*` rules would only be enabled in
367
- `.ts` files and `vue/*` rules would only be enabled in `.vue` files. To override the rules, specify the file extension:
330
+ Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files and `vue/*` rules would only be enabled in `.vue` files. If you want to override the rules, you need to specify the file extension:
368
331
 
369
332
  ```js
370
333
  // eslint.config.js
371
- import config from '@infernodesign/eslint-config'
334
+ import { inferno } from '@infernodesign/eslint-config'
372
335
 
373
- export default config(
336
+ export default inferno(
374
337
  {
375
- typescript: true,
376
- vue: true
338
+ vue: true,
339
+ typescript: true
377
340
  },
378
341
  {
379
342
  // Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
@@ -391,21 +354,21 @@ export default config(
391
354
  )
392
355
  ```
393
356
 
394
- Use the provided `overrides` options in each integration to make overrides easier:
357
+ We also provided the `overrides` options in each integration to make it easier:
395
358
 
396
359
  ```js
397
360
  // eslint.config.js
398
- import config from '@infernodesign/eslint-config'
361
+ import { inferno } from '@infernodesign/eslint-config'
399
362
 
400
- export default config( {
401
- typescript: {
363
+ export default inferno( {
364
+ vue: {
402
365
  overrides: {
403
- 'ts/consistent-type-definitions': [ 'error', 'interface' ],
366
+ 'vue/operator-linebreak': [ 'error', 'before' ],
404
367
  },
405
368
  },
406
- vue: {
369
+ typescript: {
407
370
  overrides: {
408
- 'vue/operator-linebreak': [ 'error', 'before' ],
371
+ 'ts/consistent-type-definitions': [ 'error', 'interface' ],
409
372
  },
410
373
  },
411
374
  yaml: {
@@ -418,90 +381,108 @@ export default config( {
418
381
 
419
382
  ### Config Composer
420
383
 
421
- The factory function `config()` returns a [`FlatConfigComposer` object from
422
- `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config more flexibly.
384
+ Since v2.10.0, the factory function `inferno()` returns a [`FlatConfigComposer` object from `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config even more flexibly.
423
385
 
424
386
  ```js
425
387
  // eslint.config.js
426
- import config from '@infernodesign/eslint-config'
388
+ import { inferno } from '@infernodesign/eslint-config'
427
389
 
428
- export default config()
390
+ export default inferno()
429
391
  .prepend(
430
- // some configs before the main config
392
+ // some configs before the main config
431
393
  )
432
- // overrides any named configs
394
+ // overrides any named configs
433
395
  .override(
434
- 'config/imports',
396
+ 'antfu/stylistic/rules',
435
397
  {
436
398
  rules: {
437
- 'import/order': [ 'error', { 'newlines-between': 'always' } ],
399
+ 'style/generator-star-spacing': [ 'error', { after: true, before: false } ],
438
400
  }
439
401
  }
440
402
  )
441
- // rename plugin prefixes
403
+ // rename plugin prefixes
442
404
  .renamePlugins( {
443
405
  'old-prefix': 'new-prefix',
444
- // ...
406
+ // ...
445
407
  } )
446
408
  // ...
447
409
  ```
448
410
 
449
411
  ### Vue
450
412
 
451
- Vue support is detected automatically by checking if
452
- `vue` is installed in your project. To explicitly enable/disable it:
413
+ Vue support is detected automatically by checking if `vue` is installed in your project. You can also explicitly enable/disable it:
453
414
 
454
415
  ```js
455
416
  // eslint.config.js
456
- import config from '@infernodesign/eslint-config'
417
+ import { inferno } from '@infernodesign/eslint-config'
457
418
 
458
- export default config( {
419
+ export default inferno( {
459
420
  vue: true
460
421
  } )
461
422
  ```
462
423
 
463
424
  #### Vue 2
464
425
 
465
- Limited support for Vue 2 is available since it has [reached EOL](https://v2.vuejs.org/eol/). To use Vue 2, configure it manually by setting
466
- `vueVersion` to `2`:
426
+ We have limited support for Vue 2 (as it's already [reached EOL](https://v2.vuejs.org/eol/)). If you are still using Vue 2, you can configure it manually by setting `vueVersion` to `2`:
467
427
 
468
428
  ```js
469
429
  // eslint.config.js
470
- import config from '@infernodesign/eslint-config'
430
+ import { inferno } from '@infernodesign/eslint-config'
471
431
 
472
- export default config( {
432
+ export default inferno( {
473
433
  vue: {
474
434
  vueVersion: 2
475
435
  },
476
436
  } )
477
437
  ```
478
438
 
439
+ As it's in maintenance mode, we only accept bug fixes for Vue 2. It might also be removed in the future when `eslint-plugin-vue` drops support for Vue 2. We recommend upgrading to Vue 3 if possible.
440
+
441
+ #### Vue Accessibility
442
+
443
+ To enable Vue accessibility support, you need to explicitly turn it on:
444
+
445
+ ```js
446
+ // eslint.config.js
447
+ import { inferno } from '@infernodesign/eslint-config'
448
+
449
+ export default inferno( {
450
+ vue: {
451
+ a11y: true
452
+ },
453
+ } )
454
+ ```
455
+
456
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
457
+
458
+ ```bash
459
+ npm i -D eslint-plugin-vuejs-accessibility
460
+ ```
461
+
479
462
  ### Optional Configs
480
463
 
481
- Some optional configs are available for specific use cases. Their dependencies are not provided by default.
464
+ We provide some optional configs for specific use cases, that we don't include their dependencies by default.
482
465
 
483
466
  #### Formatters
484
467
 
485
- Use external formatters to format files that ESLint can't handle yet (`.css`, `.html`, etc). Powered by [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format).
468
+ Use external formatters to format files that ESLint cannot handle yet (`.css`, `.html`, etc). Powered by [`eslint-plugin-format`](https://github.com/antfu/eslint-plugin-format).
486
469
 
487
470
  ```js
488
471
  // eslint.config.js
489
- import config from '@infernodesign/eslint-config'
472
+ import { inferno } from '@infernodesign/eslint-config'
490
473
 
491
- export default config( {
474
+ export default inferno( {
492
475
  formatters: {
493
476
  /**
494
477
  * Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
495
478
  * By default uses Prettier
496
479
  */
497
480
  css: true,
498
-
499
481
  /**
500
482
  * Format HTML files
501
483
  * By default uses Prettier
502
484
  */
503
485
  html: true,
504
-
505
486
  /**
506
487
  * Format Markdown files
507
488
  * Supports Prettier and dprint
@@ -512,143 +493,150 @@ export default config( {
512
493
  } )
513
494
  ```
514
495
 
515
- Then, install the required dependencies:
496
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
516
497
 
517
- ```shell
518
- pnpm i -D eslint-plugin-format
498
+ ```bash
499
+ npm i -D eslint-plugin-format
500
+ ```
501
+
502
+ #### React
503
+
504
+ To enable React support, you need to explicitly turn it on:
505
+
506
+ ```js
507
+ // eslint.config.js
508
+ import { inferno } from '@infernodesign/eslint-config'
509
+
510
+ export default inferno( {
511
+ react: true,
512
+ } )
513
+ ```
514
+
515
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
516
+
517
+ ```bash
518
+ npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
519
519
  ```
520
520
 
521
521
  #### Next.js
522
522
 
523
- To enable Next.js support, explicitly turn it on:
523
+ To enable Next.js support, you need to explicitly turn it on:
524
524
 
525
525
  ```js
526
526
  // eslint.config.js
527
- import config from '@infernodesign/eslint-config'
527
+ import { inferno } from '@infernodesign/eslint-config'
528
528
 
529
- export default config( {
530
- next: true,
529
+ export default inferno( {
530
+ nextjs: true,
531
531
  } )
532
532
  ```
533
533
 
534
- Then, install the required dependencies:
534
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
535
535
 
536
- ```shell
537
- pnpm i -D @next/eslint-next-plugin
536
+ ```bash
537
+ npm i -D @next/eslint-plugin-next
538
538
  ```
539
539
 
540
- #### React
540
+ #### Storybook
541
541
 
542
- To enable React support, explicitly turn it on:
542
+ To enable storybook support, you need to explicitly turn it on:
543
543
 
544
544
  ```js
545
545
  // eslint.config.js
546
- import config from '@infernodesign/eslint-config'
546
+ import { inferno } from '@infernodesign/eslint-config'
547
547
 
548
- export default config( {
549
- react: true,
548
+ export default inferno( {
549
+ storybook: true,
550
550
  } )
551
551
  ```
552
552
 
553
- Then, install the required dependencies:
553
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
554
554
 
555
- ```shell
556
- pnpm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
555
+ ```bash
556
+ npm i -D eslint-plugin-storybook
557
557
  ```
558
558
 
559
559
  #### Svelte
560
560
 
561
- To enable svelte support, explicitly turn it on:
561
+ To enable svelte support, you need to explicitly turn it on:
562
562
 
563
563
  ```js
564
564
  // eslint.config.js
565
- import config from '@infernodesign/eslint-config'
565
+ import { inferno } from '@infernodesign/eslint-config'
566
566
 
567
- export default config( {
567
+ export default inferno( {
568
568
  svelte: true,
569
569
  } )
570
570
  ```
571
571
 
572
- Then, install the required dependencies:
572
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
573
573
 
574
- ```shell
575
- pnpm i -D eslint-plugin-svelte
574
+ ```bash
575
+ npm i -D eslint-plugin-svelte
576
576
  ```
577
577
 
578
578
  #### Astro
579
579
 
580
- To enable astro support, explicitly turn it on:
580
+ To enable astro support, you need to explicitly turn it on:
581
581
 
582
582
  ```js
583
583
  // eslint.config.js
584
- import config from '@infernodesign/eslint-config'
584
+ import { inferno } from '@infernodesign/eslint-config'
585
585
 
586
- export default config( {
586
+ export default inferno( {
587
587
  astro: true,
588
588
  } )
589
589
  ```
590
590
 
591
- Then, install the required dependencies:
591
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
592
592
 
593
- ```shell
594
- pnpm i -D eslint-plugin-astro
593
+ ```bash
594
+ npm i -D eslint-plugin-astro
595
595
  ```
596
596
 
597
597
  #### Solid
598
598
 
599
- To enable Solid support, explicitly turn it on:
599
+ To enable Solid support, you need to explicitly turn it on:
600
600
 
601
601
  ```js
602
602
  // eslint.config.js
603
- import config from '@infernodesign/eslint-config'
603
+ import { inferno } from '@infernodesign/eslint-config'
604
604
 
605
- export default config( {
605
+ export default inferno( {
606
606
  solid: true,
607
607
  } )
608
608
  ```
609
609
 
610
- Then, install the required dependencies:
610
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
611
611
 
612
- ```shell
613
- pnpm i -D eslint-plugin-solid
612
+ ```bash
613
+ npm i -D eslint-plugin-solid
614
614
  ```
615
615
 
616
616
  #### UnoCSS
617
617
 
618
- To enable UnoCSS support, explicitly turn it on:
618
+ To enable UnoCSS support, you need to explicitly turn it on:
619
619
 
620
620
  ```js
621
621
  // eslint.config.js
622
- import config from '@infernodesign/eslint-config'
622
+ import { inferno } from '@infernodesign/eslint-config'
623
623
 
624
- export default config( {
624
+ export default inferno( {
625
625
  unocss: true,
626
626
  } )
627
627
  ```
628
628
 
629
- Then, install the required dependencies:
629
+ Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
630
630
 
631
- ```shell
632
- pnpm i -D @unocss/eslint-plugin
631
+ ```bash
632
+ npm i -D @unocss/eslint-plugin
633
633
  ```
634
634
 
635
- ### Type-Aware Rules
636
-
637
- You can optionally enable the [type-aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the
638
- `typescript` config:
639
-
640
- ```js
641
- // eslint.config.js
642
- import config from '@infernodesign/eslint-config'
635
+ ### Optional Rules
643
636
 
644
- export default config( {
645
- typescript: {
646
- tsconfigPath: 'tsconfig.json',
647
- },
648
- } )
649
- ```
637
+ This config also provides some optional plugins/rules for extended usage.
650
638
 
651
- ### Command-Line Interface (CLI)
639
+ #### `command`
652
640
 
653
641
  Powered by [`eslint-plugin-command`](https://github.com/antfu/eslint-plugin-command). It is not a typical rule for linting, but an on-demand micro-codemod tool that triggers by specific comments.
654
642
 
@@ -667,12 +655,12 @@ You can add the trigger comment one line above the code you want to transform, f
667
655
 
668
656
  ```ts
669
657
  /// to-function
670
- const foo = async ( msg: string ): void => {
671
- console.log( msg )
658
+ const foo = async (msg: string): void => {
659
+ console.log(msg)
672
660
  }
673
661
  ```
674
662
 
675
- Will be transformed to this when you hit save with your editor or run `eslint . --fix`:
663
+ Will be transformed to this when you hit save with your editor or run `eslint --fix`:
676
664
 
677
665
  ```ts
678
666
  async function foo( msg: string ): void {
@@ -682,24 +670,45 @@ async function foo( msg: string ): void {
682
670
 
683
671
  The command comments are usually one-off and will be removed along with the transformation.
684
672
 
673
+ ### Type Aware Rules
674
+
675
+ You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
676
+
677
+ ```js
678
+ // eslint.config.js
679
+ import { inferno } from '@infernodesign/eslint-config'
680
+
681
+ export default inferno( {
682
+ typescript: {
683
+ tsconfigPath: 'tsconfig.json',
684
+ },
685
+ } )
686
+ ```
687
+
685
688
  ### Editor Specific Disables
686
689
 
687
- Some rules are disabled when inside ESLint IDE integrations, namely [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports) [`test/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests).
690
+ Auto-fixing for the following rules are disabled when ESLint is running in a code editor:
691
+
692
+ - [`prefer-const`](https://eslint.org/docs/rules/prefer-const)
693
+ - [`test/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
694
+ - [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports)
688
695
 
689
- This is to prevent unused imports from getting removed by the IDE during refactoring to get a better DX. Those rules will be applied when running ESLint in the terminal or [Lint Staged](#lint-staged). To disable this behavior:
696
+ Since v3.16.0, they are no longer disabled, but made non-fixable using [this helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix).
697
+
698
+ This is to prevent unused imports from getting removed by the editor during refactoring to get a better developer experience. Those rules will be applied when you run ESLint in the terminal or [Lint Staged](#lint-staged). If you don't want this behavior, you can disable them:
690
699
 
691
700
  ```js
692
701
  // eslint.config.js
693
- import config from '@infernodesign/eslint-config'
702
+ import { inferno } from '@infernodesign/eslint-config'
694
703
 
695
- export default config( {
704
+ export default inferno( {
696
705
  isInEditor: false
697
706
  } )
698
707
  ```
699
708
 
700
709
  ### Lint Staged
701
710
 
702
- To apply linting and auto fixing before every commit, add the following to your `package.json`:
711
+ If you want to apply lint and auto-fix before every commit, you can add the following to your `package.json`:
703
712
 
704
713
  ```json
705
714
  {
@@ -712,10 +721,10 @@ To apply linting and auto fixing before every commit, add the following to your
712
721
  }
713
722
  ```
714
723
 
715
- Then, install the required dependencies:
724
+ and then
716
725
 
717
- ```shell
718
- pnpm i -D lint-staged simple-git-hooks
726
+ ```bash
727
+ npm i -D lint-staged simple-git-hooks
719
728
 
720
729
  # to activate the hooks
721
730
  npx simple-git-hooks
@@ -723,15 +732,47 @@ npx simple-git-hooks
723
732
 
724
733
  ## View what rules are enabled
725
734
 
726
- Use the [`@eslint/config-inspector`](https://github.com/eslint/config-inspector) visual tool to view the enabled rules in your project and applied to each file.
735
+ I built a visual tool to help you view what rules are enabled in your project and apply them to what files, [@eslint/config-inspector](https://github.com/eslint/config-inspector)
736
+
737
+ Go to your project root that contains `eslint.config.mjs` and run:
738
+
739
+ ```bash
740
+ npx @eslint/config-inspector
741
+ ```
742
+
743
+ ## Versioning Policy
744
+
745
+ This project follows [Semantic Versioning](https://semver.org/) for releases. However, since this is just a config and involves opinions and many moving parts, we don't treat rules changes as breaking changes.
746
+
747
+ ### Changes Considered as Breaking Changes
727
748
 
728
- In the project root that contains the `eslint.config.js`file, run:
749
+ - Node.js version requirement changes
750
+ - Huge refactors that might break the config
751
+ - Plugins made major changes that might break the config
752
+ - Changes that might affect most of the codebases
729
753
 
730
- ```shell
731
- pnpx @eslint/config-inspector
754
+ ### Changes Considered as Non-breaking Changes
732
755
 
733
- # or specify the config file
734
- pnpx @eslint/config-inspector --config ./eslint.config.js
756
+ - Enable/disable rules and plugins (that might become stricter)
757
+ - Rules options changes
758
+ - Version bumps of dependencies
759
+
760
+ ## FAQ
761
+
762
+ ### How to format CSS?
763
+
764
+ You can opt-in to the [`formatters`](#formatters) feature to format your CSS. Note that it's only doing formatting, but not linting. If you want proper linting support, give [`stylelint`](https://stylelint.io/) a try.
765
+
766
+ ### Top-level Function Style, etc
767
+
768
+ If you want to disable the opinionated rules, you can disable them with:
769
+
770
+ ```ts
771
+ import { inferno } from '@infernodesign/eslint-config'
772
+
773
+ export default inferno( {
774
+ lessOpinionated: true
775
+ } )
735
776
  ```
736
777
 
737
778
  ## License
@@ -740,4 +781,4 @@ Licensed under the [MIT License](./LICENSE).
740
781
 
741
782
  ## Credits
742
783
 
743
- - Inspired by [Antfu's eslint-config](https://github.com/antfu/eslint-config)
784
+ - Orignally forked from [Antfu's eslint-config](https://github.com/antfu/eslint-config)