@ghettoddos/eslint-config 1.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/LICENSE +21 -0
- package/README.md +524 -0
- package/dist/index.d.ts +13057 -0
- package/dist/index.js +1991 -0
- package/package.json +99 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-PRESENT ghettoDdOS<https://github.com/ghettDdOS>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
# @ghettoddos/eslint-config
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@ghettoddos/eslint-config)
|
|
4
|
+
|
|
5
|
+
- Auto fix for formatting (aimed to be used standalone **without** Prettier)
|
|
6
|
+
- Reasonable defaults, best practices, only one line of config
|
|
7
|
+
- Designed to work with TypeScript, JSX, React, JSON, YAML, Toml, Markdown, etc. Out-of-box.
|
|
8
|
+
- Opinionated, but [very customizable](#customization)
|
|
9
|
+
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
|
|
10
|
+
- Optional [UnoCSS](#unocss) support
|
|
11
|
+
- Optional [formatters](#formatters) support for formatting CSS, HTML, XML, etc.
|
|
12
|
+
- **Style principle**: Minimal for reading, stable for diff, consistent
|
|
13
|
+
- Sorted imports, dangling commas
|
|
14
|
+
- Single quotes, no semi
|
|
15
|
+
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
16
|
+
- Respects `.gitignore` by default
|
|
17
|
+
- Requires ESLint v9.5.0+
|
|
18
|
+
|
|
19
|
+
> Thanks to [antfu/eslint-config](https://github.com/antfu/eslint-config) for the inspiration and reference.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Manual Install
|
|
24
|
+
|
|
25
|
+
If you prefer to set up manually:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm i -D eslint @ghettoddos/eslint-config
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
And create `eslint.config.mjs` in your project root:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
// eslint.config.mjs
|
|
35
|
+
import config from '@ghettoddos/eslint-config'
|
|
36
|
+
|
|
37
|
+
export default config()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Add script for package.json
|
|
41
|
+
|
|
42
|
+
For example:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"scripts": {
|
|
47
|
+
"lint": "eslint",
|
|
48
|
+
"lint:fix": "eslint --fix"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## IDE Support (auto fix on save)
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary>🟦 VS Code support</summary>
|
|
57
|
+
|
|
58
|
+
<br>
|
|
59
|
+
|
|
60
|
+
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
|
|
61
|
+
|
|
62
|
+
Add the following settings to your `.vscode/settings.json`:
|
|
63
|
+
|
|
64
|
+
```jsonc
|
|
65
|
+
{
|
|
66
|
+
// Disable the default formatter, use eslint instead
|
|
67
|
+
"prettier.enable": false,
|
|
68
|
+
"editor.formatOnSave": false,
|
|
69
|
+
|
|
70
|
+
// Auto fix
|
|
71
|
+
"editor.codeActionsOnSave": {
|
|
72
|
+
"source.fixAll.eslint": "explicit",
|
|
73
|
+
"source.organizeImports": "never"
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
77
|
+
"eslint.rules.customizations": [
|
|
78
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
79
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
80
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
81
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
82
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
83
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
84
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
85
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
86
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
87
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
88
|
+
],
|
|
89
|
+
|
|
90
|
+
// Enable eslint for all supported languages
|
|
91
|
+
"eslint.validate": [
|
|
92
|
+
"javascript",
|
|
93
|
+
"javascriptreact",
|
|
94
|
+
"typescript",
|
|
95
|
+
"typescriptreact",
|
|
96
|
+
"html",
|
|
97
|
+
"markdown",
|
|
98
|
+
"json",
|
|
99
|
+
"jsonc",
|
|
100
|
+
"yaml",
|
|
101
|
+
"toml",
|
|
102
|
+
"xml",
|
|
103
|
+
"css",
|
|
104
|
+
"less",
|
|
105
|
+
"scss",
|
|
106
|
+
"pcss",
|
|
107
|
+
"postcss"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Customization
|
|
113
|
+
|
|
114
|
+
Normally you only need to import the `config` preset:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
// eslint.config.js
|
|
118
|
+
import config from '@ghettoddos/eslint-config'
|
|
119
|
+
|
|
120
|
+
export default config()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
And that's it! Or you can configure each integration individually, for example:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
// eslint.config.js
|
|
127
|
+
import config from '@ghettoddos/eslint-config'
|
|
128
|
+
|
|
129
|
+
export default config({
|
|
130
|
+
// Type of the project. 'lib' for libraries, the default is 'app'
|
|
131
|
+
type: 'lib',
|
|
132
|
+
|
|
133
|
+
// Enable stylistic formatting rules
|
|
134
|
+
// stylistic: true,
|
|
135
|
+
|
|
136
|
+
// Or customize the stylistic rules
|
|
137
|
+
stylistic: {
|
|
138
|
+
indent: 2, // 4, or 'tab'
|
|
139
|
+
quotes: 'single', // or 'double'
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
// TypeScript are autodetected, you can also explicitly enable them:
|
|
143
|
+
typescript: true,
|
|
144
|
+
|
|
145
|
+
// Disable jsonc and yaml support
|
|
146
|
+
jsonc: false,
|
|
147
|
+
yaml: false,
|
|
148
|
+
|
|
149
|
+
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
|
|
150
|
+
ignores: [
|
|
151
|
+
'**/fixtures',
|
|
152
|
+
// ...globs
|
|
153
|
+
],
|
|
154
|
+
})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The `config` factory function also accepts any number of arbitrary custom config overrides:
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
// eslint.config.js
|
|
161
|
+
import config from '@ghettoddos/eslint-config'
|
|
162
|
+
|
|
163
|
+
export default config(
|
|
164
|
+
{
|
|
165
|
+
// Configures for config
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// From the second arguments they are ESLint Flat Configs
|
|
169
|
+
// you can have multiple configs
|
|
170
|
+
{
|
|
171
|
+
files: ['**/*.ts'],
|
|
172
|
+
rules: {},
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
rules: {},
|
|
176
|
+
},
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Going more advanced, you can also import fine-grained configs and compose them as you wish:
|
|
181
|
+
|
|
182
|
+
<details>
|
|
183
|
+
<summary>Advanced Example</summary>
|
|
184
|
+
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
// eslint.config.js
|
|
189
|
+
import {
|
|
190
|
+
combine,
|
|
191
|
+
comments,
|
|
192
|
+
ignores,
|
|
193
|
+
imports,
|
|
194
|
+
javascript,
|
|
195
|
+
jsonc,
|
|
196
|
+
markdown,
|
|
197
|
+
node,
|
|
198
|
+
sortPackageJson,
|
|
199
|
+
sortTsconfig,
|
|
200
|
+
stylistic,
|
|
201
|
+
toml,
|
|
202
|
+
typescript,
|
|
203
|
+
unicorn,
|
|
204
|
+
yaml,
|
|
205
|
+
} from '@ghettoddo/eslint-config'
|
|
206
|
+
|
|
207
|
+
export default combine(
|
|
208
|
+
ignores(),
|
|
209
|
+
javascript(/* Options */),
|
|
210
|
+
comments(),
|
|
211
|
+
node(),
|
|
212
|
+
imports(),
|
|
213
|
+
unicorn(),
|
|
214
|
+
typescript(/* Options */),
|
|
215
|
+
stylistic(),
|
|
216
|
+
jsonc(),
|
|
217
|
+
yaml(),
|
|
218
|
+
toml(),
|
|
219
|
+
markdown(),
|
|
220
|
+
)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
</details>
|
|
224
|
+
|
|
225
|
+
Check out the [configs](https://github.com/ghettoDdOS/eslint-config/blob/master/src/configs) and [factory](https://github.com/ghettoDdOS/eslint-config/blob/master/src/factory.ts) for more details.
|
|
226
|
+
|
|
227
|
+
> Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) for the inspiration and reference.
|
|
228
|
+
|
|
229
|
+
### Plugins Renaming
|
|
230
|
+
|
|
231
|
+
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.
|
|
232
|
+
|
|
233
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
234
|
+
| ---------- | ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
235
|
+
| `import/*` | `import-x/*` | [eslint-plugin-import-x](https://github.com/un-es/eslint-plugin-import-x) |
|
|
236
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
237
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
238
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
239
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
240
|
+
|
|
241
|
+
When you want to override rules, or disable them inline, you need to update to the new prefix:
|
|
242
|
+
|
|
243
|
+
```diff
|
|
244
|
+
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
245
|
+
+// eslint-disable-next-line ts/consistent-type-definitions
|
|
246
|
+
type foo = { bar: 2 }
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
> [!NOTE]
|
|
250
|
+
> About plugin renaming - it is actually rather a dangrous move that might leading to potential naming collisions, pointed out [here](https://github.com/eslint/eslint/discussions/17766) and [here](https://github.com/prettier/eslint-config-prettier#eslintconfigjs-flat-config-plugin-caveat). As this config also very **personal** and **opinionated**, I ambitiously position this config as the only **"top-level"** config per project, that might pivots the taste of how rules are named.
|
|
251
|
+
>
|
|
252
|
+
> This config cares more about the user-facings DX, and try to ease out the implementation details. For example, users could keep using the semantic `import/order` without ever knowing the underlying plugin has migrated twice to `eslint-plugin-i` and then to `eslint-plugin-import-x`. User are also not forced to migrate to the implicit `i/order` halfway only because we swapped the implementation to a fork.
|
|
253
|
+
>
|
|
254
|
+
> That said, it's probably still not a good idea. You might not want to doing this if you are maintaining your own eslint config.
|
|
255
|
+
>
|
|
256
|
+
> Feel free to open issues if you want to combine this config with some other config presets but faced naming collisions. I am happy to figure out a way to make them work. But at this moment I have no plan to revert the renaming.
|
|
257
|
+
|
|
258
|
+
This preset will automatically rename the plugins also for your custom configs. You can use the original prefix to override the rules directly.
|
|
259
|
+
|
|
260
|
+
<details>
|
|
261
|
+
<summary>Change back to original prefix</summary>
|
|
262
|
+
|
|
263
|
+
If you really want to use the original prefix, you can revert the plugin renaming by:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import config from '@ghettoddos/eslint-config'
|
|
267
|
+
|
|
268
|
+
export default config().renamePlugins({
|
|
269
|
+
ts: '@typescript-eslint',
|
|
270
|
+
yaml: 'yml',
|
|
271
|
+
node: 'n',
|
|
272
|
+
// ...
|
|
273
|
+
})
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
</details>
|
|
277
|
+
|
|
278
|
+
### Rules Overrides
|
|
279
|
+
|
|
280
|
+
Certain rules would only be enabled in specific files, for example, `ts/*` rules would only be enabled in `.ts` files. If you want to override the rules, you need to specify the file extension:
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
// eslint.config.js
|
|
284
|
+
import config from '@ghettoddos/eslint-config'
|
|
285
|
+
|
|
286
|
+
export default config(
|
|
287
|
+
{
|
|
288
|
+
typescript: true,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
// Without `files`, they are general rules for all files
|
|
292
|
+
rules: {
|
|
293
|
+
'style/semi': ['error', 'never'],
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
)
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
We also provided the `overrides` options in each integration to make it easier:
|
|
300
|
+
|
|
301
|
+
```js
|
|
302
|
+
// eslint.config.js
|
|
303
|
+
import config from '@ghettoddos/eslint-config'
|
|
304
|
+
|
|
305
|
+
export default config({
|
|
306
|
+
typescript: {
|
|
307
|
+
overrides: {
|
|
308
|
+
'ts/consistent-type-definitions': ['error', 'interface'],
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
yaml: {
|
|
312
|
+
overrides: {
|
|
313
|
+
// ...
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
})
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Config Composer
|
|
320
|
+
|
|
321
|
+
The factory function `config()` 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.
|
|
322
|
+
|
|
323
|
+
```js
|
|
324
|
+
// eslint.config.js
|
|
325
|
+
import config from '@ghettoddos/eslint-config'
|
|
326
|
+
|
|
327
|
+
export default config()
|
|
328
|
+
.prepend
|
|
329
|
+
// some configs before the main config
|
|
330
|
+
()
|
|
331
|
+
// overrides any named configs
|
|
332
|
+
.override('imports', {
|
|
333
|
+
rules: {
|
|
334
|
+
'import/order': ['error', { 'newlines-between': 'always' }],
|
|
335
|
+
},
|
|
336
|
+
})
|
|
337
|
+
// rename plugin prefixes
|
|
338
|
+
.renamePlugins({
|
|
339
|
+
'old-prefix': 'new-prefix',
|
|
340
|
+
// ...
|
|
341
|
+
})
|
|
342
|
+
// ...
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### React
|
|
346
|
+
|
|
347
|
+
React support is detected automatically by checking if `react` is installed in your project. You can also explicitly enable/disable it:
|
|
348
|
+
|
|
349
|
+
```js
|
|
350
|
+
// eslint.config.js
|
|
351
|
+
import config from '@ghettoddos/eslint-config'
|
|
352
|
+
|
|
353
|
+
export default config({
|
|
354
|
+
react: true,
|
|
355
|
+
})
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Optional Configs
|
|
359
|
+
|
|
360
|
+
We provide some optional configs for specific use cases, that we don't include their dependencies by default.
|
|
361
|
+
|
|
362
|
+
#### Formatters
|
|
363
|
+
|
|
364
|
+
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).
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
// eslint.config.js
|
|
368
|
+
import config from '@ghettoddos/eslint-config'
|
|
369
|
+
|
|
370
|
+
export default config({
|
|
371
|
+
formatters: {
|
|
372
|
+
/**
|
|
373
|
+
* Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue
|
|
374
|
+
* By default uses Prettier
|
|
375
|
+
*/
|
|
376
|
+
css: true,
|
|
377
|
+
/**
|
|
378
|
+
* Format HTML files
|
|
379
|
+
* By default uses Prettier
|
|
380
|
+
*/
|
|
381
|
+
html: true,
|
|
382
|
+
/**
|
|
383
|
+
* Format Markdown files
|
|
384
|
+
* By default uses Prettier
|
|
385
|
+
*/
|
|
386
|
+
markdown: 'prettier',
|
|
387
|
+
},
|
|
388
|
+
})
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
npm i -D eslint-plugin-format
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### UnoCSS
|
|
398
|
+
|
|
399
|
+
To enable UnoCSS support, you need to explicitly turn it on:
|
|
400
|
+
|
|
401
|
+
```js
|
|
402
|
+
// eslint.config.js
|
|
403
|
+
import config from '@ghettoddos/eslint-config'
|
|
404
|
+
|
|
405
|
+
export default config({
|
|
406
|
+
unocss: true,
|
|
407
|
+
})
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
npm i -D @unocss/eslint-plugin
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Type Aware Rules
|
|
417
|
+
|
|
418
|
+
You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
|
|
419
|
+
|
|
420
|
+
```js
|
|
421
|
+
// eslint.config.js
|
|
422
|
+
import config from '@ghettoddos/eslint-config'
|
|
423
|
+
|
|
424
|
+
export default config({
|
|
425
|
+
typescript: {
|
|
426
|
+
tsconfigPath: 'tsconfig.json',
|
|
427
|
+
},
|
|
428
|
+
})
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### Editor Specific Disables
|
|
432
|
+
|
|
433
|
+
Auto-fixing for the following rules are disabled when ESLint is running in a code editor:
|
|
434
|
+
|
|
435
|
+
- [`prefer-const`](https://eslint.org/docs/rules/prefer-const)
|
|
436
|
+
- [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports)
|
|
437
|
+
|
|
438
|
+
They are no disabled, but made non-fixable using [this helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix).
|
|
439
|
+
|
|
440
|
+
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:
|
|
441
|
+
|
|
442
|
+
```js
|
|
443
|
+
// eslint.config.js
|
|
444
|
+
import config from '@ghettoddos/eslint-config'
|
|
445
|
+
|
|
446
|
+
export default config({
|
|
447
|
+
isInEditor: false,
|
|
448
|
+
})
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Lint Staged
|
|
452
|
+
|
|
453
|
+
If you want to apply lint and auto-fix before every commit, you can add the following to your `package.json`:
|
|
454
|
+
|
|
455
|
+
```json
|
|
456
|
+
{
|
|
457
|
+
"simple-git-hooks": {
|
|
458
|
+
"pre-commit": "pnpm lint-staged"
|
|
459
|
+
},
|
|
460
|
+
"lint-staged": {
|
|
461
|
+
"*": "eslint --fix"
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
and then
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
npm i -D lint-staged simple-git-hooks
|
|
470
|
+
|
|
471
|
+
// to active the hooks
|
|
472
|
+
npx simple-git-hooks
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## View what rules are enabled
|
|
476
|
+
|
|
477
|
+
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)
|
|
478
|
+
|
|
479
|
+
Go to your project root that contains `eslint.config.js` and run:
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
npx @eslint/config-inspector
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
## Versioning Policy
|
|
486
|
+
|
|
487
|
+
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.
|
|
488
|
+
|
|
489
|
+
### Changes Considered as Breaking Changes
|
|
490
|
+
|
|
491
|
+
- Node.js version requirement changes
|
|
492
|
+
- Huge refactors that might break the config
|
|
493
|
+
- Plugins made major changes that might break the config
|
|
494
|
+
- Changes that might affect most of the codebases
|
|
495
|
+
|
|
496
|
+
### Changes Considered as Non-breaking Changes
|
|
497
|
+
|
|
498
|
+
- Enable/disable rules and plugins (that might become stricter)
|
|
499
|
+
- Rules options changes
|
|
500
|
+
- Version bumps of dependencies
|
|
501
|
+
|
|
502
|
+
## FAQ
|
|
503
|
+
|
|
504
|
+
### Prettier?
|
|
505
|
+
|
|
506
|
+
[Why I don't use Prettier](https://antfu.me/posts/why-not-prettier)
|
|
507
|
+
|
|
508
|
+
Well, you can still use Prettier to format files that are not supported well by ESLint yet, such as `.css`, `.html`, etc. See [formatters](#formatters) for more details.
|
|
509
|
+
|
|
510
|
+
### How to format CSS?
|
|
511
|
+
|
|
512
|
+
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.
|
|
513
|
+
|
|
514
|
+
### I prefer XXX...
|
|
515
|
+
|
|
516
|
+
Sure, you can configure and override rules locally in your project to fit your needs. If that still does not work for you, you can always fork this repo and maintain your own.
|
|
517
|
+
|
|
518
|
+
## Check Also
|
|
519
|
+
|
|
520
|
+
- [antfu/eslint-config](https://github.com/antfu/eslint-config) - Original repo
|
|
521
|
+
|
|
522
|
+
## License
|
|
523
|
+
|
|
524
|
+
[MIT](./LICENSE) License © 2025-PRESENT [ghettoDdOS](https://github.com/ghettoDdOS)
|