@moso/eslint-config 3.0.4 → 3.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.
- package/README.md +164 -70
- package/dist/index.d.mts +3994 -663
- package/dist/index.mjs +1154 -965
- package/package.json +59 -51
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @moso/eslint-config
|
|
2
2
|
|
|
3
|
-
[](https://
|
|
3
|
+
[](https://npmx.dev/package/@moso/eslint-config)
|
|
4
|
+
[](https://codecov.io/gh/moso/eslint-config)
|
|
5
|
+
[](https://github.com/moso/eslint-config/blob/main/LICENSE)
|
|
4
6
|
|
|
5
7
|
Flat ESLint config for JavaScript, TypeScript, Vue, React, and more.
|
|
6
8
|
|
|
@@ -15,7 +17,8 @@ Flat ESLint config for JavaScript, TypeScript, Vue, React, and more.
|
|
|
15
17
|
- Ships its own small [`@moso`](#custom-rules)-ruleset with security and hygiene rules
|
|
16
18
|
- Every config can be enabled/disabled
|
|
17
19
|
- Respects `.gitignore` by default
|
|
18
|
-
- Requires Node.js >= v22.
|
|
20
|
+
- Requires Node.js >= v22.22.3/v24.x, ESLint v10+
|
|
21
|
+
- Enhanced security by [Socket's Bun Security Scanner](https://npmx.dev/package/@socketsecurity/bun-security-scanner)
|
|
19
22
|
|
|
20
23
|
> [!NOTE]
|
|
21
24
|
> **Note regarding TypeScript v7**
|
|
@@ -23,7 +26,7 @@ Flat ESLint config for JavaScript, TypeScript, Vue, React, and more.
|
|
|
23
26
|
|
|
24
27
|
## Configs
|
|
25
28
|
|
|
26
|
-
This section contains a list of the plugins used in the named configs that
|
|
29
|
+
This section contains a list of the plugins used in the named configs that ship with this shareable config.
|
|
27
30
|
|
|
28
31
|
\- ✅ Enabled by default
|
|
29
32
|
\- ☑️ Enabled by auto-detect
|
|
@@ -31,7 +34,7 @@ This section contains a list of the plugins used in the named configs that ships
|
|
|
31
34
|
\- 🟨 Can be enabled manually
|
|
32
35
|
\- 🎨 Stylistic rules enabled
|
|
33
36
|
\- 💭 Type-aware rules available by setting the path to your `tsconfig.json`
|
|
34
|
-
\- ℹ️ Accessibility rules available with `a11y: true`
|
|
37
|
+
\- ℹ️ Accessibility rules available with `a11y: true`
|
|
35
38
|
|
|
36
39
|
<table>
|
|
37
40
|
<thead>
|
|
@@ -56,6 +59,17 @@ This section contains a list of the plugins used in the named configs that ships
|
|
|
56
59
|
</tr>
|
|
57
60
|
<tr>
|
|
58
61
|
<td valign="top">
|
|
62
|
+
<details><summary><strong>Baseline</strong></summary>
|
|
63
|
+
|
|
64
|
+
[`eslint-plugin-baseline-js`](https://github.com/3ru/eslint-plugin-baseline-js)
|
|
65
|
+
|
|
66
|
+
</details></td>
|
|
67
|
+
<td valign="top">✅</td>
|
|
68
|
+
<td valign="top"></td>
|
|
69
|
+
<td valign="top">💭</td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td valign="top">
|
|
59
73
|
<details><summary><strong>e18e</strong></summary>
|
|
60
74
|
|
|
61
75
|
[`@e18e/eslint-plugin`](https://github.com/e18e/eslint-plugin)
|
|
@@ -222,6 +236,17 @@ This section contains a list of the plugins used in the named configs that ships
|
|
|
222
236
|
</tr>
|
|
223
237
|
<tr>
|
|
224
238
|
<td valign="top">
|
|
239
|
+
<details><summary><strong>TailwindCSS</strong></summary>
|
|
240
|
+
|
|
241
|
+
[`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss)
|
|
242
|
+
|
|
243
|
+
</details></td>
|
|
244
|
+
<td valign="top">☑️</td>
|
|
245
|
+
<td valign="top">🎨</td>
|
|
246
|
+
<td valign="top"></td>
|
|
247
|
+
</tr>
|
|
248
|
+
<tr>
|
|
249
|
+
<td valign="top">
|
|
225
250
|
<details><summary><strong>Test</strong></summary>
|
|
226
251
|
|
|
227
252
|
[`@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)
|
|
@@ -309,22 +334,40 @@ This config ships its own small plugin, registered as `@moso`. Each rule has ful
|
|
|
309
334
|
| [`prefer-early-return`](./src/rules/prefer-early-return/prefer-early-return.md) | Prefer guard clauses over wrapped function bodies | | 🔧 |
|
|
310
335
|
| [`prefer-fetch`](./src/rules/prefer-fetch/prefer-fetch.md) | Enforce `fetch` over legacy HTTP clients | | |
|
|
311
336
|
| [`prefer-reduce-over-chaining`](./src/rules/prefer-reduce-over-chaining/prefer-reduce-over-chaining.md) | Prefer one `.reduce()` pass over `.map().filter()` chains | ✅ | |
|
|
337
|
+
| [`prefer-strict-number-guards`](./src/rules/prefer-strict-number-guards/prefer-strict-number-guards.md) | Enforce the syntactic patterns that keep numeric code analyzable | | |
|
|
312
338
|
|
|
313
339
|
## Usage
|
|
314
340
|
|
|
315
341
|
### Install
|
|
316
342
|
|
|
317
|
-
|
|
318
|
-
|
|
343
|
+
```shell
|
|
344
|
+
# npm
|
|
345
|
+
npm install -D eslint @moso/eslint-config
|
|
346
|
+
|
|
347
|
+
# pnpm
|
|
348
|
+
pnpm add -D eslint @moso/eslint-config
|
|
319
349
|
|
|
320
|
-
|
|
350
|
+
# bun
|
|
321
351
|
bun add -d eslint @moso/eslint-config
|
|
322
352
|
```
|
|
323
353
|
|
|
324
|
-
Create `eslint.config
|
|
354
|
+
Create an `eslint.config.*` in the root of your project. You can use `.js` or `.ts`; `.mjs`/`.cjs` also works.
|
|
325
355
|
|
|
326
|
-
|
|
327
|
-
|
|
356
|
+
> [!NOTE]
|
|
357
|
+
> If you use `.ts`, you will need to install [`jiti`](https://unjs.io/packages/jiti) as a developer dependency:
|
|
358
|
+
> ```shell
|
|
359
|
+
> # npm
|
|
360
|
+
> npm install -D jiti
|
|
361
|
+
>
|
|
362
|
+
> # pnpm
|
|
363
|
+
> pnpm add -D jiti
|
|
364
|
+
>
|
|
365
|
+
> # bun
|
|
366
|
+
> bun add -d jiti
|
|
367
|
+
> ```
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
// eslint.config.*
|
|
328
371
|
import moso from '@moso/eslint-config';
|
|
329
372
|
|
|
330
373
|
export default moso();
|
|
@@ -335,10 +378,10 @@ export default moso();
|
|
|
335
378
|
Combine with legacy config:
|
|
336
379
|
</summary>
|
|
337
380
|
|
|
338
|
-
If you still use some configs from the legacy
|
|
381
|
+
If you still use some configs from the legacy `.eslintrc` format, you can use the [`@eslint/eslintrc`](https://npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
|
|
339
382
|
|
|
340
|
-
```
|
|
341
|
-
// eslint.config
|
|
383
|
+
```ts
|
|
384
|
+
// eslint.config.*
|
|
342
385
|
import moso from '@moso/eslint-config';
|
|
343
386
|
import { FlatCompat } from '@eslint/eslintrc';
|
|
344
387
|
|
|
@@ -399,7 +442,7 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
399
442
|
"source.organizeImports": "never"
|
|
400
443
|
},
|
|
401
444
|
|
|
402
|
-
// You can
|
|
445
|
+
// You can silence specific rules in your IDE, but still auto fix them
|
|
403
446
|
"eslint.rules.customizations": [
|
|
404
447
|
{ "rule": "@stylistic/*", "severity": "off", "fixable": true },
|
|
405
448
|
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
@@ -434,8 +477,8 @@ Since v1.0.0, this config has been migrated to [ESLint Flat config](https://esli
|
|
|
434
477
|
|
|
435
478
|
Normally you only need to import the `moso` preset:
|
|
436
479
|
|
|
437
|
-
```
|
|
438
|
-
// eslint.config
|
|
480
|
+
```ts
|
|
481
|
+
// eslint.config.*
|
|
439
482
|
import moso from '@moso/eslint-config';
|
|
440
483
|
|
|
441
484
|
export default moso();
|
|
@@ -445,8 +488,8 @@ export default moso();
|
|
|
445
488
|
|
|
446
489
|
Configure integrations by passing options to the main function:
|
|
447
490
|
|
|
448
|
-
```
|
|
449
|
-
// eslint.config
|
|
491
|
+
```ts
|
|
492
|
+
// eslint.config.*
|
|
450
493
|
import moso from '@moso/eslint-config';
|
|
451
494
|
|
|
452
495
|
export default moso({
|
|
@@ -465,6 +508,14 @@ export default moso({
|
|
|
465
508
|
typescript: true,
|
|
466
509
|
vue: true,
|
|
467
510
|
|
|
511
|
+
// JavaScript Baseline (enabled by default, reported as warnings)
|
|
512
|
+
baseline: false, // disable entirely
|
|
513
|
+
baseline: 'newly', // 'widely' (default), 'newly', or a year like 2023
|
|
514
|
+
baseline: {
|
|
515
|
+
baseline: 'widely',
|
|
516
|
+
ignoreFeatures: [], // skip web-features by ID, supports RegExp via '/.../'
|
|
517
|
+
},
|
|
518
|
+
|
|
468
519
|
// JSDoc support
|
|
469
520
|
jsdoc: true, // enable explicitly with reasonable defaults
|
|
470
521
|
|
|
@@ -484,8 +535,8 @@ export default moso({
|
|
|
484
535
|
|
|
485
536
|
Pass additional flat config objects as arguments. Rules are scoped to specific file types:
|
|
486
537
|
|
|
487
|
-
```
|
|
488
|
-
// eslint.config
|
|
538
|
+
```ts
|
|
539
|
+
// eslint.config.*
|
|
489
540
|
import moso from '@moso/eslint-config';
|
|
490
541
|
|
|
491
542
|
export default moso(
|
|
@@ -515,8 +566,8 @@ export default moso(
|
|
|
515
566
|
|
|
516
567
|
The config returns a `FlatConfigComposer` object from [`eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer), enabling chainable methods:
|
|
517
568
|
|
|
518
|
-
```
|
|
519
|
-
// eslint.config
|
|
569
|
+
```ts
|
|
570
|
+
// eslint.config.*
|
|
520
571
|
import moso from '@moso/eslint-config';
|
|
521
572
|
|
|
522
573
|
export default moso()
|
|
@@ -539,7 +590,7 @@ export default moso()
|
|
|
539
590
|
|
|
540
591
|
You can import and compose individual configs directly. Only use this if you need granular control:
|
|
541
592
|
|
|
542
|
-
```
|
|
593
|
+
```ts
|
|
543
594
|
import {
|
|
544
595
|
combine,
|
|
545
596
|
comments,
|
|
@@ -584,8 +635,8 @@ Disabled by default, will have to be enabled manually.
|
|
|
584
635
|
|
|
585
636
|
There are many ways JSDoc support can be configured. However, the most simple way is just enabling it which will use very reasonable defaults:
|
|
586
637
|
|
|
587
|
-
```
|
|
588
|
-
// eslint.config
|
|
638
|
+
```ts
|
|
639
|
+
// eslint.config.*
|
|
589
640
|
import moso from '@moso/eslint-config';
|
|
590
641
|
|
|
591
642
|
export default moso({
|
|
@@ -593,11 +644,11 @@ export default moso({
|
|
|
593
644
|
});
|
|
594
645
|
```
|
|
595
646
|
|
|
596
|
-
This will enable the preset `recommended`, which is recommended starting rules for enforcing proper tag values, common tags
|
|
647
|
+
This will enable the preset `recommended`, which is recommended starting rules for enforcing proper tag values, common tags exist, and tags are formatted and styled consistently.
|
|
597
648
|
|
|
598
649
|
Individual rules can be tweaked with the `overrides` property:
|
|
599
650
|
|
|
600
|
-
```
|
|
651
|
+
```ts
|
|
601
652
|
{
|
|
602
653
|
jsdoc: {
|
|
603
654
|
overrides: {
|
|
@@ -618,8 +669,8 @@ Framework support is auto-detected based on installed packages, but can be enabl
|
|
|
618
669
|
|
|
619
670
|
Auto-detected if you have [Astro](https://astro.build) installed. Enable explicitly:
|
|
620
671
|
|
|
621
|
-
```
|
|
622
|
-
// eslint.config
|
|
672
|
+
```ts
|
|
673
|
+
// eslint.config.*
|
|
623
674
|
import moso from '@moso/eslint-config';
|
|
624
675
|
|
|
625
676
|
export default moso({
|
|
@@ -629,8 +680,15 @@ export default moso({
|
|
|
629
680
|
|
|
630
681
|
Install dependencies when prompted, or manually:
|
|
631
682
|
|
|
632
|
-
```
|
|
633
|
-
|
|
683
|
+
```shell
|
|
684
|
+
# npm
|
|
685
|
+
npm install -D eslint-plugin-astro astro-eslint-parser
|
|
686
|
+
|
|
687
|
+
# pnpm
|
|
688
|
+
pnpm add -D eslint-plugin-astro astro-eslint-parser
|
|
689
|
+
|
|
690
|
+
# Bun
|
|
691
|
+
bun add -d eslint-plugin-astro astro-eslint-parser
|
|
634
692
|
```
|
|
635
693
|
|
|
636
694
|
> [!NOTE]
|
|
@@ -641,8 +699,8 @@ bun add --dev eslint-plugin-astro astro-eslint-parser
|
|
|
641
699
|
|
|
642
700
|
Auto-detected if you have React, Next.js, Nextra, Remix, Gatsby, or the `@astrojs/react` Astro framework integration installed. Enable explicitly:
|
|
643
701
|
|
|
644
|
-
```
|
|
645
|
-
// eslint.config
|
|
702
|
+
```ts
|
|
703
|
+
// eslint.config.*
|
|
646
704
|
import moso from '@moso/eslint-config';
|
|
647
705
|
|
|
648
706
|
export default moso({
|
|
@@ -652,16 +710,23 @@ export default moso({
|
|
|
652
710
|
|
|
653
711
|
Install dependencies when prompted, or manually:
|
|
654
712
|
|
|
655
|
-
```
|
|
656
|
-
|
|
713
|
+
```shell
|
|
714
|
+
# npm
|
|
715
|
+
npm install -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-react-you-might-not-need-an-effect
|
|
716
|
+
|
|
717
|
+
# pnpm
|
|
718
|
+
pnpm add -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-react-you-might-not-need-an-effect
|
|
719
|
+
|
|
720
|
+
# Bun
|
|
721
|
+
bun add -d @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-react-you-might-not-need-an-effect
|
|
657
722
|
```
|
|
658
723
|
|
|
659
724
|
### Vue
|
|
660
725
|
|
|
661
|
-
Auto-detected if you have Vue, Nuxt, VitePress, or the `@astrojs/vue` Astro framework
|
|
726
|
+
Auto-detected if you have Vue, Nuxt, VitePress, or the `@astrojs/vue` Astro framework integration installed. Enable explicitly:
|
|
662
727
|
|
|
663
|
-
```
|
|
664
|
-
// eslint.config
|
|
728
|
+
```ts
|
|
729
|
+
// eslint.config.*
|
|
665
730
|
import moso from '@moso/eslint-config';
|
|
666
731
|
|
|
667
732
|
export default moso({
|
|
@@ -671,34 +736,41 @@ export default moso({
|
|
|
671
736
|
|
|
672
737
|
Install dependencies when prompted, or manually (the Vue parser and SFC processors are already bundled as dependencies):
|
|
673
738
|
|
|
674
|
-
```
|
|
675
|
-
|
|
739
|
+
```shell
|
|
740
|
+
# npm
|
|
741
|
+
npm install -D eslint-plugin-vue
|
|
742
|
+
|
|
743
|
+
# pnpm
|
|
744
|
+
pnpm add -D eslint-plugin-vue
|
|
745
|
+
|
|
746
|
+
# Bun
|
|
747
|
+
bun add -d eslint-plugin-vue
|
|
676
748
|
```
|
|
677
749
|
|
|
678
750
|
> [!CAUTION]
|
|
679
|
-
> Since Vue 2 has [reached EOL](https://v2.vuejs.org/eol), this config does not support Vue 2. If you need
|
|
751
|
+
> Since Vue 2 has [reached EOL](https://v2.vuejs.org/eol), this config does not support Vue 2. If you need 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.
|
|
680
752
|
|
|
681
753
|
### Typed Linting
|
|
682
754
|
|
|
683
755
|
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.
|
|
684
756
|
|
|
685
|
-
You enable them by passing
|
|
757
|
+
You enable them by passing your project's root directory to the `projectRoot` option inside `typescript`.
|
|
686
758
|
|
|
687
759
|
> [!WARNING]
|
|
688
760
|
> Enabling these rules will come with a slight performance cost, [explained here](https://typescript-eslint.io/getting-started/typed-linting/#performance).
|
|
689
761
|
>
|
|
690
762
|
> 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).
|
|
691
763
|
|
|
692
|
-
```
|
|
693
|
-
// eslint.config
|
|
764
|
+
```ts
|
|
765
|
+
// eslint.config.*
|
|
694
766
|
import moso from '@moso/eslint-config';
|
|
695
767
|
|
|
696
768
|
export default moso(
|
|
697
769
|
{
|
|
698
|
-
projectRoot: import.meta.dirname,
|
|
699
|
-
|
|
700
|
-
// If you wish to override any of these rules, use `overridesTypeAware`:
|
|
701
770
|
typescript: {
|
|
771
|
+
projectRoot: import.meta.dirname,
|
|
772
|
+
|
|
773
|
+
// If you wish to override any of these rules, use `overridesTypeAware`:
|
|
702
774
|
overridesTypeAware: {
|
|
703
775
|
'@typescript-eslint/no-deprecated': 'off',
|
|
704
776
|
},
|
|
@@ -714,14 +786,14 @@ export default moso(
|
|
|
714
786
|
|
|
715
787
|
You can disable the type-aware layer entirely, or exclude certain globs or specific files from it:
|
|
716
788
|
|
|
717
|
-
```
|
|
718
|
-
// eslint.config
|
|
789
|
+
```ts
|
|
790
|
+
// eslint.config.*
|
|
719
791
|
import moso from '@moso/eslint-config';
|
|
720
792
|
|
|
721
793
|
export default moso({
|
|
722
|
-
projectRoot: import.meta.dirname,
|
|
723
|
-
|
|
724
794
|
typescript: {
|
|
795
|
+
projectRoot: import.meta.dirname,
|
|
796
|
+
|
|
725
797
|
// Kill switch: keep regular TypeScript rules, drop the type-aware layer
|
|
726
798
|
disableTypeAwareRules: true,
|
|
727
799
|
|
|
@@ -744,8 +816,8 @@ Some rules are deemed as 'non-fixable' when inside your editor with ESLint integ
|
|
|
744
816
|
|
|
745
817
|
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).
|
|
746
818
|
|
|
747
|
-
```
|
|
748
|
-
// eslint.config
|
|
819
|
+
```ts
|
|
820
|
+
// eslint.config.*
|
|
749
821
|
import moso from '@moso/eslint-config';
|
|
750
822
|
|
|
751
823
|
export default moso({
|
|
@@ -757,10 +829,10 @@ export default moso({
|
|
|
757
829
|
|
|
758
830
|
Linting and auto-fixing before every commit is easy, you just add the following to your `package.json`:
|
|
759
831
|
|
|
760
|
-
```
|
|
832
|
+
```jsonc
|
|
761
833
|
{
|
|
762
834
|
"simple-git-hooks": {
|
|
763
|
-
"pre-commit": "
|
|
835
|
+
"pre-commit": "npx lint-staged" // or pnx/bunx
|
|
764
836
|
},
|
|
765
837
|
"nano-staged": {
|
|
766
838
|
"*": "eslint --fix"
|
|
@@ -770,18 +842,30 @@ Linting and auto-fixing before every commit is easy, you just add the following
|
|
|
770
842
|
|
|
771
843
|
and then
|
|
772
844
|
|
|
773
|
-
```
|
|
774
|
-
|
|
845
|
+
```shell
|
|
846
|
+
# npm
|
|
847
|
+
npm install -D nano-staged simple-git-hooks
|
|
848
|
+
|
|
849
|
+
# pnpm
|
|
850
|
+
pnpm add -D nano-staged simple-git-hooks
|
|
851
|
+
|
|
852
|
+
# Bun
|
|
853
|
+
bun add -d nano-staged simple-git-hooks
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
# to activate the hooks:
|
|
857
|
+
npx simple-git-hooks # npm
|
|
858
|
+
|
|
859
|
+
pnx simple-git-hooks # pnpm
|
|
775
860
|
|
|
776
|
-
|
|
777
|
-
bunx simple-git-hooks
|
|
861
|
+
bunx simple-git-hooks # bun
|
|
778
862
|
```
|
|
779
863
|
|
|
780
864
|
## FAQ
|
|
781
865
|
|
|
782
866
|
### ESLint v9, older Node.js versions?
|
|
783
867
|
|
|
784
|
-
ESLint v9
|
|
868
|
+
ESLint v9 reached [EOL on August 6th, 2026](https://eslint.org/version-support). The world of development moves fast, and as with Vue v2.x, I don't intend to support versions that have reached EOL unless absolutely necessary. The same goes with older Node.js versions.
|
|
785
869
|
|
|
786
870
|
Even though ESLint v10 supports Node.js `v20.19.0` (as of current status), this version has also reached EOL. The rest of their requirements mention `v22.13.0` and `>= 24`. However, the minimum requirements of some of the configs that this sharable config apply rules from have a minimum requirement of `v22.22.3`, this project will stay within this range.
|
|
787
871
|
|
|
@@ -789,13 +873,20 @@ Even though ESLint v10 supports Node.js `v20.19.0` (as of current status), this
|
|
|
789
873
|
|
|
790
874
|
TypeScript 7.0 [does not ship a compiler API](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) (a new one supposedly arrives in 7.1), so [`typescript-eslint`](https://typescript-eslint.io) - and therefore all TypeScript linting in this config - cannot run against it. TypeScript's supported setup is running TypeScript 6 side-by-side through the [`@typescript/typescript6`](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0) compatibility package, aliased so tooling that imports `typescript` keeps working:
|
|
791
875
|
|
|
792
|
-
```
|
|
793
|
-
|
|
876
|
+
```shell
|
|
877
|
+
# npm
|
|
878
|
+
npm install -D typescript@npm:@typescript/typescript6
|
|
879
|
+
|
|
880
|
+
# pnpm
|
|
881
|
+
pnpm add -D typescript@npm:@typescript/typescript6
|
|
882
|
+
|
|
883
|
+
# Bun
|
|
884
|
+
bun add -d typescript@npm:@typescript/typescript6
|
|
794
885
|
```
|
|
795
886
|
|
|
796
887
|
Optionally keep TypeScript 7's own `tsc` around as well:
|
|
797
888
|
|
|
798
|
-
```
|
|
889
|
+
```json
|
|
799
890
|
{
|
|
800
891
|
"devDependencies": {
|
|
801
892
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
@@ -808,12 +899,15 @@ With the alias in place, this config works unchanged. Without it, the config det
|
|
|
808
899
|
|
|
809
900
|
**Keep in mind**, this is temporary until an API is provided by TypeScript for v7.
|
|
810
901
|
|
|
902
|
+
> [!NOTE]
|
|
903
|
+
> As per v8.65.0, `@typescript-eslint` will also display a warning if TypeScript v7 is detected.
|
|
904
|
+
|
|
811
905
|
### I want it less opinionated
|
|
812
906
|
|
|
813
907
|
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.
|
|
814
908
|
|
|
815
|
-
```
|
|
816
|
-
// eslint.config
|
|
909
|
+
```ts
|
|
910
|
+
// eslint.config.*
|
|
817
911
|
import moso from '@moso/eslint-config';
|
|
818
912
|
|
|
819
913
|
export default moso({
|
|
@@ -824,7 +918,7 @@ export default moso({
|
|
|
824
918
|
> [!NOTE]
|
|
825
919
|
> 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
|
|
826
920
|
|
|
827
|
-
```
|
|
921
|
+
```ts
|
|
828
922
|
{
|
|
829
923
|
// Disable opinionated rules
|
|
830
924
|
lessOpinionated: true,
|
|
@@ -850,7 +944,7 @@ You can still use these to format files that aren't linted with this config, how
|
|
|
850
944
|
|
|
851
945
|
You will need to install and configure [`stylelint`](https://stylelint.io) yourself, unfortunately.
|
|
852
946
|
|
|
853
|
-
|
|
947
|
+
`v3.2.0` added linting support for TailwindCSS, however.
|
|
854
948
|
|
|
855
949
|
### I prefer `this` or `that` rule
|
|
856
950
|
|
|
@@ -860,9 +954,9 @@ No worries, you can always override the rules locally in your project to fit you
|
|
|
860
954
|
|
|
861
955
|
This ESLint config is heavily inspired by (and uses some of the same logic of):
|
|
862
956
|
|
|
863
|
-
\- [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
864
|
-
\- [@rebeccastevens/eslint-config](https://github.com/RebeccaStevens/eslint-config-rebeccastevens)
|
|
865
|
-
\- [@eslint-sukka/eslint-config](https://github.com/SukkaW/eslint-config-sukka)
|
|
957
|
+
\- [@antfu/eslint-config](https://github.com/antfu/eslint-config)
|
|
958
|
+
\- [@rebeccastevens/eslint-config](https://github.com/RebeccaStevens/eslint-config-rebeccastevens)
|
|
959
|
+
\- [@eslint-sukka/eslint-config](https://github.com/SukkaW/eslint-config-sukka)
|
|
866
960
|
|
|
867
961
|
[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.
|
|
868
962
|
|