@moso/eslint-config 3.6.1 → 3.7.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 (4) hide show
  1. package/README.md +67 -33
  2. package/dist/index.d.mts +3161 -810
  3. package/dist/index.mjs +435 -531
  4. package/package.json +52 -49
package/README.md CHANGED
@@ -548,10 +548,12 @@ export default moso({
548
548
  yaml: false,
549
549
 
550
550
  // Replaces .eslintignore (no longer supported)
551
- ignores: [
552
- '**/dist',
553
- '**/node_modules',
554
- ],
551
+ ignores: {
552
+ userIgnores: [
553
+ '**/dist',
554
+ '**/node_modules',
555
+ ],
556
+ },
555
557
  });
556
558
  ```
557
559
 
@@ -588,36 +590,53 @@ export default moso(
588
590
 
589
591
  ### Advanced Composition
590
592
 
591
- The config returns a `FlatConfigComposer` object from [`eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer), enabling chainable methods:
593
+ `moso(options, ...userConfigs)` returns a `Promise<Linter.Config[]>`: a plain flat config array, not a chainable object. Extra configs (items, arrays, or promises of either) are appended after the generated ones, and since later items win, that is how you change or turn off rules anywhere, including those of a named config like `moso/javascript/rules`.
594
+
595
+ To place configs *before* the generated ones (so the generated rules win over them), flatten everything in order with `combine`, which takes the same mix of items, arrays, and promises:
592
596
 
593
597
  ```ts
594
598
  // eslint.config.*
595
- import moso from '@moso/eslint-config';
599
+ import moso, { combine } from '@moso/eslint-config';
600
+ import otherConfig from 'some-shareable-config';
596
601
 
597
- export default moso()
598
- .prepend({
599
- // Configs before the main config
600
- })
601
- .override('moso/javascript/rules', {
602
- rules: {
603
- 'no-var': 'off',
602
+ export default combine(
603
+ // Before the generated configs: its conflicting rules lose
604
+ otherConfig,
605
+ moso(
606
+ {
607
+ // moso config options
604
608
  },
605
- })
606
- .removeRules(
607
- 'no-console',
608
- 'no-debugger',
609
- );
609
+ {
610
+ // After the generated configs: no `files`, so it applies to every file
611
+ rules: {
612
+ 'no-console': 'off',
613
+ 'no-debugger': 'off',
614
+ 'no-var': 'off',
615
+ },
616
+ },
617
+ ),
618
+ );
610
619
  ```
611
620
 
612
621
  <details>
613
622
  <summary>Fine-grained config imports</summary>
614
623
 
615
- You can import and compose individual configs directly. Only use this if you need granular control:
624
+ You can import and compose individual configs directly. Only use this if you need granular control.
625
+ Composing by hand skips the factory, so each config takes the options the factory would otherwise resolve for it:
616
626
 
617
627
  ```ts
618
628
  import {
619
629
  combine,
620
630
  comments,
631
+ GLOB_DTS,
632
+ GLOB_JSON,
633
+ GLOB_JSON5,
634
+ GLOB_JSONC,
635
+ GLOB_SRC,
636
+ GLOB_TS,
637
+ GLOB_TSX,
638
+ GLOB_VUE,
639
+ GLOB_YAML,
621
640
  ignores,
622
641
  imports,
623
642
  javascript,
@@ -627,25 +646,39 @@ import {
627
646
  sortPackageJson,
628
647
  sortTsconfig,
629
648
  stylistic,
649
+ StylisticConfigDefaults,
630
650
  typescript,
631
651
  unicorn,
632
652
  vue,
633
653
  yaml,
634
654
  } from '@moso/eslint-config';
635
655
 
656
+ const functionalOptions = { functionalEnforcement: 'lite' as const, ignoreNamePattern: ['^[mM]ut_'] };
657
+ const parserOptions = { filesTypeAware: [GLOB_DTS, GLOB_TS, GLOB_TSX], ignoresTypeAware: [], parserOptions: {} };
658
+
636
659
  export default combine(
637
- comments(),
638
- ignores(),
639
- imports(),
640
- javascript(/* options */),
641
- jsdoc(),
642
- jsonc(),
643
- node(),
644
- stylistic(/* options */),
645
- typescript(/* options */),
646
- unicorn(),
647
- vue(/* options */),
648
- yaml(),
660
+ comments({}),
661
+ ignores({}),
662
+ imports({ files: [GLOB_DTS, GLOB_TS, GLOB_TSX], stylistic: StylisticConfigDefaults, typescript: true }),
663
+ javascript(functionalOptions),
664
+ jsdoc({ files: [GLOB_SRC], stylistic: StylisticConfigDefaults, typescript: true }),
665
+ jsonc({ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], stylistic: StylisticConfigDefaults }),
666
+ sortPackageJson(),
667
+ sortTsconfig(),
668
+ node({}),
669
+ stylistic({ ...StylisticConfigDefaults, typescript: true }),
670
+ typescript({
671
+ ...functionalOptions,
672
+ ...parserOptions,
673
+ componentExts: ['vue'],
674
+ files: [GLOB_SRC, GLOB_VUE],
675
+ mode: 'none',
676
+ stylistic: StylisticConfigDefaults,
677
+ unsafe: 'warn',
678
+ }),
679
+ unicorn({ files: [GLOB_SRC] }),
680
+ vue({ ...parserOptions, files: [GLOB_VUE], stylistic: StylisticConfigDefaults, typescript: true }),
681
+ yaml({ files: [GLOB_YAML], stylistic: StylisticConfigDefaults }),
649
682
  );
650
683
  ```
651
684
 
@@ -1004,7 +1037,7 @@ export default moso({
1004
1037
  ```
1005
1038
 
1006
1039
  > [!NOTE]
1007
- > 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
1040
+ > The above will also disable `e18e`, `functional`, and `perfectionist` completely. An explicit setting for any of them (`true`, an object, or for `functional` an enforcement level) wins over `lessOpinionated` and re-enables it, as demonstrated below
1008
1041
 
1009
1042
  ```ts
1010
1043
  {
@@ -1019,7 +1052,8 @@ export default moso({
1019
1052
  functionalEnforcement: 'recommended',
1020
1053
  },
1021
1054
 
1022
- // Re-enable `perfectionist`
1055
+ // Re-enable `e18e` and `perfectionist` - `true`, or an object such as `{ overrides }`
1056
+ e18e: true,
1023
1057
  perfectionist: true,
1024
1058
  }
1025
1059
  ```