@lincy/eslint-config 3.0.11 → 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/dist/index.js CHANGED
@@ -61,9 +61,6 @@ function searchPackageJSON(dir) {
61
61
  // src/factory.ts
62
62
  import gitignore from "eslint-config-flat-gitignore";
63
63
 
64
- // src/flags.ts
65
- var OFF = 0;
66
-
67
64
  // src/plugins.ts
68
65
  import { default as default2 } from "eslint-plugin-antfu";
69
66
  import { default as default3 } from "eslint-plugin-eslint-comments";
@@ -72,49 +69,69 @@ import { default as default5 } from "eslint-plugin-jsdoc";
72
69
  import { default as default6 } from "eslint-plugin-jsonc";
73
70
  import { default as default7 } from "eslint-plugin-markdown";
74
71
  import { default as default8 } from "eslint-plugin-n";
75
- import { default as default9 } from "@stylistic/eslint-plugin-js";
76
- import { default as default10 } from "@stylistic/eslint-plugin-ts";
77
- import { default as default11 } from "@typescript-eslint/eslint-plugin";
78
- import { default as default12 } from "eslint-plugin-unicorn";
79
- import { default as default13 } from "eslint-plugin-unused-imports";
80
- import { default as default14 } from "eslint-plugin-vue";
81
- import { default as default15 } from "eslint-plugin-yml";
82
- import { default as default16 } from "eslint-plugin-no-only-tests";
83
- import { default as default17 } from "@typescript-eslint/parser";
84
- import { default as default18 } from "vue-eslint-parser";
85
- import { default as default19 } from "yaml-eslint-parser";
86
- import { default as default20 } from "jsonc-eslint-parser";
72
+ import { default as default9 } from "@stylistic/eslint-plugin";
73
+ import { default as default10 } from "@typescript-eslint/eslint-plugin";
74
+ import { default as default11 } from "eslint-plugin-unicorn";
75
+ import { default as default12 } from "eslint-plugin-unused-imports";
76
+ import { default as default13 } from "eslint-plugin-vue";
77
+ import { default as default14 } from "eslint-plugin-yml";
78
+ import { default as default15 } from "eslint-plugin-no-only-tests";
79
+ import { default as default16 } from "@typescript-eslint/parser";
80
+ import { default as default17 } from "vue-eslint-parser";
81
+ import { default as default18 } from "yaml-eslint-parser";
82
+ import { default as default19 } from "jsonc-eslint-parser";
87
83
 
88
84
  // src/configs/comments.ts
89
- var comments = [
90
- {
91
- plugins: {
92
- "eslint-comments": default3
93
- },
94
- rules: {
95
- ...default3.configs.recommended.rules,
96
- "eslint-comments/disable-enable-pair": OFF
85
+ function comments() {
86
+ return [
87
+ {
88
+ plugins: {
89
+ "eslint-comments": default3
90
+ },
91
+ rules: {
92
+ "eslint-comments/no-aggregating-enable": "error",
93
+ "eslint-comments/no-duplicate-disable": "error",
94
+ "eslint-comments/no-unlimited-disable": "error",
95
+ "eslint-comments/no-unused-enable": "error"
96
+ }
97
97
  }
98
- }
99
- ];
98
+ ];
99
+ }
100
100
 
101
101
  // src/globs.ts
102
102
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
103
103
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
104
+ var GLOB_JS = "**/*.?([cm])js";
105
+ var GLOB_JSX = "**/*.?([cm])jsx";
104
106
  var GLOB_TS = "**/*.?([cm])ts";
105
107
  var GLOB_TSX = "**/*.?([cm])tsx";
108
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
109
+ var GLOB_CSS = "**/*.css";
110
+ var GLOB_LESS = "**/*.less";
111
+ var GLOB_SCSS = "**/*.scss";
106
112
  var GLOB_JSON = "**/*.json";
107
113
  var GLOB_JSON5 = "**/*.json5";
108
114
  var GLOB_JSONC = "**/*.jsonc";
109
115
  var GLOB_MARKDOWN = "**/*.md";
110
116
  var GLOB_VUE = "**/*.vue";
111
117
  var GLOB_YAML = "**/*.y?(a)ml";
118
+ var GLOB_HTML = "**/*.htm?(l)";
112
119
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
113
120
  var GLOB_TESTS = [
114
121
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
115
122
  `**/*.spec.${GLOB_SRC_EXT}`,
116
123
  `**/*.test.${GLOB_SRC_EXT}`
117
124
  ];
125
+ var GLOB_ALL_SRC = [
126
+ GLOB_SRC,
127
+ GLOB_STYLE,
128
+ GLOB_JSON,
129
+ GLOB_JSON5,
130
+ GLOB_MARKDOWN,
131
+ GLOB_VUE,
132
+ GLOB_YAML,
133
+ GLOB_HTML
134
+ ];
118
135
  var GLOB_EXCLUDE = [
119
136
  "**/node_modules",
120
137
  "**/dist",
@@ -140,33 +157,54 @@ var GLOB_EXCLUDE = [
140
157
  ];
141
158
 
142
159
  // src/configs/ignores.ts
143
- var ignores = [
144
- { ignores: GLOB_EXCLUDE }
145
- ];
160
+ function ignores(options = {}) {
161
+ const {
162
+ ignores: ignores2 = []
163
+ } = options;
164
+ return [
165
+ {
166
+ ignores: [
167
+ ...GLOB_EXCLUDE,
168
+ ...ignores2
169
+ ]
170
+ }
171
+ ];
172
+ }
146
173
 
147
174
  // src/configs/imports.ts
148
- var imports = [
149
- {
150
- plugins: {
151
- import: default4
152
- },
153
- rules: {
154
- "import/export": "error",
155
- "import/first": "error",
156
- "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
157
- "import/no-duplicates": "error",
158
- "import/no-mutable-exports": "error",
159
- "import/no-named-default": "error",
160
- "import/no-self-import": "error",
161
- "import/no-webpack-loader-syntax": "error",
162
- "import/order": "error"
175
+ function imports() {
176
+ return [
177
+ {
178
+ plugins: {
179
+ import: default4
180
+ },
181
+ rules: {
182
+ "import/export": "error",
183
+ "import/first": "error",
184
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }],
185
+ "import/no-duplicates": "error",
186
+ "import/no-mutable-exports": "error",
187
+ "import/no-named-default": "error",
188
+ "import/no-self-import": "error",
189
+ "import/no-webpack-loader-syntax": "error",
190
+ "import/order": "error"
191
+ }
163
192
  }
164
- }
165
- ];
193
+ ];
194
+ }
166
195
 
167
196
  // src/configs/javascript.ts
168
197
  import globals from "globals";
198
+
199
+ // src/flags.ts
200
+ var OFF = 0;
201
+
202
+ // src/configs/javascript.ts
169
203
  function javascript(options = {}) {
204
+ const {
205
+ isInEditor = false,
206
+ overrides = {}
207
+ } = options;
170
208
  return [
171
209
  {
172
210
  languageOptions: {
@@ -190,7 +228,7 @@ function javascript(options = {}) {
190
228
  },
191
229
  plugins: {
192
230
  "antfu": default2,
193
- "unused-imports": default13
231
+ "unused-imports": default12
194
232
  },
195
233
  rules: {
196
234
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
@@ -371,7 +409,7 @@ function javascript(options = {}) {
371
409
  ],
372
410
  "symbol-description": "error",
373
411
  "unicode-bom": ["error", "never"],
374
- "unused-imports/no-unused-imports": options.isInEditor ? OFF : "error",
412
+ "unused-imports/no-unused-imports": isInEditor ? OFF : "error",
375
413
  "unused-imports/no-unused-vars": [
376
414
  "error",
377
415
  { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
@@ -380,7 +418,8 @@ function javascript(options = {}) {
380
418
  "valid-typeof": ["error", { requireStringLiterals: true }],
381
419
  "vars-on-top": "error",
382
420
  "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
383
- "yoda": ["error", "never"]
421
+ "yoda": ["error", "never"],
422
+ ...overrides
384
423
  }
385
424
  },
386
425
  {
@@ -393,65 +432,106 @@ function javascript(options = {}) {
393
432
  }
394
433
 
395
434
  // src/configs/jsdoc.ts
396
- var jsdoc = [
397
- {
398
- plugins: {
399
- jsdoc: default5
400
- },
401
- rules: {
402
- ...default5.configs["flat/recommended-typescript"].rules,
403
- "jsdoc/check-tag-names": OFF,
404
- "jsdoc/check-values": OFF,
405
- "jsdoc/no-undefined-types": OFF,
406
- "jsdoc/require-jsdoc": OFF,
407
- "jsdoc/require-param": OFF,
408
- "jsdoc/require-param-description": OFF,
409
- "jsdoc/require-param-type": OFF,
410
- "jsdoc/require-returns": OFF,
411
- "jsdoc/require-returns-type": OFF,
412
- "jsdoc/require-throws": OFF,
413
- "jsdoc/require-yields": OFF,
414
- "jsdoc/tag-lines": OFF
435
+ function jsdoc() {
436
+ return [
437
+ {
438
+ plugins: {
439
+ jsdoc: default5
440
+ },
441
+ rules: {
442
+ "jsdoc/check-access": "warn",
443
+ "jsdoc/check-alignment": "warn",
444
+ "jsdoc/check-param-names": "warn",
445
+ "jsdoc/check-property-names": "warn",
446
+ "jsdoc/check-types": "warn",
447
+ "jsdoc/empty-tags": "warn",
448
+ "jsdoc/implements-on-classes": "warn",
449
+ "jsdoc/multiline-blocks": "warn",
450
+ "jsdoc/no-defaults": "warn",
451
+ "jsdoc/no-multi-asterisks": "warn",
452
+ "jsdoc/no-types": "warn",
453
+ "jsdoc/require-param-name": "warn",
454
+ "jsdoc/require-property": "warn",
455
+ "jsdoc/require-property-description": "warn",
456
+ "jsdoc/require-property-name": "warn",
457
+ "jsdoc/require-returns-check": "warn",
458
+ "jsdoc/require-returns-description": "warn",
459
+ "jsdoc/require-yields-check": "warn",
460
+ "jsdoc/valid-types": "warn"
461
+ }
415
462
  }
416
- }
417
- ];
463
+ ];
464
+ }
418
465
 
419
466
  // src/configs/jsonc.ts
420
- var jsonc = [
421
- {
422
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
423
- languageOptions: {
424
- parser: default20
425
- },
426
- plugins: {
427
- jsonc: default6
467
+ function jsonc() {
468
+ return [
469
+ {
470
+ plugins: {
471
+ jsonc: default6
472
+ }
428
473
  },
429
- rules: {
430
- ...default6.configs["recommended-with-jsonc"].rules,
431
- "jsonc/array-bracket-spacing": ["error", "never"],
432
- "jsonc/comma-dangle": ["error", "never"],
433
- "jsonc/comma-style": ["error", "last"],
434
- "jsonc/indent": ["error", 2],
435
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
436
- "jsonc/no-octal-escape": "error",
437
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
438
- "jsonc/object-curly-spacing": ["error", "always"],
439
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }]
474
+ {
475
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
476
+ languageOptions: {
477
+ parser: default19
478
+ },
479
+ rules: {
480
+ "jsonc/array-bracket-spacing": ["error", "never"],
481
+ "jsonc/comma-dangle": ["error", "never"],
482
+ "jsonc/comma-style": ["error", "last"],
483
+ "jsonc/indent": ["error", 2],
484
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
485
+ "jsonc/no-bigint-literals": "error",
486
+ "jsonc/no-binary-expression": "error",
487
+ "jsonc/no-binary-numeric-literals": "error",
488
+ "jsonc/no-dupe-keys": "error",
489
+ "jsonc/no-escape-sequence-in-identifier": "error",
490
+ "jsonc/no-floating-decimal": "error",
491
+ "jsonc/no-hexadecimal-numeric-literals": "error",
492
+ "jsonc/no-infinity": "error",
493
+ "jsonc/no-multi-str": "error",
494
+ "jsonc/no-nan": "error",
495
+ "jsonc/no-number-props": "error",
496
+ "jsonc/no-numeric-separators": "error",
497
+ "jsonc/no-octal": "error",
498
+ "jsonc/no-octal-escape": "error",
499
+ "jsonc/no-octal-numeric-literals": "error",
500
+ "jsonc/no-parenthesized": "error",
501
+ "jsonc/no-plus-sign": "error",
502
+ "jsonc/no-regexp-literals": "error",
503
+ "jsonc/no-sparse-arrays": "error",
504
+ "jsonc/no-template-literals": "error",
505
+ "jsonc/no-undefined-value": "error",
506
+ "jsonc/no-unicode-codepoint-escapes": "error",
507
+ "jsonc/no-useless-escape": "error",
508
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
509
+ "jsonc/object-curly-spacing": ["error", "always"],
510
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
511
+ "jsonc/quote-props": "error",
512
+ "jsonc/quotes": "error",
513
+ "jsonc/space-unary-ops": "error",
514
+ "jsonc/valid-json-number": "error",
515
+ "jsonc/vue-custom-block/no-parsing-error": "error"
516
+ }
440
517
  }
441
- }
442
- ];
518
+ ];
519
+ }
443
520
 
444
521
  // src/configs/markdown.ts
445
522
  function markdown(options = {}) {
446
523
  const {
447
- componentExts = []
524
+ componentExts = [],
525
+ overrides = {}
448
526
  } = options;
449
527
  return [
450
528
  {
451
- files: [GLOB_MARKDOWN],
452
529
  plugins: {
453
530
  markdown: default7
454
- },
531
+ }
532
+ },
533
+ {
534
+ files: [GLOB_MARKDOWN],
455
535
  processor: "markdown/markdown"
456
536
  },
457
537
  {
@@ -466,22 +546,17 @@ function markdown(options = {}) {
466
546
  }
467
547
  }
468
548
  },
469
- plugins: {
470
- ts: default11
471
- },
472
549
  rules: {
473
- ...default7.configs.recommended.overrides[1].rules,
474
550
  "antfu/no-cjs-exports": OFF,
475
551
  "antfu/no-ts-export-equal": OFF,
476
- "import/no-unresolved": OFF,
552
+ "eol-last": OFF,
477
553
  "no-alert": OFF,
478
554
  "no-console": OFF,
479
- "no-restricted-imports": OFF,
480
555
  "no-undef": OFF,
481
556
  "no-unused-expressions": OFF,
482
557
  "no-unused-vars": OFF,
483
558
  "node/prefer-global/process": OFF,
484
- "ts/comma-dangle": OFF,
559
+ "style/comma-dangle": OFF,
485
560
  "ts/consistent-type-imports": OFF,
486
561
  "ts/no-namespace": OFF,
487
562
  "ts/no-redeclare": OFF,
@@ -489,386 +564,356 @@ function markdown(options = {}) {
489
564
  "ts/no-unused-vars": OFF,
490
565
  "ts/no-use-before-define": OFF,
491
566
  "ts/no-var-requires": OFF,
567
+ "unicode-bom": "off",
492
568
  "unused-imports/no-unused-imports": OFF,
493
- "unused-imports/no-unused-vars": OFF
569
+ "unused-imports/no-unused-vars": OFF,
570
+ ...overrides
494
571
  }
495
572
  }
496
573
  ];
497
574
  }
498
575
 
499
576
  // src/configs/node.ts
500
- var node = [
501
- {
502
- plugins: {
503
- node: default8
504
- },
505
- rules: {
506
- "node/handle-callback-err": ["error", "^(err|error)$"],
507
- "node/no-deprecated-api": "error",
508
- "node/no-exports-assign": "error",
509
- "node/no-new-require": "error",
510
- "node/no-path-concat": "error",
511
- "node/prefer-global/buffer": ["error", "never"],
512
- "node/prefer-global/process": ["error", "never"],
513
- "node/process-exit-as-throw": "error"
577
+ function node() {
578
+ return [
579
+ {
580
+ plugins: {
581
+ node: default8
582
+ },
583
+ rules: {
584
+ "node/handle-callback-err": ["error", "^(err|error)$"],
585
+ "node/no-deprecated-api": "error",
586
+ "node/no-exports-assign": "error",
587
+ "node/no-new-require": "error",
588
+ "node/no-path-concat": "error",
589
+ "node/prefer-global/buffer": ["error", "never"],
590
+ "node/prefer-global/process": ["error", "never"],
591
+ "node/process-exit-as-throw": "error"
592
+ }
514
593
  }
515
- }
516
- ];
594
+ ];
595
+ }
517
596
 
518
597
  // src/configs/sort.ts
519
- var sortPackageJson = [
520
- {
521
- files: ["**/package.json"],
522
- rules: {
523
- "jsonc/sort-array-values": [
524
- "error",
525
- {
526
- order: { type: "asc" },
527
- pathPattern: "^files$"
528
- }
529
- ],
530
- "jsonc/sort-keys": [
531
- "error",
532
- {
533
- order: [
534
- "publisher",
535
- "name",
536
- "displayName",
537
- "type",
538
- "version",
539
- "private",
540
- "packageManager",
541
- "description",
542
- "author",
543
- "license",
544
- "funding",
545
- "homepage",
546
- "repository",
547
- "bugs",
548
- "keywords",
549
- "categories",
550
- "sideEffects",
551
- "exports",
552
- "main",
553
- "module",
554
- "unpkg",
555
- "jsdelivr",
556
- "types",
557
- "typesVersions",
558
- "bin",
559
- "icon",
560
- "files",
561
- "engines",
562
- "activationEvents",
563
- "contributes",
564
- "scripts",
565
- "peerDependencies",
566
- "peerDependenciesMeta",
567
- "dependencies",
568
- "optionalDependencies",
569
- "devDependencies",
570
- "pnpm",
571
- "overrides",
572
- "resolutions",
573
- "husky",
574
- "simple-git-hooks",
575
- "lint-staged",
576
- "eslintConfig"
577
- ],
578
- pathPattern: "^$"
579
- },
580
- {
581
- order: { type: "asc" },
582
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
583
- },
584
- {
585
- order: { type: "asc" },
586
- pathPattern: "^resolutions$"
587
- },
588
- {
589
- order: { type: "asc" },
590
- pathPattern: "^pnpm.overrides$"
591
- },
592
- {
593
- order: [
594
- "types",
595
- "import",
596
- "require",
597
- "default"
598
- ],
599
- pathPattern: "^exports.*$"
600
- }
601
- ]
598
+ function sortPackageJson() {
599
+ return [
600
+ {
601
+ files: ["**/package.json"],
602
+ rules: {
603
+ "jsonc/sort-array-values": [
604
+ "error",
605
+ {
606
+ order: { type: "asc" },
607
+ pathPattern: "^files$"
608
+ }
609
+ ],
610
+ "jsonc/sort-keys": [
611
+ "error",
612
+ {
613
+ order: [
614
+ "publisher",
615
+ "name",
616
+ "displayName",
617
+ "type",
618
+ "version",
619
+ "private",
620
+ "packageManager",
621
+ "description",
622
+ "author",
623
+ "license",
624
+ "funding",
625
+ "homepage",
626
+ "repository",
627
+ "bugs",
628
+ "keywords",
629
+ "categories",
630
+ "sideEffects",
631
+ "exports",
632
+ "main",
633
+ "module",
634
+ "unpkg",
635
+ "jsdelivr",
636
+ "types",
637
+ "typesVersions",
638
+ "bin",
639
+ "icon",
640
+ "files",
641
+ "engines",
642
+ "activationEvents",
643
+ "contributes",
644
+ "scripts",
645
+ "peerDependencies",
646
+ "peerDependenciesMeta",
647
+ "dependencies",
648
+ "optionalDependencies",
649
+ "devDependencies",
650
+ "pnpm",
651
+ "overrides",
652
+ "resolutions",
653
+ "husky",
654
+ "simple-git-hooks",
655
+ "lint-staged",
656
+ "eslintConfig"
657
+ ],
658
+ pathPattern: "^$"
659
+ },
660
+ {
661
+ order: { type: "asc" },
662
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
663
+ },
664
+ {
665
+ order: { type: "asc" },
666
+ pathPattern: "^resolutions$"
667
+ },
668
+ {
669
+ order: { type: "asc" },
670
+ pathPattern: "^pnpm.overrides$"
671
+ },
672
+ {
673
+ order: [
674
+ "types",
675
+ "import",
676
+ "require",
677
+ "default"
678
+ ],
679
+ pathPattern: "^exports.*$"
680
+ }
681
+ ]
682
+ }
602
683
  }
603
- }
604
- ];
605
- var sortTsconfig = [
606
- {
607
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
608
- rules: {
609
- "jsonc/sort-keys": [
610
- "error",
611
- {
612
- order: [
613
- "extends",
614
- "compilerOptions",
615
- "references",
616
- "files",
617
- "include",
618
- "exclude"
619
- ],
620
- pathPattern: "^$"
621
- },
622
- {
623
- order: [
624
- /* Projects */
625
- "incremental",
626
- "composite",
627
- "tsBuildInfoFile",
628
- "disableSourceOfProjectReferenceRedirect",
629
- "disableSolutionSearching",
630
- "disableReferencedProjectLoad",
631
- /* Language and Environment */
632
- "target",
633
- "lib",
634
- "jsx",
635
- "experimentalDecorators",
636
- "emitDecoratorMetadata",
637
- "jsxFactory",
638
- "jsxFragmentFactory",
639
- "jsxImportSource",
640
- "reactNamespace",
641
- "noLib",
642
- "useDefineForClassFields",
643
- "moduleDetection",
644
- /* Modules */
645
- "module",
646
- "rootDir",
647
- "moduleResolution",
648
- "baseUrl",
649
- "paths",
650
- "rootDirs",
651
- "typeRoots",
652
- "types",
653
- "allowUmdGlobalAccess",
654
- "moduleSuffixes",
655
- "allowImportingTsExtensions",
656
- "resolvePackageJsonExports",
657
- "resolvePackageJsonImports",
658
- "customConditions",
659
- "resolveJsonModule",
660
- "allowArbitraryExtensions",
661
- "noResolve",
662
- /* JavaScript Support */
663
- "allowJs",
664
- "checkJs",
665
- "maxNodeModuleJsDepth",
666
- /* Emit */
667
- "declaration",
668
- "declarationMap",
669
- "emitDeclarationOnly",
670
- "sourceMap",
671
- "inlineSourceMap",
672
- "outFile",
673
- "outDir",
674
- "removeComments",
675
- "noEmit",
676
- "importHelpers",
677
- "importsNotUsedAsValues",
678
- "downlevelIteration",
679
- "sourceRoot",
680
- "mapRoot",
681
- "inlineSources",
682
- "emitBOM",
683
- "newLine",
684
- "stripInternal",
685
- "noEmitHelpers",
686
- "noEmitOnError",
687
- "preserveConstEnums",
688
- "declarationDir",
689
- "preserveValueImports",
690
- /* Interop Constraints */
691
- "isolatedModules",
692
- "verbatimModuleSyntax",
693
- "allowSyntheticDefaultImports",
694
- "esModuleInterop",
695
- "preserveSymlinks",
696
- "forceConsistentCasingInFileNames",
697
- /* Type Checking */
698
- "strict",
699
- "strictBindCallApply",
700
- "strictFunctionTypes",
701
- "strictNullChecks",
702
- "strictPropertyInitialization",
703
- "allowUnreachableCode",
704
- "allowUnusedLabels",
705
- "alwaysStrict",
706
- "exactOptionalPropertyTypes",
707
- "noFallthroughCasesInSwitch",
708
- "noImplicitAny",
709
- "noImplicitOverride",
710
- "noImplicitReturns",
711
- "noImplicitThis",
712
- "noPropertyAccessFromIndexSignature",
713
- "noUncheckedIndexedAccess",
714
- "noUnusedLocals",
715
- "noUnusedParameters",
716
- "useUnknownInCatchVariables",
717
- /* Completeness */
718
- "skipDefaultLibCheck",
719
- "skipLibCheck"
720
- ],
721
- pathPattern: "^compilerOptions$"
722
- }
723
- ]
684
+ ];
685
+ }
686
+ function sortTsconfig() {
687
+ return [
688
+ {
689
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
690
+ rules: {
691
+ "jsonc/sort-keys": [
692
+ "error",
693
+ {
694
+ order: [
695
+ "extends",
696
+ "compilerOptions",
697
+ "references",
698
+ "files",
699
+ "include",
700
+ "exclude"
701
+ ],
702
+ pathPattern: "^$"
703
+ },
704
+ {
705
+ order: [
706
+ /* Projects */
707
+ "incremental",
708
+ "composite",
709
+ "tsBuildInfoFile",
710
+ "disableSourceOfProjectReferenceRedirect",
711
+ "disableSolutionSearching",
712
+ "disableReferencedProjectLoad",
713
+ /* Language and Environment */
714
+ "target",
715
+ "lib",
716
+ "jsx",
717
+ "experimentalDecorators",
718
+ "emitDecoratorMetadata",
719
+ "jsxFactory",
720
+ "jsxFragmentFactory",
721
+ "jsxImportSource",
722
+ "reactNamespace",
723
+ "noLib",
724
+ "useDefineForClassFields",
725
+ "moduleDetection",
726
+ /* Modules */
727
+ "module",
728
+ "rootDir",
729
+ "moduleResolution",
730
+ "baseUrl",
731
+ "paths",
732
+ "rootDirs",
733
+ "typeRoots",
734
+ "types",
735
+ "allowUmdGlobalAccess",
736
+ "moduleSuffixes",
737
+ "allowImportingTsExtensions",
738
+ "resolvePackageJsonExports",
739
+ "resolvePackageJsonImports",
740
+ "customConditions",
741
+ "resolveJsonModule",
742
+ "allowArbitraryExtensions",
743
+ "noResolve",
744
+ /* JavaScript Support */
745
+ "allowJs",
746
+ "checkJs",
747
+ "maxNodeModuleJsDepth",
748
+ /* Emit */
749
+ "declaration",
750
+ "declarationMap",
751
+ "emitDeclarationOnly",
752
+ "sourceMap",
753
+ "inlineSourceMap",
754
+ "outFile",
755
+ "outDir",
756
+ "removeComments",
757
+ "noEmit",
758
+ "importHelpers",
759
+ "importsNotUsedAsValues",
760
+ "downlevelIteration",
761
+ "sourceRoot",
762
+ "mapRoot",
763
+ "inlineSources",
764
+ "emitBOM",
765
+ "newLine",
766
+ "stripInternal",
767
+ "noEmitHelpers",
768
+ "noEmitOnError",
769
+ "preserveConstEnums",
770
+ "declarationDir",
771
+ "preserveValueImports",
772
+ /* Interop Constraints */
773
+ "isolatedModules",
774
+ "verbatimModuleSyntax",
775
+ "allowSyntheticDefaultImports",
776
+ "esModuleInterop",
777
+ "preserveSymlinks",
778
+ "forceConsistentCasingInFileNames",
779
+ /* Type Checking */
780
+ "strict",
781
+ "strictBindCallApply",
782
+ "strictFunctionTypes",
783
+ "strictNullChecks",
784
+ "strictPropertyInitialization",
785
+ "allowUnreachableCode",
786
+ "allowUnusedLabels",
787
+ "alwaysStrict",
788
+ "exactOptionalPropertyTypes",
789
+ "noFallthroughCasesInSwitch",
790
+ "noImplicitAny",
791
+ "noImplicitOverride",
792
+ "noImplicitReturns",
793
+ "noImplicitThis",
794
+ "noPropertyAccessFromIndexSignature",
795
+ "noUncheckedIndexedAccess",
796
+ "noUnusedLocals",
797
+ "noUnusedParameters",
798
+ "useUnknownInCatchVariables",
799
+ /* Completeness */
800
+ "skipDefaultLibCheck",
801
+ "skipLibCheck"
802
+ ],
803
+ pathPattern: "^compilerOptions$"
804
+ }
805
+ ]
806
+ }
724
807
  }
725
- }
726
- ];
808
+ ];
809
+ }
727
810
 
728
811
  // src/configs/stylistic.ts
729
- import { packages } from "@eslint-stylistic/metadata";
730
- var tsPackage = packages.find((i) => i.shortId === "ts");
731
- var javascriptStylistic = [
732
- {
733
- plugins: {
734
- style: default9
735
- },
736
- rules: {
737
- "antfu/consistent-list-newline": "error",
738
- "antfu/if-newline": "error",
739
- "comma-dangle": ["error", "always-multiline"],
740
- "curly": ["error", "multi-or-nest", "consistent"],
741
- "quotes": ["error", "single"],
742
- "semi": ["error", "never"],
743
- "style/array-bracket-spacing": ["error", "never"],
744
- "style/arrow-spacing": ["error", { after: true, before: true }],
745
- "style/block-spacing": ["error", "always"],
746
- "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
747
- "style/comma-spacing": ["error", { after: true, before: false }],
748
- "style/comma-style": ["error", "last"],
749
- "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
750
- "style/dot-location": ["error", "property"],
751
- "style/func-call-spacing": OFF,
752
- "style/generator-star-spacing": OFF,
753
- "style/indent": ["error", 4, {
754
- ArrayExpression: 1,
755
- CallExpression: { arguments: 1 },
756
- FunctionDeclaration: { body: 1, parameters: 1 },
757
- FunctionExpression: { body: 1, parameters: 1 },
758
- ImportDeclaration: 1,
759
- MemberExpression: 1,
760
- ObjectExpression: 1,
761
- SwitchCase: 1,
762
- VariableDeclarator: 1,
763
- flatTernaryExpressions: false,
764
- ignoreComments: false,
765
- ignoredNodes: [
766
- "TemplateLiteral *",
767
- "JSXElement",
768
- "JSXElement > *",
769
- "JSXAttribute",
770
- "JSXIdentifier",
771
- "JSXNamespacedName",
772
- "JSXMemberExpression",
773
- "JSXSpreadAttribute",
774
- "JSXExpressionContainer",
775
- "JSXOpeningElement",
776
- "JSXClosingElement",
777
- "JSXFragment",
778
- "JSXOpeningFragment",
779
- "JSXClosingFragment",
780
- "JSXText",
781
- "JSXEmptyExpression",
782
- "JSXSpreadChild",
783
- "TSTypeParameterInstantiation",
784
- "FunctionExpression > .params[decorators.length > 0]",
785
- "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
786
- "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
787
- ],
788
- offsetTernaryExpressions: true,
789
- outerIIFEBody: 1
790
- }],
791
- "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
792
- "style/keyword-spacing": ["error", { after: true, before: true }],
793
- "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
794
- "style/multiline-ternary": ["error", "always-multiline"],
795
- "style/no-mixed-spaces-and-tabs": "error",
796
- "style/no-multi-spaces": "error",
797
- "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
798
- "style/no-tabs": "error",
799
- "style/no-trailing-spaces": "error",
800
- "style/no-whitespace-before-property": "error",
801
- "style/object-curly-newline": ["error", { consistent: true, multiline: true }],
802
- "style/object-curly-spacing": ["error", "always"],
803
- "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
804
- "style/operator-linebreak": ["error", "before"],
805
- "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
806
- "style/rest-spread-spacing": ["error", "never"],
807
- "style/semi-spacing": ["error", { after: true, before: false }],
808
- "style/space-before-blocks": ["error", "always"],
809
- "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
810
- "style/space-in-parens": ["error", "never"],
811
- "style/space-infix-ops": "error",
812
- "style/space-unary-ops": ["error", { nonwords: false, words: true }],
813
- "style/spaced-comment": ["error", "always", {
814
- block: {
815
- balanced: true,
816
- exceptions: ["*"],
817
- markers: ["!"]
818
- },
819
- line: {
820
- exceptions: ["/", "#"],
821
- markers: ["/"]
822
- }
823
- }],
824
- "style/template-curly-spacing": "error",
825
- "style/template-tag-spacing": ["error", "never"],
826
- "style/yield-star-spacing": ["error", "both"]
827
- }
828
- }
829
- ];
830
- var typescriptStylistic = [
831
- {
832
- plugins: {
833
- "style-ts": default10,
834
- "ts": default11
835
- },
836
- rules: {
837
- ...stylisticJsToTS(javascriptStylistic[0].rules),
838
- "comma-dangle": OFF,
839
- "quotes": OFF,
840
- "semi": OFF,
841
- "style-ts/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
842
- "style-ts/type-annotation-spacing": ["error", {}],
843
- "ts/comma-dangle": ["error", "always-multiline"],
844
- "ts/quotes": ["error", "single"],
845
- "ts/semi": ["error", "never"]
812
+ function stylistic(options = {}) {
813
+ const {
814
+ overrides = {}
815
+ } = options;
816
+ return [
817
+ {
818
+ plugins: {
819
+ antfu: default2,
820
+ style: default9
821
+ },
822
+ rules: {
823
+ "antfu/consistent-list-newline": "error",
824
+ "antfu/if-newline": "error",
825
+ "curly": ["error", "multi-or-nest", "consistent"],
826
+ "style/array-bracket-spacing": ["error", "never"],
827
+ "style/arrow-spacing": ["error", { after: true, before: true }],
828
+ "style/block-spacing": ["error", "always"],
829
+ "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
830
+ "style/comma-dangle": ["error", "always-multiline"],
831
+ "style/comma-spacing": ["error", { after: true, before: false }],
832
+ "style/comma-style": ["error", "last"],
833
+ "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
834
+ "style/dot-location": ["error", "property"],
835
+ "style/indent": ["error", 4, {
836
+ ArrayExpression: 1,
837
+ CallExpression: { arguments: 1 },
838
+ FunctionDeclaration: { body: 1, parameters: 1 },
839
+ FunctionExpression: { body: 1, parameters: 1 },
840
+ ImportDeclaration: 1,
841
+ MemberExpression: 1,
842
+ ObjectExpression: 1,
843
+ SwitchCase: 1,
844
+ VariableDeclarator: 1,
845
+ flatTernaryExpressions: false,
846
+ ignoreComments: false,
847
+ ignoredNodes: [
848
+ "TemplateLiteral *",
849
+ "JSXElement",
850
+ "JSXElement > *",
851
+ "JSXAttribute",
852
+ "JSXIdentifier",
853
+ "JSXNamespacedName",
854
+ "JSXMemberExpression",
855
+ "JSXSpreadAttribute",
856
+ "JSXExpressionContainer",
857
+ "JSXOpeningElement",
858
+ "JSXClosingElement",
859
+ "JSXFragment",
860
+ "JSXOpeningFragment",
861
+ "JSXClosingFragment",
862
+ "JSXText",
863
+ "JSXEmptyExpression",
864
+ "JSXSpreadChild",
865
+ "TSTypeParameterInstantiation",
866
+ "FunctionExpression > .params[decorators.length > 0]",
867
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
868
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
869
+ ],
870
+ offsetTernaryExpressions: true,
871
+ outerIIFEBody: 1
872
+ }],
873
+ "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
874
+ "style/keyword-spacing": ["error", { after: true, before: true }],
875
+ "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
876
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
877
+ "style/multiline-ternary": ["error", "always-multiline"],
878
+ "style/no-mixed-spaces-and-tabs": "error",
879
+ "style/no-multi-spaces": "error",
880
+ "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
881
+ "style/no-tabs": "error",
882
+ "style/no-trailing-spaces": "error",
883
+ "style/no-whitespace-before-property": "error",
884
+ "style/object-curly-newline": ["error", { consistent: true, multiline: true }],
885
+ "style/object-curly-spacing": ["error", "always"],
886
+ "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
887
+ "style/operator-linebreak": ["error", "before"],
888
+ "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
889
+ "style/quotes": ["error", "single"],
890
+ "style/rest-spread-spacing": ["error", "never"],
891
+ "style/semi": ["error", "never"],
892
+ "style/semi-spacing": ["error", { after: true, before: false }],
893
+ "style/space-before-blocks": ["error", "always"],
894
+ "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
895
+ "style/space-in-parens": ["error", "never"],
896
+ "style/space-infix-ops": "error",
897
+ "style/space-unary-ops": ["error", { nonwords: false, words: true }],
898
+ "style/spaced-comment": ["error", "always", {
899
+ block: {
900
+ balanced: true,
901
+ exceptions: ["*"],
902
+ markers: ["!"]
903
+ },
904
+ line: {
905
+ exceptions: ["/", "#"],
906
+ markers: ["/"]
907
+ }
908
+ }],
909
+ "style/template-curly-spacing": "error",
910
+ "style/template-tag-spacing": ["error", "never"],
911
+ "style/type-annotation-spacing": ["error", {}],
912
+ "style/yield-star-spacing": ["error", "both"],
913
+ ...overrides
914
+ }
846
915
  }
847
- }
848
- ];
849
- function stylisticJsToTS(input) {
850
- return {
851
- // turn off all stylistic rules from style
852
- ...Object.fromEntries(
853
- Object.entries(input).map(([key]) => {
854
- if (!key.startsWith("style/"))
855
- return null;
856
- const basename = key.replace("style/", "");
857
- if (tsPackage.rules.find((i) => i.name === basename))
858
- return [key, OFF];
859
- return null;
860
- }).filter(Boolean)
861
- ),
862
- // rename all stylistic rules from style to style/ts
863
- ...Object.fromEntries(
864
- Object.entries(input).map(([key, value]) => {
865
- if (!key.startsWith("style/"))
866
- return null;
867
- const basename = key.replace("style/", "");
868
- return tsPackage.rules.find((i) => i.name === basename) ? [`style-ts/${basename}`, value] : null;
869
- }).filter(Boolean)
870
- )
871
- };
916
+ ];
872
917
  }
873
918
 
874
919
  // src/configs/typescript.ts
@@ -887,13 +932,46 @@ function renameRules(rules, from, to) {
887
932
  })
888
933
  );
889
934
  }
935
+ var rulesOn = /* @__PURE__ */ new Set();
936
+ var rulesOff = /* @__PURE__ */ new Set();
937
+ function recordRulesStateConfigs(configs) {
938
+ for (const config of configs)
939
+ recordRulesState(config.rules ?? {});
940
+ return configs;
941
+ }
942
+ function recordRulesState(rules) {
943
+ for (const [key, value] of Object.entries(rules ?? {})) {
944
+ const firstValue = Array.isArray(value) ? value[0] : value;
945
+ if (firstValue == null)
946
+ continue;
947
+ if (firstValue === "off" || firstValue === 0)
948
+ rulesOff.add(key);
949
+ else
950
+ rulesOn.add(key);
951
+ }
952
+ return rules;
953
+ }
954
+ function warnUnnecessaryOffRules() {
955
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
956
+ for (const off of unnecessaryOffRules)
957
+ console.warn(`[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`);
958
+ }
890
959
 
891
960
  // src/configs/typescript.ts
892
961
  function typescript(options) {
893
962
  const {
894
- componentExts = []
963
+ componentExts = [],
964
+ overrides = {}
895
965
  } = options ?? {};
896
966
  return [
967
+ {
968
+ // Install the plugins without globs, so they can be configured separately.
969
+ plugins: {
970
+ antfu: default2,
971
+ import: default4,
972
+ ts: default10
973
+ }
974
+ },
897
975
  {
898
976
  files: [
899
977
  GLOB_TS,
@@ -901,24 +979,19 @@ function typescript(options) {
901
979
  ...componentExts.map((ext) => `**/*.${ext}`)
902
980
  ],
903
981
  languageOptions: {
904
- parser: default17,
982
+ parser: default16,
905
983
  parserOptions: {
906
984
  sourceType: "module"
907
985
  }
908
986
  },
909
- plugins: {
910
- antfu: default2,
911
- import: default4,
912
- ts: default11
913
- },
914
987
  rules: {
915
988
  ...renameRules(
916
- default11.configs["eslint-recommended"].overrides[0].rules,
989
+ default10.configs["eslint-recommended"].overrides[0].rules,
917
990
  "@typescript-eslint/",
918
991
  "ts/"
919
992
  ),
920
993
  ...renameRules(
921
- default11.configs.strict.rules,
994
+ default10.configs.strict.rules,
922
995
  "@typescript-eslint/",
923
996
  "ts/"
924
997
  ),
@@ -935,18 +1008,10 @@ function typescript(options) {
935
1008
  "no-use-before-define": OFF,
936
1009
  "no-useless-constructor": OFF,
937
1010
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
938
- "ts/ban-ts-ignore": OFF,
939
- "ts/consistent-indexed-object-style": OFF,
940
1011
  "ts/consistent-type-definitions": ["error", "interface"],
941
1012
  "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
942
- "ts/explicit-function-return-type": OFF,
943
- "ts/explicit-member-accessibility": OFF,
944
- "ts/explicit-module-boundary-types": OFF,
945
- "ts/naming-convention": OFF,
946
1013
  "ts/no-dupe-class-members": "error",
947
1014
  "ts/no-dynamic-delete": OFF,
948
- "ts/no-empty-function": OFF,
949
- "ts/no-empty-interface": OFF,
950
1015
  "ts/no-explicit-any": OFF,
951
1016
  "ts/no-extra-parens": ["error", "functions"],
952
1017
  "ts/no-invalid-this": "error",
@@ -957,10 +1022,10 @@ function typescript(options) {
957
1022
  "ts/no-require-imports": "error",
958
1023
  "ts/no-unused-vars": OFF,
959
1024
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
960
- "ts/parameter-properties": OFF,
961
1025
  "ts/prefer-ts-expect-error": "error",
962
1026
  "ts/triple-slash-reference": OFF,
963
- "ts/unified-signatures": OFF
1027
+ "ts/unified-signatures": OFF,
1028
+ ...overrides
964
1029
  }
965
1030
  },
966
1031
  {
@@ -986,30 +1051,29 @@ function typescript(options) {
986
1051
  }
987
1052
  ];
988
1053
  }
989
- function typescriptWithLanguageServer(options) {
1054
+ function typescriptWithTypes(options) {
990
1055
  const {
991
1056
  componentExts = [],
992
1057
  tsconfigPath,
993
- tsconfigRootDir = process.cwd()
1058
+ tsconfigRootDir = process.cwd(),
1059
+ overrides = {}
994
1060
  } = options;
995
1061
  return [
996
1062
  {
997
1063
  files: [
998
1064
  GLOB_TS,
999
1065
  GLOB_TSX,
1000
- ...componentExts.map((ext) => `**/*.${ext}`)
1066
+ ...componentExts.map((ext) => `**/*.${ext}`),
1067
+ "!**/*.md/*.*"
1001
1068
  ],
1002
1069
  ignores: ["**/*.md/*.*"],
1003
1070
  languageOptions: {
1004
- parser: default17,
1071
+ parser: default16,
1005
1072
  parserOptions: {
1006
1073
  project: [tsconfigPath],
1007
1074
  tsconfigRootDir
1008
1075
  }
1009
1076
  },
1010
- plugins: {
1011
- ts: default11
1012
- },
1013
1077
  rules: {
1014
1078
  "dot-notation": OFF,
1015
1079
  "no-implied-eval": OFF,
@@ -1029,50 +1093,53 @@ function typescriptWithLanguageServer(options) {
1029
1093
  "ts/no-unsafe-return": "error",
1030
1094
  "ts/restrict-plus-operands": "error",
1031
1095
  "ts/restrict-template-expressions": "error",
1032
- "ts/unbound-method": "error"
1096
+ "ts/unbound-method": "error",
1097
+ ...overrides
1033
1098
  }
1034
1099
  }
1035
1100
  ];
1036
1101
  }
1037
1102
 
1038
1103
  // src/configs/unicorn.ts
1039
- var unicorn = [
1040
- {
1041
- plugins: {
1042
- unicorn: default12
1043
- },
1044
- rules: {
1045
- // Pass error message when throwing errors
1046
- "unicorn/error-message": "error",
1047
- // Uppercase regex escapes
1048
- "unicorn/escape-case": "error",
1049
- // Array.isArray instead of instanceof
1050
- "unicorn/no-instanceof-array": "error",
1051
- // Ban `new Array` as `Array` constructor's params are ambiguous
1052
- "unicorn/no-new-array": "error",
1053
- // Prevent deprecated `new Buffer()`
1054
- "unicorn/no-new-buffer": "error",
1055
- // Keep regex literals safe!
1056
- "unicorn/no-unsafe-regex": "error",
1057
- // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1058
- "unicorn/number-literal-case": "error",
1059
- // includes over indexOf when checking for existence
1060
- "unicorn/prefer-includes": "error",
1061
- // Prefer using the node: protocol
1062
- "unicorn/prefer-node-protocol": "error",
1063
- // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1064
- "unicorn/prefer-number-properties": "error",
1065
- // String methods startsWith/endsWith instead of more complicated stuff
1066
- "unicorn/prefer-string-starts-ends-with": "error",
1067
- // textContent instead of innerText
1068
- "unicorn/prefer-text-content": "error",
1069
- // Enforce throwing type error when throwing error while checking typeof
1070
- "unicorn/prefer-type-error": "error",
1071
- // Use new when throwing error
1072
- "unicorn/throw-new-error": "error"
1104
+ function unicorn() {
1105
+ return [
1106
+ {
1107
+ plugins: {
1108
+ unicorn: default11
1109
+ },
1110
+ rules: {
1111
+ // Pass error message when throwing errors
1112
+ "unicorn/error-message": "error",
1113
+ // Uppercase regex escapes
1114
+ "unicorn/escape-case": "error",
1115
+ // Array.isArray instead of instanceof
1116
+ "unicorn/no-instanceof-array": "error",
1117
+ // Ban `new Array` as `Array` constructor's params are ambiguous
1118
+ "unicorn/no-new-array": "error",
1119
+ // Prevent deprecated `new Buffer()`
1120
+ "unicorn/no-new-buffer": "error",
1121
+ // Keep regex literals safe!
1122
+ "unicorn/no-unsafe-regex": "error",
1123
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1124
+ "unicorn/number-literal-case": "error",
1125
+ // includes over indexOf when checking for existence
1126
+ "unicorn/prefer-includes": "error",
1127
+ // Prefer using the node: protocol
1128
+ "unicorn/prefer-node-protocol": "error",
1129
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1130
+ "unicorn/prefer-number-properties": "error",
1131
+ // String methods startsWith/endsWith instead of more complicated stuff
1132
+ "unicorn/prefer-string-starts-ends-with": "error",
1133
+ // textContent instead of innerText
1134
+ "unicorn/prefer-text-content": "error",
1135
+ // Enforce throwing type error when throwing error while checking typeof
1136
+ "unicorn/prefer-type-error": "error",
1137
+ // Use new when throwing error
1138
+ "unicorn/throw-new-error": "error"
1139
+ }
1073
1140
  }
1074
- }
1075
- ];
1141
+ ];
1142
+ }
1076
1143
 
1077
1144
  // src/configs/vue.ts
1078
1145
  var pkg = getPackageInfoSync("vue");
@@ -1080,34 +1147,39 @@ var vueVersion = pkg && pkg.version;
1080
1147
  vueVersion = vueVersion && vueVersion[0];
1081
1148
  vueVersion = Number.isNaN(vueVersion) ? "3" : vueVersion;
1082
1149
  function vue(options = {}) {
1150
+ const {
1151
+ overrides = {}
1152
+ } = options;
1083
1153
  return [
1154
+ {
1155
+ plugins: {
1156
+ vue: default13
1157
+ }
1158
+ },
1084
1159
  {
1085
1160
  files: [GLOB_VUE],
1086
1161
  languageOptions: {
1087
- parser: default18,
1162
+ parser: default17,
1088
1163
  parserOptions: {
1089
1164
  ecmaFeatures: {
1090
1165
  jsx: true
1091
1166
  },
1092
1167
  extraFileExtensions: [".vue"],
1093
- parser: options.typescript ? default17 : null,
1168
+ parser: options.typescript ? default16 : null,
1094
1169
  sourceType: "module"
1095
1170
  }
1096
1171
  },
1097
- plugins: {
1098
- vue: default14
1099
- },
1100
- processor: default14.processors[".vue"],
1172
+ processor: default13.processors[".vue"],
1101
1173
  rules: {
1102
- ...default14.configs.base.rules,
1174
+ ...default13.configs.base.rules,
1103
1175
  ...vueVersion === "3" ? {
1104
- ...default14.configs["vue3-essential"].rules,
1105
- ...default14.configs["vue3-strongly-recommended"].rules,
1106
- ...default14.configs["vue3-recommended"].rules
1176
+ ...default13.configs["vue3-essential"].rules,
1177
+ ...default13.configs["vue3-strongly-recommended"].rules,
1178
+ ...default13.configs["vue3-recommended"].rules
1107
1179
  } : {
1108
- ...default14.configs.essential.rules,
1109
- ...default14.configs["strongly-recommended"].rules,
1110
- ...default14.configs.recommended.rules
1180
+ ...default13.configs.essential.rules,
1181
+ ...default13.configs["strongly-recommended"].rules,
1182
+ ...default13.configs.recommended.rules
1111
1183
  },
1112
1184
  "node/prefer-global/process": OFF,
1113
1185
  "vue/array-bracket-spacing": ["error", "never"],
@@ -1198,42 +1270,72 @@ function vue(options = {}) {
1198
1270
  "vue/space-in-parens": ["error", "never"],
1199
1271
  "vue/space-infix-ops": "error",
1200
1272
  "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1201
- "vue/template-curly-spacing": "error"
1273
+ "vue/template-curly-spacing": "error",
1274
+ ...overrides
1202
1275
  }
1203
1276
  }
1204
1277
  ];
1205
1278
  }
1206
1279
 
1207
- // src/configs/yml.ts
1208
- var yml = [
1209
- {
1210
- files: [GLOB_YAML],
1211
- languageOptions: {
1212
- parser: default19
1213
- },
1214
- plugins: {
1215
- yml: default15
1280
+ // src/configs/yaml.ts
1281
+ function yaml(options = {}) {
1282
+ const {
1283
+ overrides = {}
1284
+ } = options;
1285
+ return [
1286
+ {
1287
+ plugins: {
1288
+ yaml: default14
1289
+ }
1216
1290
  },
1217
- rules: {
1218
- ...default15.configs.standard.rules,
1219
- "style/spaced-comment": OFF,
1220
- "yml/no-empty-document": OFF,
1221
- "yml/no-empty-mapping-value": OFF,
1222
- "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }]
1291
+ {
1292
+ files: [GLOB_YAML],
1293
+ languageOptions: {
1294
+ parser: default18
1295
+ },
1296
+ rules: {
1297
+ "style/spaced-comment": OFF,
1298
+ "yaml/block-mapping": "error",
1299
+ "yaml/block-mapping-question-indicator-newline": "error",
1300
+ "yaml/block-sequence": "error",
1301
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1302
+ "yaml/flow-mapping-curly-newline": "error",
1303
+ "yaml/flow-mapping-curly-spacing": "error",
1304
+ "yaml/flow-sequence-bracket-newline": "error",
1305
+ "yaml/flow-sequence-bracket-spacing": "error",
1306
+ "yaml/indent": ["error", 2],
1307
+ "yaml/key-spacing": "error",
1308
+ "yaml/no-empty-key": "error",
1309
+ "yaml/no-empty-sequence-entry": "error",
1310
+ "yaml/no-irregular-whitespace": "error",
1311
+ "yaml/no-tab-indent": "error",
1312
+ "yaml/plain-scalar": "error",
1313
+ "yaml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
1314
+ "yaml/spaced-comment": "error",
1315
+ "yaml/vue-custom-block/no-parsing-error": "error",
1316
+ ...overrides
1317
+ }
1223
1318
  }
1224
- }
1225
- ];
1319
+ ];
1320
+ }
1226
1321
 
1227
1322
  // src/configs/test.ts
1228
1323
  function test(options = {}) {
1324
+ const {
1325
+ isInEditor = false,
1326
+ overrides = {}
1327
+ } = options;
1229
1328
  return [
1230
1329
  {
1231
- files: GLOB_TESTS,
1232
1330
  plugins: {
1233
- "no-only-tests": default16
1234
- },
1331
+ "no-only-tests": default15
1332
+ }
1333
+ },
1334
+ {
1335
+ files: GLOB_TESTS,
1235
1336
  rules: {
1236
- "no-only-tests/no-only-tests": options.isInEditor ? OFF : "error"
1337
+ "no-only-tests/no-only-tests": isInEditor ? OFF : "error",
1338
+ ...overrides
1237
1339
  }
1238
1340
  }
1239
1341
  ];
@@ -1250,12 +1352,21 @@ var flatConfigProps = [
1250
1352
  "rules",
1251
1353
  "settings"
1252
1354
  ];
1355
+ var VuePackages = [
1356
+ "vue",
1357
+ "nuxt",
1358
+ "vitepress",
1359
+ "@slidev/cli"
1360
+ ];
1253
1361
  function lincy(options = {}, ...userConfigs) {
1254
- const isInEditor = options.isInEditor ?? !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI);
1255
- const enableVue = options.vue ?? (isPackageExists("vue") || isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("@slidev/cli"));
1256
- const enableTypeScript = options.typescript ?? isPackageExists("typescript");
1257
- const enableStylistic = options.stylistic ?? true;
1258
- const enableGitignore = options.gitignore ?? true;
1362
+ const {
1363
+ isInEditor = !!((process2.env.VSCODE_PID || process2.env.JETBRAINS_IDE) && !process2.env.CI),
1364
+ vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1365
+ typescript: enableTypeScript = isPackageExists("typescript"),
1366
+ stylistic: enableStylistic = true,
1367
+ gitignore: enableGitignore = true,
1368
+ overrides = {}
1369
+ } = options;
1259
1370
  const configs = [];
1260
1371
  if (enableGitignore) {
1261
1372
  if (typeof enableGitignore !== "boolean") {
@@ -1266,45 +1377,64 @@ function lincy(options = {}, ...userConfigs) {
1266
1377
  }
1267
1378
  }
1268
1379
  configs.push(
1269
- ignores,
1270
- javascript({ isInEditor }),
1271
- comments,
1272
- node,
1273
- jsdoc,
1274
- imports,
1275
- unicorn
1380
+ ignores({
1381
+ ignores: overrides.ignores
1382
+ }),
1383
+ javascript({
1384
+ isInEditor,
1385
+ overrides: overrides.javascript
1386
+ }),
1387
+ comments(),
1388
+ node(),
1389
+ jsdoc(),
1390
+ imports(),
1391
+ unicorn()
1276
1392
  );
1277
1393
  const componentExts = [];
1278
1394
  if (enableVue)
1279
1395
  componentExts.push("vue");
1280
- if (enableStylistic)
1281
- configs.push(javascriptStylistic);
1282
1396
  if (enableTypeScript) {
1283
- configs.push(typescript({ componentExts }));
1397
+ configs.push(typescript({
1398
+ componentExts,
1399
+ overrides: overrides.typescript
1400
+ }));
1284
1401
  if (typeof enableTypeScript !== "boolean") {
1285
- configs.push(typescriptWithLanguageServer({
1402
+ configs.push(typescriptWithTypes({
1286
1403
  ...enableTypeScript,
1287
- componentExts
1404
+ componentExts,
1405
+ overrides: overrides.typescriptWithTypes
1288
1406
  }));
1289
1407
  }
1290
- if (enableStylistic)
1291
- configs.push(typescriptStylistic);
1292
1408
  }
1293
- if (options.test ?? true)
1294
- configs.push(test({ isInEditor }));
1295
- if (enableVue)
1296
- configs.push(vue({ typescript: !!enableTypeScript }));
1409
+ if (enableStylistic)
1410
+ configs.push(stylistic());
1411
+ if (options.test ?? true) {
1412
+ configs.push(test({
1413
+ isInEditor,
1414
+ overrides: overrides.test
1415
+ }));
1416
+ }
1417
+ if (enableVue) {
1418
+ configs.push(vue({
1419
+ overrides: overrides.vue,
1420
+ typescript: !!enableTypeScript
1421
+ }));
1422
+ }
1297
1423
  if (options.jsonc ?? true) {
1298
1424
  configs.push(
1299
- jsonc,
1300
- sortPackageJson,
1301
- sortTsconfig
1425
+ jsonc(),
1426
+ sortPackageJson(),
1427
+ sortTsconfig()
1302
1428
  );
1303
1429
  }
1304
1430
  if (options.yaml ?? true)
1305
- configs.push(yml);
1306
- if (options.markdown ?? true)
1307
- configs.push(markdown({ componentExts }));
1431
+ configs.push(yaml());
1432
+ if (options.markdown ?? true) {
1433
+ configs.push(markdown({
1434
+ componentExts,
1435
+ overrides: overrides.markdown
1436
+ }));
1437
+ }
1308
1438
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
1309
1439
  if (key in options)
1310
1440
  acc[key] = options[key];
@@ -1312,54 +1442,77 @@ function lincy(options = {}, ...userConfigs) {
1312
1442
  }, {});
1313
1443
  if (Object.keys(fusedConfig).length)
1314
1444
  configs.push([fusedConfig]);
1315
- return combine(
1445
+ const merged = combine(
1316
1446
  ...configs,
1317
1447
  ...userConfigs
1318
1448
  );
1449
+ return merged;
1319
1450
  }
1320
1451
 
1321
1452
  // src/index.ts
1322
1453
  var src_default = lincy;
1323
1454
  export {
1455
+ GLOB_ALL_SRC,
1456
+ GLOB_CSS,
1457
+ GLOB_EXCLUDE,
1458
+ GLOB_HTML,
1459
+ GLOB_JS,
1460
+ GLOB_JSON,
1461
+ GLOB_JSON5,
1462
+ GLOB_JSONC,
1463
+ GLOB_JSX,
1464
+ GLOB_LESS,
1465
+ GLOB_MARKDOWN,
1466
+ GLOB_MARKDOWN_CODE,
1467
+ GLOB_SCSS,
1468
+ GLOB_SRC,
1469
+ GLOB_SRC_EXT,
1470
+ GLOB_STYLE,
1471
+ GLOB_TESTS,
1472
+ GLOB_TS,
1473
+ GLOB_TSX,
1474
+ GLOB_VUE,
1475
+ GLOB_YAML,
1324
1476
  combine,
1325
1477
  comments,
1326
1478
  src_default as default,
1327
1479
  ignores,
1328
1480
  imports,
1329
1481
  javascript,
1330
- javascriptStylistic,
1331
1482
  jsdoc,
1332
1483
  jsonc,
1333
1484
  lincy,
1334
1485
  markdown,
1335
1486
  node,
1336
- default20 as parserJsonc,
1337
- default17 as parserTs,
1338
- default18 as parserVue,
1339
- default19 as parserYml,
1487
+ default19 as parserJsonc,
1488
+ default16 as parserTs,
1489
+ default17 as parserVue,
1490
+ default18 as parserYaml,
1340
1491
  default2 as pluginAntfu,
1341
1492
  default3 as pluginComments,
1342
1493
  default4 as pluginImport,
1343
1494
  default5 as pluginJsdoc,
1344
1495
  default6 as pluginJsonc,
1345
1496
  default7 as pluginMarkdown,
1346
- default16 as pluginNoOnlyTests,
1497
+ default15 as pluginNoOnlyTests,
1347
1498
  default8 as pluginNode,
1348
- default9 as pluginStylisticJs,
1349
- default10 as pluginStylisticTs,
1350
- default11 as pluginTs,
1351
- default12 as pluginUnicorn,
1352
- default13 as pluginUnusedImports,
1353
- default14 as pluginVue,
1354
- default15 as pluginYml,
1499
+ default9 as pluginStylistic,
1500
+ default10 as pluginTs,
1501
+ default11 as pluginUnicorn,
1502
+ default12 as pluginUnusedImports,
1503
+ default13 as pluginVue,
1504
+ default14 as pluginYaml,
1505
+ recordRulesState,
1506
+ recordRulesStateConfigs,
1355
1507
  renameRules,
1356
1508
  sortPackageJson,
1357
1509
  sortTsconfig,
1510
+ stylistic,
1358
1511
  test,
1359
1512
  typescript,
1360
- typescriptStylistic,
1361
- typescriptWithLanguageServer,
1513
+ typescriptWithTypes,
1362
1514
  unicorn,
1363
1515
  vue,
1364
- yml
1516
+ warnUnnecessaryOffRules,
1517
+ yaml
1365
1518
  };