@moso/eslint-config 1.0.4 → 2.0.2
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 +24 -16
- package/README.md +347 -132
- package/dist/index.d.mts +15188 -0
- package/dist/index.mjs +15146 -0
- package/package.json +119 -61
- package/dist/index.d.ts +0 -16215
- package/dist/index.js +0 -1975
package/README.md
CHANGED
|
@@ -4,28 +4,230 @@
|
|
|
4
4
|
|
|
5
5
|
Flat ESLint config for JavaScript, TypeScript, Vue, React, and more.
|
|
6
6
|
|
|
7
|
-
[Legacy Version](https://github.com/moso/eslint-config/tree/legacy).
|
|
8
|
-
|
|
9
7
|
## Features
|
|
10
8
|
|
|
11
9
|
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) with reasonable but opinionated defaults
|
|
12
|
-
-
|
|
10
|
+
- [Stylistic](https://eslint.style) with single quotes, semi enabled, sorted imports, dangling commas,
|
|
13
11
|
- Aimed to be used without Prettier
|
|
14
12
|
- Designed to work with JSX, TypeScript, Vue, and React out of the box
|
|
15
|
-
- [
|
|
16
|
-
- Lints for
|
|
13
|
+
- Applies [Functional](https://github.com/eslint-functional/eslint-plugin-functional) and [Perfectionist](https://perfectionist.dev) by default
|
|
14
|
+
- Lints for JSDoc, JSON, RegEx, and YAML
|
|
15
|
+
- Every config can be enabled/disabled
|
|
17
16
|
- Respects `.gitignore` by default
|
|
18
|
-
- Requires ESLint v9.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
- Requires ESLint v9.10.0+
|
|
18
|
+
|
|
19
|
+
## Configs
|
|
20
|
+
|
|
21
|
+
This section contains a list of the plugins used in the named configs that ships with this shareable config.
|
|
22
|
+
|
|
23
|
+
\- ✅ Enabled by default
|
|
24
|
+
\- ☑️ Enabled by auto-detect
|
|
25
|
+
\- 🌟 Enabled unless `lessOpinionated: false`
|
|
26
|
+
\- 🟨 Can be enabled manually
|
|
27
|
+
\- 🎨 Stylistic rules enabled
|
|
28
|
+
\- 💭 Type-aware rules available by setting the path to your `tsconfig.json`
|
|
29
|
+
\- ℹ️ Accessibility rules available with `a11y: true`
|
|
30
|
+
|
|
31
|
+
<table>
|
|
32
|
+
<thead>
|
|
33
|
+
<tr>
|
|
34
|
+
<th align="left" width="1200" style="max-width: 100%">Plugin</th>
|
|
35
|
+
<th>💼</th>
|
|
36
|
+
<th>🎨</th>
|
|
37
|
+
<th>💭</th>
|
|
38
|
+
</tr>
|
|
39
|
+
</thead>
|
|
40
|
+
<tbody>
|
|
41
|
+
<tr>
|
|
42
|
+
<td>
|
|
43
|
+
<details><summary><strong>ESLint Comments</strong></summary>
|
|
44
|
+
|
|
45
|
+
[`eslint-plugin-eslint-comments`](https://eslint-community.github.io/eslint-plugin-eslint-comments)
|
|
24
46
|
|
|
25
|
-
>
|
|
26
|
-
>
|
|
27
|
-
>
|
|
28
|
-
>
|
|
47
|
+
</details>
|
|
48
|
+
</td>
|
|
49
|
+
<td valign="top">✅</td>
|
|
50
|
+
<td valign="top"></td>
|
|
51
|
+
<td valign="top"></td>
|
|
52
|
+
</tr>
|
|
53
|
+
<tr>
|
|
54
|
+
<td valign="top">
|
|
55
|
+
<details><summary><strong>Functional</strong></summary>
|
|
56
|
+
|
|
57
|
+
[`eslint-plugin-functional`](https://github.com/eslint-functional/eslint-plugin-functional)
|
|
58
|
+
|
|
59
|
+
</details></td>
|
|
60
|
+
<td valign="top">✅</td>
|
|
61
|
+
<td valign="top">🎨</td>
|
|
62
|
+
<td valign="top"></td>
|
|
63
|
+
</tr>
|
|
64
|
+
<tr>
|
|
65
|
+
<td valign="top">
|
|
66
|
+
<details><summary><strong>Import Lite</strong></summary>
|
|
67
|
+
|
|
68
|
+
[`eslint-plugin-import-lite`](https://github.com/9romise/eslint-plugin-import-lite)
|
|
69
|
+
|
|
70
|
+
</details></td>
|
|
71
|
+
<td valign="top">✅</td>
|
|
72
|
+
<td valign="top">🎨</td>
|
|
73
|
+
<td valign="top"></td>
|
|
74
|
+
</tr>
|
|
75
|
+
<tr>
|
|
76
|
+
<td valign="top">
|
|
77
|
+
<details><summary><strong>JavaScript</strong></summary>
|
|
78
|
+
|
|
79
|
+
[`@eslint/js`](https://eslint.org), [`eslint-plugin-de-morgan`](https://github.com/azat-io/eslint-plugin-de-morgan), [`eslint-plugin-unused-imports`](https://github.com/sweepline/eslint-plugin-unused-imports)
|
|
80
|
+
|
|
81
|
+
</details></td>
|
|
82
|
+
<td valign="top">✅</td>
|
|
83
|
+
<td valign="top"></td>
|
|
84
|
+
<td valign="top"></td>
|
|
85
|
+
</tr>
|
|
86
|
+
<tr>
|
|
87
|
+
<td valign="top">
|
|
88
|
+
<details><summary><strong>JSDoc</strong></summary>
|
|
89
|
+
|
|
90
|
+
[`eslint-plugin-jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc)
|
|
91
|
+
|
|
92
|
+
</details></td>
|
|
93
|
+
<td valign="top">🟨</td>
|
|
94
|
+
<td valign="top">🎨</td>
|
|
95
|
+
<td valign="top"></td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td valign="top">
|
|
99
|
+
<details><summary><strong>JSONC</strong></summary>
|
|
100
|
+
|
|
101
|
+
[`eslint-plugin-jsonc`](https://ota-meshi.github.io/eslint-plugin-jsonc)
|
|
102
|
+
|
|
103
|
+
</details></td>
|
|
104
|
+
<td valign="top">🟨</td>
|
|
105
|
+
<td valign="top">🎨</td>
|
|
106
|
+
<td valign="top"></td>
|
|
107
|
+
</tr>
|
|
108
|
+
<tr>
|
|
109
|
+
<td valign="top">
|
|
110
|
+
<details><summary><strong>Node</strong></summary>
|
|
111
|
+
|
|
112
|
+
[`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n)
|
|
113
|
+
|
|
114
|
+
</details></td>
|
|
115
|
+
<td valign="top">✅</td>
|
|
116
|
+
<td valign="top"></td>
|
|
117
|
+
<td valign="top"></td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td valign="top">
|
|
121
|
+
<details><summary><strong>Perfectionist</strong></summary>
|
|
122
|
+
|
|
123
|
+
[`eslint-plugin-perfectionist`](https://perfectionist.dev)
|
|
124
|
+
|
|
125
|
+
</details></td>
|
|
126
|
+
<td valign="top">🌟</td>
|
|
127
|
+
<td valign="top"></td>
|
|
128
|
+
<td valign="top"></td>
|
|
129
|
+
</tr>
|
|
130
|
+
<tr>
|
|
131
|
+
<td valign="top">
|
|
132
|
+
<details><summary><strong>Promises</strong></summary>
|
|
133
|
+
|
|
134
|
+
[`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise)
|
|
135
|
+
|
|
136
|
+
</details></td>
|
|
137
|
+
<td valign="top">✅</td>
|
|
138
|
+
<td valign="top"></td>
|
|
139
|
+
<td valign="top"></td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td valign="top">
|
|
143
|
+
<details><summary><strong>React</strong></summary>
|
|
144
|
+
|
|
145
|
+
[`@eslint-react`](https://eslint-react.xyz), [`@eslint-react/dom`](https://eslint-react.xyz), [`@eslint-react/hooks-extra`](https://eslint-react.xyz), [`@eslint-react/naming-convention`](https://eslint-react.xyz), [`@eslint-react/web-api`](https://eslint-react.xyz), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), [`eslint-plugin-react-you-might-not-need-an-effect`](https://github.com/NickvanDyke/eslint-plugin-react-you-might-not-need-an-effect), [`eslint-plugin-jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
|
|
146
|
+
|
|
147
|
+
</details></td>
|
|
148
|
+
<td valign="top">☑️ℹ️</td>
|
|
149
|
+
<td valign="top">🎨</td>
|
|
150
|
+
<td valign="top">💭</td>
|
|
151
|
+
</tr>
|
|
152
|
+
<tr>
|
|
153
|
+
<td valign="top">
|
|
154
|
+
<details><summary><strong>RegExp</strong></summary>
|
|
155
|
+
|
|
156
|
+
[`eslint-plugin-regexp`](https://ota-meshi.github.io/eslint-plugin-regexp)
|
|
157
|
+
|
|
158
|
+
</details></td>
|
|
159
|
+
<td valign="top">✅</td>
|
|
160
|
+
<td valign="top"></td>
|
|
161
|
+
<td valign="top"></td>
|
|
162
|
+
</tr>
|
|
163
|
+
<tr>
|
|
164
|
+
<td valign="top">
|
|
165
|
+
<details><summary><strong>Stylistic</strong></summary>
|
|
166
|
+
|
|
167
|
+
[`@stylistic/eslint-plugin`](https://eslint.style)
|
|
168
|
+
|
|
169
|
+
</details></td>
|
|
170
|
+
<td valign="top">🌟</td>
|
|
171
|
+
<td valign="top">🎨</td>
|
|
172
|
+
<td valign="top"></td>
|
|
173
|
+
</tr>
|
|
174
|
+
<tr>
|
|
175
|
+
<td valign="top">
|
|
176
|
+
<details><summary><strong>Test</strong></summary>
|
|
177
|
+
|
|
178
|
+
[`@vitest/eslint-plugin`](https://github.com/vitest-dev/eslint-plugin-vitest), [`eslint-plugin-no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
|
|
179
|
+
|
|
180
|
+
</details></td>
|
|
181
|
+
<td valign="top">🟨</td>
|
|
182
|
+
<td valign="top"></td>
|
|
183
|
+
<td valign="top"></td>
|
|
184
|
+
</tr>
|
|
185
|
+
<tr>
|
|
186
|
+
<td valign="top">
|
|
187
|
+
<details><summary><strong>TypeScript</strong></summary>
|
|
188
|
+
|
|
189
|
+
[`@typescript-eslint`](https://typescript-eslint.io), [`eslint-plugin-erasable-syntax-only`](https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only)
|
|
190
|
+
|
|
191
|
+
</details></td>
|
|
192
|
+
<td valign="top">☑️</td>
|
|
193
|
+
<td valign="top">🎨</td>
|
|
194
|
+
<td valign="top">💭</td>
|
|
195
|
+
</tr>
|
|
196
|
+
<tr>
|
|
197
|
+
<td valign="top">
|
|
198
|
+
<details><summary><strong>Unicorn</strong></summary>
|
|
199
|
+
|
|
200
|
+
[`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn)
|
|
201
|
+
|
|
202
|
+
</details></td>
|
|
203
|
+
<td valign="top">✅</td>
|
|
204
|
+
<td valign="top"></td>
|
|
205
|
+
<td valign="top"></td>
|
|
206
|
+
</tr>
|
|
207
|
+
<tr>
|
|
208
|
+
<td valign="top">
|
|
209
|
+
<details><summary><strong>Vue</strong></summary>
|
|
210
|
+
|
|
211
|
+
[`eslint-plugin-vue`](https://eslint.vuejs.org), [`eslint-plugin-vuejs-accessibility`](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility)
|
|
212
|
+
|
|
213
|
+
</details></td>
|
|
214
|
+
<td valign="top">☑️ℹ️</td>
|
|
215
|
+
<td valign="top">🎨</td>
|
|
216
|
+
<td valign="top">💭</td>
|
|
217
|
+
</tr>
|
|
218
|
+
<tr>
|
|
219
|
+
<td valign="top">
|
|
220
|
+
<details><summary><strong>YAML</strong></summary>
|
|
221
|
+
|
|
222
|
+
[`eslint-plugin-yml`](https://ota-meshi.github.io/eslint-plugin-yml)
|
|
223
|
+
|
|
224
|
+
</details></td>
|
|
225
|
+
<td valign="top">🟨</td>
|
|
226
|
+
<td valign="top">🎨</td>
|
|
227
|
+
<td valign="top"></td>
|
|
228
|
+
</tr>
|
|
229
|
+
</tbody>
|
|
230
|
+
</table>
|
|
29
231
|
|
|
30
232
|
## Usage
|
|
31
233
|
|
|
@@ -34,7 +236,7 @@ Flat ESLint config for JavaScript, TypeScript, Vue, React, and more.
|
|
|
34
236
|
> I like to use [Bun](https://bun.sh) because it's hella fast. Thus all the install instructions are with Bun. If you use something else, check the syntax with your favorite package manager.
|
|
35
237
|
|
|
36
238
|
```bash
|
|
37
|
-
bun add -
|
|
239
|
+
bun add -d eslint @moso/eslint-config
|
|
38
240
|
```
|
|
39
241
|
|
|
40
242
|
Create `eslint.config.js` in the root of your project:
|
|
@@ -81,7 +283,6 @@ export default moso(
|
|
|
81
283
|
|
|
82
284
|
</details>
|
|
83
285
|
|
|
84
|
-
|
|
85
286
|
### Add script for package.json
|
|
86
287
|
|
|
87
288
|
For example:
|
|
@@ -147,7 +348,7 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
147
348
|
|
|
148
349
|
## Customization
|
|
149
350
|
|
|
150
|
-
Since v1.0, this config has been migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition. And speed!
|
|
351
|
+
Since v1.0.0, this config has been migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition. And speed!
|
|
151
352
|
|
|
152
353
|
Normally you only need to import the `moso` preset:
|
|
153
354
|
|
|
@@ -158,42 +359,42 @@ import moso from '@moso/eslint-config';
|
|
|
158
359
|
export default moso();
|
|
159
360
|
```
|
|
160
361
|
|
|
161
|
-
|
|
362
|
+
### Configuration Options
|
|
363
|
+
|
|
364
|
+
Configure integrations by passing options to the main function:
|
|
162
365
|
|
|
163
366
|
```js
|
|
164
367
|
// eslint.config.js
|
|
165
368
|
import moso from '@moso/eslint-config';
|
|
166
369
|
|
|
167
370
|
export default moso({
|
|
168
|
-
//
|
|
169
|
-
stylistic: false,
|
|
170
|
-
|
|
171
|
-
// Or customize the stylistic rules
|
|
371
|
+
// Stylistic rules (enabled by default)
|
|
372
|
+
stylistic: false, // disable entirely
|
|
172
373
|
stylistic: {
|
|
173
374
|
indent: 2, // 4, or 'tab'
|
|
174
375
|
quotes: 'single', // or 'double'
|
|
175
376
|
},
|
|
176
377
|
|
|
177
|
-
//
|
|
378
|
+
// Auto-detected, or enable explicitly
|
|
178
379
|
typescript: true,
|
|
179
380
|
react: true,
|
|
180
381
|
vue: true,
|
|
181
382
|
|
|
182
|
-
//
|
|
383
|
+
// File format support
|
|
183
384
|
jsonc: false,
|
|
184
385
|
yaml: false,
|
|
185
386
|
|
|
186
|
-
//
|
|
387
|
+
// Replaces .eslintignore (no longer supported)
|
|
187
388
|
ignores: [
|
|
188
389
|
'**/dist',
|
|
189
|
-
|
|
390
|
+
'**/node_modules',
|
|
190
391
|
],
|
|
191
392
|
});
|
|
192
393
|
```
|
|
193
394
|
|
|
194
|
-
### Rules
|
|
395
|
+
### Overriding Rules
|
|
195
396
|
|
|
196
|
-
|
|
397
|
+
Pass additional flat config objects as arguments. Rules are scoped to specific file types:
|
|
197
398
|
|
|
198
399
|
```js
|
|
199
400
|
// eslint.config.js
|
|
@@ -201,55 +402,54 @@ import moso from '@moso/eslint-config';
|
|
|
201
402
|
|
|
202
403
|
export default moso(
|
|
203
404
|
{
|
|
204
|
-
// First argument
|
|
405
|
+
// First argument: moso config options
|
|
205
406
|
vue: true,
|
|
206
407
|
typescript: true,
|
|
207
408
|
},
|
|
208
409
|
{
|
|
209
|
-
//
|
|
210
|
-
// You can have as many as you want here.
|
|
211
|
-
|
|
212
|
-
// Example of overriding vue/* rules on `.vue`-files using the Vue file glob:
|
|
410
|
+
// Additional arguments: standard ESLint flat configs
|
|
213
411
|
files: ['**/*.vue'],
|
|
214
412
|
rules: {
|
|
215
413
|
'vue/multi-word-component-names': ['error', { ignores: [] }],
|
|
216
414
|
},
|
|
217
415
|
},
|
|
218
416
|
{
|
|
219
|
-
|
|
417
|
+
// You can pass multiple config objects
|
|
418
|
+
files: ['**/*.ts'],
|
|
419
|
+
rules: {
|
|
420
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
421
|
+
},
|
|
220
422
|
},
|
|
221
423
|
);
|
|
222
424
|
```
|
|
223
425
|
|
|
224
|
-
|
|
426
|
+
### Advanced Composition
|
|
427
|
+
|
|
428
|
+
The config returns a `FlatConfigComposer` object from [`eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer), enabling chainable methods:
|
|
225
429
|
|
|
226
430
|
```js
|
|
227
431
|
// eslint.config.js
|
|
228
432
|
import moso from '@moso/eslint-config';
|
|
229
433
|
|
|
230
434
|
export default moso()
|
|
231
|
-
.prepend(
|
|
435
|
+
.prepend({
|
|
232
436
|
// Configs before the main config
|
|
233
|
-
)
|
|
234
|
-
.override(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
{
|
|
238
|
-
rules: {
|
|
239
|
-
'no-var': 'off',
|
|
240
|
-
},
|
|
437
|
+
})
|
|
438
|
+
.override('moso/javascript/rules', {
|
|
439
|
+
rules: {
|
|
440
|
+
'no-var': 'off',
|
|
241
441
|
},
|
|
242
|
-
)
|
|
243
|
-
// You can also remove rules entirely
|
|
442
|
+
})
|
|
244
443
|
.removeRules(
|
|
245
|
-
|
|
444
|
+
'no-console',
|
|
445
|
+
'no-debugger',
|
|
246
446
|
);
|
|
247
447
|
```
|
|
248
448
|
|
|
249
449
|
<details>
|
|
250
|
-
<summary>
|
|
450
|
+
<summary>Fine-grained config imports</summary>
|
|
251
451
|
|
|
252
|
-
You can import
|
|
452
|
+
You can import and compose individual configs directly. Only use this if you need granular control:
|
|
253
453
|
|
|
254
454
|
```js
|
|
255
455
|
import {
|
|
@@ -271,17 +471,17 @@ import {
|
|
|
271
471
|
} from '@moso/eslint-config';
|
|
272
472
|
|
|
273
473
|
export default combine(
|
|
474
|
+
comments(),
|
|
274
475
|
ignores(),
|
|
476
|
+
imports(),
|
|
275
477
|
javascript(/* options */),
|
|
276
|
-
comments(),
|
|
277
|
-
node(),
|
|
278
478
|
jsdoc(),
|
|
279
|
-
|
|
280
|
-
|
|
479
|
+
jsonc(),
|
|
480
|
+
node(),
|
|
481
|
+
stylistic(/* options */),
|
|
281
482
|
typescript(/* options */),
|
|
282
|
-
|
|
483
|
+
unicorn(),
|
|
283
484
|
vue(/* options */),
|
|
284
|
-
jsonc(),
|
|
285
485
|
yaml(),
|
|
286
486
|
);
|
|
287
487
|
```
|
|
@@ -290,112 +490,101 @@ export default combine(
|
|
|
290
490
|
|
|
291
491
|
## Optional configs
|
|
292
492
|
|
|
293
|
-
|
|
493
|
+
Framework support is auto-detected based on installed packages, but can be enabled explicitly. Dependencies are not bundled and will be prompted for installation.
|
|
494
|
+
|
|
495
|
+
### React
|
|
496
|
+
|
|
497
|
+
Auto-detected if you have Gatsby, Next.js, Nextra, React, or Remix installed. Enable explicitly:
|
|
294
498
|
|
|
295
499
|
```js
|
|
296
500
|
// eslint.config.js
|
|
297
501
|
import moso from '@moso/eslint-config';
|
|
298
502
|
|
|
299
503
|
export default moso({
|
|
300
|
-
// Enable TypeScript
|
|
301
|
-
typescript: true,
|
|
302
|
-
|
|
303
|
-
// Enable Vue
|
|
304
|
-
vue: true,
|
|
305
|
-
|
|
306
|
-
// Enable React
|
|
307
504
|
react: true,
|
|
308
505
|
});
|
|
309
506
|
```
|
|
310
507
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
## Optional rules
|
|
508
|
+
Install dependencies when prompted, or manually:
|
|
314
509
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
510
|
+
```bash
|
|
511
|
+
bun add --dev @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-react-you-might-not-need-an-effect
|
|
512
|
+
```
|
|
318
513
|
|
|
319
|
-
|
|
514
|
+
### Vue
|
|
320
515
|
|
|
321
|
-
|
|
516
|
+
Auto-detected if you have Nuxt, VitePress, or Vue installed. Enable explicitly:
|
|
322
517
|
|
|
323
518
|
```js
|
|
324
519
|
// eslint.config.js
|
|
325
520
|
import moso from '@moso/eslint-config';
|
|
326
521
|
|
|
327
|
-
export default moso(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
perfectionist: {
|
|
331
|
-
overrides: {
|
|
332
|
-
'perfectionist/sort-imports': 'off',
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
// Or adding your own rules
|
|
338
|
-
rules: {
|
|
339
|
-
'perfectionist/sort-enums': ['error', { type: 'natural', order: 'asc', locales: 'da-DK' }],
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
);
|
|
522
|
+
export default moso({
|
|
523
|
+
vue: true,
|
|
524
|
+
});
|
|
343
525
|
```
|
|
344
526
|
|
|
345
|
-
|
|
527
|
+
Install dependencies when prompted, or manually:
|
|
346
528
|
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
const objectWantedToSort = {
|
|
350
|
-
a: 2,
|
|
351
|
-
b: 1,
|
|
352
|
-
c: 3,
|
|
353
|
-
};
|
|
529
|
+
```bash
|
|
530
|
+
bun add --dev eslint-plugin-vue vue-eslint-parser eslint-processor-vue-blocks eslint-merge-processors
|
|
354
531
|
```
|
|
355
532
|
|
|
356
|
-
**Note**: If you
|
|
357
|
-
|
|
358
|
-
#### Individually
|
|
533
|
+
**Note**: Since Vue 2 has [reached EOL](https://v2.vuejs.org/eol), this config does not support Vue 2. If you need to support for Vue 2, you'll need to disable the imported configs from Vue 3, and replace them with the Vue 2 ones. You can see an inspiring example on [`eslint-plugin-vue`](https://eslint.vuejs.org/user-guide/#usage). I recommend upgrading to Vue 3 if possible.
|
|
359
534
|
|
|
360
|
-
|
|
361
|
-
// eslint.config.js
|
|
362
|
-
import moso from '@moso/eslint-config';
|
|
535
|
+
### Typed Linting
|
|
363
536
|
|
|
364
|
-
|
|
365
|
-
// Disable Perfectionist
|
|
366
|
-
perfectionist: false,
|
|
367
|
-
});
|
|
368
|
-
```
|
|
537
|
+
You can optionally enable [typed linting](https://typescript-eslint.io/getting-started/typed-linting). These are also known as "rules that require types", or simply "type-aware rules". This enables for much deeper insight into your code.
|
|
369
538
|
|
|
370
|
-
|
|
539
|
+
You enable them by passing the path of your `tsconfig.json` to the `projectRoot` option.
|
|
371
540
|
|
|
372
|
-
|
|
541
|
+
> [!WARNING]
|
|
542
|
+
> Enabling these rules will come with a slight performance cost, [explained here](https://typescript-eslint.io/getting-started/typed-linting/#performance).
|
|
543
|
+
>
|
|
544
|
+
> To make things even more complicated, if you have enabled typed linting but disabled [`@stylistic`](https://eslint.style), it will also disable the type-aware rules [considered stylistic](https://typescript-eslint.io/rules/?=stylistic-typeInformation).
|
|
373
545
|
|
|
374
546
|
```js
|
|
375
547
|
// eslint.config.js
|
|
376
548
|
import moso from '@moso/eslint-config';
|
|
377
549
|
|
|
378
|
-
export default moso(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
550
|
+
export default moso(
|
|
551
|
+
{
|
|
552
|
+
projectRoot: import.meta.dirname,
|
|
553
|
+
|
|
554
|
+
// If you wish to override any of these rules, use `overridesTypeAware`:
|
|
555
|
+
typescript: {
|
|
556
|
+
overridesTypeAware: {
|
|
557
|
+
'@typescript-eslint/no-deprecated': 'off',
|
|
558
|
+
},
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
);
|
|
382
562
|
```
|
|
383
563
|
|
|
384
|
-
|
|
564
|
+
> [!NOTE]
|
|
565
|
+
> TypeScript will still be auto-detected if you have the `typescript`-package installed, and any non-type-aware `@typescript-eslint`-rules will still be applied. *Typed Linting* is considered as an extra option.
|
|
385
566
|
|
|
386
|
-
|
|
567
|
+
#### Disable type-aware
|
|
387
568
|
|
|
388
|
-
|
|
569
|
+
Optionally, you can even disable type-aware rules on certain file extensions, or even specific files:
|
|
389
570
|
|
|
390
571
|
```js
|
|
391
572
|
// eslint.config.js
|
|
392
573
|
import moso from '@moso/eslint-config';
|
|
393
574
|
|
|
394
|
-
export default moso(
|
|
395
|
-
|
|
396
|
-
|
|
575
|
+
export default moso(
|
|
576
|
+
{
|
|
577
|
+
projectRoot: import.meta.dirname,
|
|
397
578
|
},
|
|
398
|
-
|
|
579
|
+
{
|
|
580
|
+
files: ['**/*.{js,jsx}'],
|
|
581
|
+
disableTypeAware: true,
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
files: ['**/components/User.jsx'],
|
|
585
|
+
disableTypeAware: true,
|
|
586
|
+
},
|
|
587
|
+
);
|
|
399
588
|
```
|
|
400
589
|
|
|
401
590
|
### Editor specific non-fixes
|
|
@@ -406,7 +595,7 @@ Some rules are deemed as 'non-fixable' when inside your editor with ESLint integ
|
|
|
406
595
|
- [`unused-imports/no-unused-imports`](https://github.com/sweepline/eslint-plugin-unused-imports)
|
|
407
596
|
- [`vitest/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
|
|
408
597
|
|
|
409
|
-
|
|
598
|
+
Before v1.0.0, they used to be hard disabled. But with a [helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix), they are now just marked as 'non-fixable'. They are re-applied when you're linting through a terminal, or by using [Lint Staged](#lint-staged).
|
|
410
599
|
|
|
411
600
|
```js
|
|
412
601
|
// eslint.config.js
|
|
@@ -453,7 +642,7 @@ bunx @eslint/config-inspector
|
|
|
453
642
|
|
|
454
643
|
## FAQ
|
|
455
644
|
|
|
456
|
-
### I want it less
|
|
645
|
+
### I want it less opinionated
|
|
457
646
|
|
|
458
647
|
No problem. I've extracted the things that I've deemed *very opinionated* in each integration, and made a setting that helps you disable all of it in one go.
|
|
459
648
|
|
|
@@ -466,6 +655,21 @@ export default moso({
|
|
|
466
655
|
});
|
|
467
656
|
```
|
|
468
657
|
|
|
658
|
+
> [!NOTE]
|
|
659
|
+
> The above will also disable `functional` and `perfectionist` completely. If you want to keep these enabled, you'll have to re-enable them explicitly, as demonstrated below
|
|
660
|
+
|
|
661
|
+
```js
|
|
662
|
+
{
|
|
663
|
+
functional: true, // will default to 'lite' enforcement
|
|
664
|
+
|
|
665
|
+
// Optionally change the `functionalEnforcement`:
|
|
666
|
+
functionalEnforcement: 'recommended',
|
|
667
|
+
|
|
668
|
+
// Re-enable `perfectionist`
|
|
669
|
+
perfectionist: true,
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
469
673
|
### Prettier? dprint?
|
|
470
674
|
|
|
471
675
|
You can still use these to format files that aren't linted with this config, however, I strongly recommend you only format your code with ESLint, as Pretter and other AST-reading-then-reprint projects tend to ignore stuff like the original line breaks and might also cause inconsistent diffs when commiting code.
|
|
@@ -474,25 +678,36 @@ You can still use these to format files that aren't linted with this config, how
|
|
|
474
678
|
|
|
475
679
|
You will need to install and configure [`stylelint`](https://stylelint.io) yourself, unfortunately.
|
|
476
680
|
|
|
681
|
+
I am actively considering adding linting support for TailwindCSS, however.
|
|
682
|
+
|
|
477
683
|
### I prefer `this` or `that` rule
|
|
478
684
|
|
|
479
|
-
|
|
685
|
+
No worries, you can always override the rules locally in your project to fit your needs. If that doesn't cut it, you're welcome to fork this project and maintain your own config.
|
|
480
686
|
|
|
481
687
|
## Inspiration
|
|
482
688
|
|
|
483
|
-
This
|
|
689
|
+
This ESLint config is heavily inspired by (and uses some of the same logic of):
|
|
690
|
+
|
|
691
|
+
\- [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
692
|
+
\- [@rebeccastevens/eslint-config](https://github.com/RebeccaStevens/eslint-config-rebeccastevens)
|
|
693
|
+
\- [@eslint-sukka/eslint-config](https://github.com/SukkaW/eslint-config-sukka)
|
|
694
|
+
|
|
695
|
+
[Anthony Fu](https://github.com/antfu)'s config inspired me to take the journey, but this project has since evolved into a personal project. Especially Rebecca's config and strict(er) approach to coding has pushed me towards a stricter coding environment, with [Functional](https://github.com/eslint-functional/eslint-plugin-functional) and [Azat](https://github.com/azat-io)'s [Perfectionist](https://perfectionist.dev) and [De Morgan](https://github.com/azat-io/eslint-plugin-de-morgan) enabled.
|
|
696
|
+
|
|
697
|
+
A personal thank-you to Anthony, Rebecca, Sukka, and Azat, and everyone else who contributed to their projects.
|
|
484
698
|
|
|
485
|
-
*
|
|
699
|
+
*Some* rules are the same, however, there are some differences:
|
|
486
700
|
|
|
487
|
-
-
|
|
488
|
-
-
|
|
489
|
-
-
|
|
490
|
-
- Includes dependencies rather than asking you to install them
|
|
701
|
+
- My own opinionated rules added
|
|
702
|
+
- Stylistic, Perfectionist, and Functional enabled per default
|
|
703
|
+
- More freedom to disable every individual config, or only disable the opinionated parts
|
|
491
704
|
- Deprecated Vue 2 support
|
|
492
705
|
- Simplification in some areas
|
|
493
|
-
-
|
|
494
|
-
-
|
|
706
|
+
- Better type-aware checks
|
|
707
|
+
- Plugin memoization
|
|
708
|
+
- Optional a11y support for React and Vue
|
|
709
|
+
- No dangerous plugin renaming
|
|
495
710
|
|
|
496
711
|
## License
|
|
497
712
|
|
|
498
|
-
[
|
|
713
|
+
[BSD 3-Clause](./LICENSE) License
|