@solvro/config 1.1.0 → 1.2.1

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.
@@ -1,35 +1,7 @@
1
- import {
2
- init_esm_shims
3
- } from "../chunk-62DEEFN2.js";
4
-
5
1
  // eslint-config/index.ts
6
- init_esm_shims();
7
-
8
- // eslint-config/factory.ts
9
- init_esm_shims();
10
- import { FlatConfigComposer } from "eslint-flat-config-utils";
11
- import { isPackageExists as isPackageExists3 } from "local-pkg";
12
-
13
- // eslint-config/configs/index.ts
14
- init_esm_shims();
15
-
16
- // eslint-config/configs/command.ts
17
- init_esm_shims();
18
- import createCommand from "eslint-plugin-command/config";
19
- async function command() {
20
- return [
21
- {
22
- ...createCommand(),
23
- name: "solvro/command/rules"
24
- }
25
- ];
26
- }
27
-
28
- // eslint-config/configs/comments.ts
29
- init_esm_shims();
2
+ import tseslint2 from "typescript-eslint";
30
3
 
31
4
  // eslint-config/plugins.ts
32
- init_esm_shims();
33
5
  import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
34
6
  import { default as default3 } from "eslint-plugin-antfu";
35
7
  import * as pluginImport from "eslint-plugin-import-x";
@@ -39,11 +11,12 @@ import { default as default6 } from "eslint-plugin-unicorn";
39
11
  import { default as default7 } from "eslint-plugin-unused-imports";
40
12
 
41
13
  // eslint-config/configs/comments.ts
42
- async function comments() {
14
+ function comments() {
43
15
  return [
44
16
  {
45
17
  name: "solvro/eslint-comments/rules",
46
18
  plugins: {
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
47
20
  "eslint-comments": default2
48
21
  },
49
22
  rules: {
@@ -56,26 +29,10 @@ async function comments() {
56
29
  ];
57
30
  }
58
31
 
59
- // eslint-config/configs/disables.ts
60
- init_esm_shims();
61
-
62
32
  // eslint-config/globs.ts
63
- init_esm_shims();
64
33
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
65
34
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
66
- var GLOB_JS = "**/*.?([cm])js";
67
- var GLOB_JSX = "**/*.?([cm])jsx";
68
- var GLOB_TS = "**/*.?([cm])ts";
69
- var GLOB_TSX = "**/*.?([cm])tsx";
70
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
71
- var GLOB_JSON = "**/*.json";
72
- var GLOB_JSON5 = "**/*.json5";
73
35
  var GLOB_MARKDOWN = "**/*.md";
74
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
75
- var GLOB_TOML = "**/*.toml";
76
- var GLOB_XML = "**/*.xml";
77
- var GLOB_SVG = "**/*.svg";
78
- var GLOB_HTML = "**/*.htm?(l)";
79
36
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
80
37
  var GLOB_TESTS = [
81
38
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -84,15 +41,6 @@ var GLOB_TESTS = [
84
41
  `**/*.bench.${GLOB_SRC_EXT}`,
85
42
  `**/*.benchmark.${GLOB_SRC_EXT}`
86
43
  ];
87
- var GLOB_ALL_SRC = [
88
- GLOB_SRC,
89
- GLOB_STYLE,
90
- GLOB_JSON,
91
- GLOB_JSON5,
92
- GLOB_MARKDOWN,
93
- GLOB_XML,
94
- GLOB_HTML
95
- ];
96
44
  var GLOB_EXCLUDE = [
97
45
  "**/node_modules",
98
46
  "**/dist",
@@ -128,7 +76,7 @@ var GLOB_EXCLUDE = [
128
76
  ];
129
77
 
130
78
  // eslint-config/configs/disables.ts
131
- async function disables() {
79
+ function disables() {
132
80
  return [
133
81
  {
134
82
  files: [`**/scripts/${GLOB_SRC}`],
@@ -185,100 +133,34 @@ async function disables() {
185
133
  }
186
134
 
187
135
  // eslint-config/configs/formatters.ts
188
- init_esm_shims();
189
-
190
- // eslint-config/utils.ts
191
- init_esm_shims();
192
- import { isPackageExists } from "local-pkg";
193
- import process from "node:process";
194
- import { fileURLToPath } from "node:url";
195
- var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
196
- var isCwdInScope = isPackageExists("@solvro/config");
197
- var parserPlain = {
198
- meta: {
199
- name: "parser-plain"
200
- },
201
- parseForESLint: (code) => ({
202
- ast: {
203
- body: [],
204
- comments: [],
205
- loc: { end: code.length, start: 0 },
206
- range: [0, code.length],
207
- tokens: [],
208
- type: "Program"
209
- },
210
- scopeManager: null,
211
- services: { isPlain: true },
212
- visitorKeys: {
213
- Program: []
136
+ import prettierConfig from "eslint-config-prettier";
137
+ function formatters() {
138
+ return [
139
+ {
140
+ name: "solvro/prettier",
141
+ ...prettierConfig
214
142
  }
215
- })
216
- };
217
- async function combine(...configs2) {
218
- const resolved = await Promise.all(configs2);
219
- return resolved.flat();
220
- }
221
- function toArray(value) {
222
- return Array.isArray(value) ? value : [value];
223
- }
224
- async function interopDefault(m) {
225
- const resolved = await m;
226
- return resolved.default || resolved;
227
- }
228
- function isPackageInScope(name) {
229
- return isPackageExists(name, { paths: [scopeUrl] });
230
- }
231
- async function ensurePackages(packages) {
232
- if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
233
- return;
234
- const nonExistingPackages = packages.filter(
235
- (i) => i && !isPackageInScope(i)
236
- );
237
- if (nonExistingPackages.length === 0) return;
238
- const p = await import("@clack/prompts");
239
- const result = await p.confirm({
240
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
241
- });
242
- if (result)
243
- await import("@antfu/install-pkg").then(
244
- (i) => i.installPackage(nonExistingPackages, { dev: true })
245
- );
246
- }
247
- function isInEditorEnv() {
248
- if (process.env.CI) return false;
249
- if (isInGitHooksOrLintStaged()) return false;
250
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
251
- }
252
- function isInGitHooksOrLintStaged() {
253
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
254
- }
255
-
256
- // eslint-config/configs/formatters.ts
257
- async function formatters() {
258
- await ensurePackages(["eslint-plugin-prettier"]);
259
- const prettierConfig = await interopDefault(import("../eslint-config-prettier-ZT22JTBW.js"));
260
- return [prettierConfig];
143
+ ];
261
144
  }
262
145
 
263
146
  // eslint-config/configs/ignores.ts
264
- init_esm_shims();
265
- async function ignores(userIgnores = []) {
147
+ function ignores() {
266
148
  return [
267
149
  {
268
- ignores: [...GLOB_EXCLUDE, ...userIgnores],
150
+ ignores: [...GLOB_EXCLUDE],
269
151
  name: "solvro/ignores"
270
152
  }
271
153
  ];
272
154
  }
273
155
 
274
156
  // eslint-config/configs/imports.ts
275
- init_esm_shims();
276
- async function imports() {
157
+ function imports() {
277
158
  return [
278
159
  {
279
160
  name: "solvro/imports/rules",
280
161
  plugins: {
281
162
  antfu: default3,
163
+ // @ts-expect-error ???
282
164
  "import-x": pluginImport
283
165
  },
284
166
  rules: {
@@ -297,10 +179,9 @@ async function imports() {
297
179
  }
298
180
 
299
181
  // eslint-config/configs/javascript.ts
300
- init_esm_shims();
182
+ import eslint from "@eslint/js";
301
183
  import globals from "globals";
302
- async function javascript(options = {}) {
303
- const { isInEditor = false, overrides = {} } = options;
184
+ function javascript() {
304
185
  return [
305
186
  {
306
187
  languageOptions: {
@@ -334,6 +215,7 @@ async function javascript(options = {}) {
334
215
  "unused-imports": default7
335
216
  },
336
217
  rules: {
218
+ ...eslint.configs.recommended.rules,
337
219
  "accessor-pairs": [
338
220
  "error",
339
221
  { enforceForClassMembers: true, setWithoutGet: true }
@@ -509,7 +391,7 @@ async function javascript(options = {}) {
509
391
  "prefer-template": "error",
510
392
  "symbol-description": "error",
511
393
  "unicode-bom": ["error", "never"],
512
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
394
+ "unused-imports/no-unused-imports": "error",
513
395
  "unused-imports/no-unused-vars": [
514
396
  "error",
515
397
  {
@@ -526,21 +408,20 @@ async function javascript(options = {}) {
526
408
  ],
527
409
  "valid-typeof": ["error", { requireStringLiterals: true }],
528
410
  "vars-on-top": "error",
529
- yoda: ["error", "never"],
530
- ...overrides
411
+ yoda: ["error", "never"]
531
412
  }
532
413
  }
533
414
  ];
534
415
  }
535
416
 
536
417
  // eslint-config/configs/jsdoc.ts
537
- init_esm_shims();
538
- async function jsdoc() {
418
+ import jsdocPlugin from "eslint-plugin-jsdoc";
419
+ function jsdoc() {
539
420
  return [
540
421
  {
541
422
  name: "solvro/jsdoc/rules",
542
423
  plugins: {
543
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
424
+ jsdoc: jsdocPlugin
544
425
  },
545
426
  rules: {
546
427
  "jsdoc/check-access": "warn",
@@ -563,105 +444,8 @@ async function jsdoc() {
563
444
  ];
564
445
  }
565
446
 
566
- // eslint-config/configs/jsx.ts
567
- init_esm_shims();
568
- async function jsx() {
569
- return [
570
- {
571
- files: [GLOB_JSX, GLOB_TSX],
572
- languageOptions: {
573
- parserOptions: {
574
- ecmaFeatures: {
575
- jsx: true
576
- }
577
- }
578
- },
579
- name: "solvro/jsx/setup"
580
- }
581
- ];
582
- }
583
-
584
- // eslint-config/configs/markdown.ts
585
- init_esm_shims();
586
- import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
587
- async function markdown(options = {}) {
588
- const {
589
- componentExts = [],
590
- files = [GLOB_MARKDOWN],
591
- overrides = {}
592
- } = options;
593
- const markdown2 = await interopDefault(import("@eslint/markdown"));
594
- return [
595
- {
596
- name: "solvro/markdown/setup",
597
- plugins: {
598
- markdown: markdown2
599
- }
600
- },
601
- {
602
- files,
603
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
604
- name: "solvro/markdown/processor",
605
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
606
- // but not the markdown file itself. We use `eslint-merge-processors` to
607
- // add a pass-through processor for the markdown file itself.
608
- processor: mergeProcessors([
609
- markdown2.processors.markdown,
610
- processorPassThrough
611
- ])
612
- },
613
- {
614
- files,
615
- languageOptions: {
616
- parser: parserPlain
617
- },
618
- name: "solvro/markdown/parser"
619
- },
620
- {
621
- files: [
622
- GLOB_MARKDOWN_CODE,
623
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
624
- ],
625
- languageOptions: {
626
- parserOptions: {
627
- ecmaFeatures: {
628
- impliedStrict: true
629
- }
630
- }
631
- },
632
- name: "solvro/markdown/disables",
633
- rules: {
634
- "antfu/no-top-level-await": "off",
635
- "no-alert": "off",
636
- "no-console": "off",
637
- "no-labels": "off",
638
- "no-lone-blocks": "off",
639
- "no-restricted-syntax": "off",
640
- "no-undef": "off",
641
- "no-unused-expressions": "off",
642
- "no-unused-labels": "off",
643
- "no-unused-vars": "off",
644
- "node/prefer-global/process": "off",
645
- "@typescript-eslint/consistent-type-imports": "off",
646
- "@typescript-eslint/explicit-function-return-type": "off",
647
- "@typescript-eslint/no-namespace": "off",
648
- "@typescript-eslint/no-redeclare": "off",
649
- "@typescript-eslint/no-require-imports": "off",
650
- "@typescript-eslint/no-unused-expressions": "off",
651
- "@typescript-eslint/no-unused-vars": "off",
652
- "@typescript-eslint/no-use-before-define": "off",
653
- "unicode-bom": "off",
654
- "unused-imports/no-unused-imports": "off",
655
- "unused-imports/no-unused-vars": "off",
656
- ...overrides
657
- }
658
- }
659
- ];
660
- }
661
-
662
447
  // eslint-config/configs/node.ts
663
- init_esm_shims();
664
- async function node() {
448
+ function node() {
665
449
  return [
666
450
  {
667
451
  name: "solvro/node/rules",
@@ -683,47 +467,23 @@ async function node() {
683
467
  }
684
468
 
685
469
  // eslint-config/configs/react.ts
686
- init_esm_shims();
687
- import { isPackageExists as isPackageExists2 } from "local-pkg";
688
- var ReactRefreshAllowConstantExportPackages = ["vite"];
470
+ import nextPlugin from "@next/eslint-plugin-next";
471
+ import pluginReact from "eslint-plugin-react";
472
+ import pluginReactHooks from "eslint-plugin-react-hooks";
473
+ import pluginReactRefresh from "eslint-plugin-react-refresh";
474
+ import { isPackageExists } from "local-pkg";
689
475
  var NextJsPackages = ["next"];
690
- async function react(options = {}) {
691
- const {
692
- files = [GLOB_SRC],
693
- filesTypeAware = [GLOB_TS, GLOB_TSX],
694
- ignoresTypeAware = [`${GLOB_MARKDOWN}/**`],
695
- overrides = {},
696
- tsconfigPath
697
- } = options;
698
- await ensurePackages([
699
- "eslint-plugin-react",
700
- "eslint-plugin-react-hooks",
701
- "eslint-plugin-react-refresh"
702
- ]);
703
- const isTypeAware = !!tsconfigPath;
704
- const typeAwareRules = {
705
- "react/jsx-no-leaked-render": "warn"
706
- };
707
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
708
- [
709
- interopDefault(import("eslint-plugin-react")),
710
- interopDefault(import("eslint-plugin-react-hooks")),
711
- interopDefault(import("eslint-plugin-react-refresh"))
712
- ]
713
- );
714
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
715
- (i) => isPackageExists2(i)
716
- );
717
- const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
476
+ function react() {
477
+ const isUsingNext = NextJsPackages.some((index) => isPackageExists(index));
718
478
  const nextjsConfig = [];
719
479
  if (isUsingNext) {
720
- await ensurePackages(["@next/eslint-plugin-next"]);
721
- const nextPlugin = await interopDefault(import("@next/eslint-plugin-next"));
722
480
  nextjsConfig.push({
723
481
  name: "solvro/next/setup",
724
482
  plugins: {
483
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
725
484
  "@next/next": nextPlugin
726
485
  },
486
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
727
487
  rules: nextPlugin.configs.recommended.rules
728
488
  });
729
489
  }
@@ -731,14 +491,17 @@ async function react(options = {}) {
731
491
  {
732
492
  name: "solvro/react/setup",
733
493
  plugins: {
494
+ // @ts-expect-error ???
734
495
  react: pluginReact,
496
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
735
497
  "react-hooks": pluginReactHooks,
498
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
736
499
  "react-refresh": pluginReactRefresh
737
500
  }
738
501
  },
739
502
  ...nextjsConfig,
740
503
  {
741
- files,
504
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
742
505
  languageOptions: {
743
506
  parserOptions: {
744
507
  ecmaFeatures: {
@@ -756,16 +519,16 @@ async function react(options = {}) {
756
519
  rules: {
757
520
  ...pluginReact.configs.flat?.recommended.rules,
758
521
  ...pluginReact.configs.flat?.["jsx-runtime"].rules,
522
+ "react/jsx-no-leaked-render": "warn",
759
523
  // recommended rules react-hooks
760
524
  "react-hooks/exhaustive-deps": "warn",
761
525
  "react-hooks/rules-of-hooks": "error",
762
526
  "react/jsx-no-useless-fragment": "error",
763
- "react/jsx-no-leaked-render": "warn",
764
527
  // react refresh
765
528
  "react-refresh/only-export-components": [
766
529
  "warn",
767
530
  {
768
- allowConstantExport: isAllowConstantExport,
531
+ allowConstantExport: false,
769
532
  allowExportNames: [
770
533
  ...isUsingNext ? [
771
534
  "dynamic",
@@ -784,196 +547,29 @@ async function react(options = {}) {
784
547
  ] : []
785
548
  ]
786
549
  }
787
- ],
788
- // overrides
789
- ...overrides
790
- }
791
- },
792
- ...isTypeAware ? [
793
- {
794
- files: filesTypeAware,
795
- ignores: ignoresTypeAware,
796
- name: "antfu/react/type-aware-rules",
797
- rules: {
798
- ...typeAwareRules
799
- }
800
- }
801
- ] : []
802
- ];
803
- }
804
-
805
- // eslint-config/configs/regexp.ts
806
- init_esm_shims();
807
- import { configs } from "eslint-plugin-regexp";
808
- async function regexp(options = {}) {
809
- const config = configs["flat/recommended"];
810
- const rules = {
811
- ...config.rules
812
- };
813
- if (options.level === "warn") {
814
- for (const key in rules) {
815
- if (rules[key] === "error") rules[key] = "warn";
816
- }
817
- }
818
- return [
819
- {
820
- ...config,
821
- name: "solvro/regexp/rules",
822
- rules: {
823
- ...rules,
824
- ...options.overrides
825
- }
826
- }
827
- ];
828
- }
829
-
830
- // eslint-config/configs/test.ts
831
- init_esm_shims();
832
- var _pluginTest;
833
- async function test(options = {}) {
834
- const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
835
- const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
836
- interopDefault(import("@vitest/eslint-plugin")),
837
- // @ts-expect-error missing types
838
- interopDefault(import("eslint-plugin-no-only-tests"))
839
- ]);
840
- _pluginTest = _pluginTest || {
841
- ...pluginVitest,
842
- rules: {
843
- ...pluginVitest.rules,
844
- // extend `test/no-only-tests` rule
845
- ...pluginNoOnlyTests.rules
846
- }
847
- };
848
- return [
849
- {
850
- name: "solvro/test/setup",
851
- plugins: {
852
- "no-only-tests": _pluginTest
853
- }
854
- },
855
- {
856
- files,
857
- name: "solvro/test/rules",
858
- rules: {
859
- "no-only-tests/consistent-test-it": [
860
- "error",
861
- { fn: "it", withinDescribe: "it" }
862
- ],
863
- "no-only-tests/no-identical-title": "error",
864
- "no-only-tests/no-import-node-test": "error",
865
- "no-only-tests/no-only-tests": isInEditor ? "off" : "error",
866
- "no-only-tests/prefer-hooks-in-order": "error",
867
- "no-only-tests/prefer-lowercase-title": "error",
868
- // Disables
869
- ...{
870
- "antfu/no-top-level-await": "off",
871
- "no-unused-expressions": "off",
872
- "node/prefer-global/process": "off",
873
- "@typescript-eslint/explicit-function-return-type": "off"
874
- },
875
- ...overrides
550
+ ]
876
551
  }
877
552
  }
878
553
  ];
879
554
  }
880
555
 
881
556
  // eslint-config/configs/typescript.ts
882
- init_esm_shims();
883
- import process2 from "node:process";
884
- async function typescript(options = {}) {
885
- const {
886
- componentExts = [],
887
- overrides = {},
888
- overridesTypeAware = {},
889
- parserOptions = {},
890
- type = "app"
891
- } = options;
892
- const files = options.files ?? [
893
- GLOB_TS,
894
- GLOB_TSX,
895
- ...componentExts.map((ext) => `**/*.${ext}`)
896
- ];
897
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
898
- const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
899
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
900
- const isTypeAware = !!tsconfigPath;
901
- const typeAwareRules = {
902
- "dot-notation": "off",
903
- "no-implied-eval": "off",
904
- "@typescript-eslint/await-thenable": "error",
905
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
906
- "@typescript-eslint/no-floating-promises": "error",
907
- "@typescript-eslint/no-for-in-array": "error",
908
- "@typescript-eslint/no-implied-eval": "error",
909
- "@typescript-eslint/no-misused-promises": "error",
910
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
911
- "@typescript-eslint/no-unsafe-argument": "error",
912
- "@typescript-eslint/no-unsafe-assignment": "error",
913
- "@typescript-eslint/no-unsafe-call": "error",
914
- "@typescript-eslint/no-unsafe-member-access": "error",
915
- "@typescript-eslint/no-unsafe-return": "error",
916
- "@typescript-eslint/promise-function-async": "error",
917
- "@typescript-eslint/restrict-plus-operands": "error",
918
- "@typescript-eslint/restrict-template-expressions": "error",
919
- "@typescript-eslint/return-await": ["error", "in-try-catch"],
920
- "@typescript-eslint/strict-boolean-expressions": [
921
- "error",
922
- { allowNullableBoolean: true, allowNullableObject: true }
923
- ],
924
- "@typescript-eslint/switch-exhaustiveness-check": "error",
925
- "@typescript-eslint/unbound-method": "error"
926
- };
927
- const [pluginTs, parserTs] = await Promise.all([
928
- interopDefault(import("@typescript-eslint/eslint-plugin")),
929
- interopDefault(import("@typescript-eslint/parser"))
930
- ]);
931
- function makeParser(typeAware, files2, ignores2) {
932
- return {
933
- files: files2,
934
- ...ignores2 ? { ignores: ignores2 } : {},
935
- languageOptions: {
936
- parser: parserTs,
937
- parserOptions: {
938
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
939
- sourceType: "module",
940
- ...typeAware ? {
941
- projectService: {
942
- allowDefaultProject: ["./*.js"],
943
- defaultProject: tsconfigPath
944
- },
945
- tsconfigRootDir: process2.cwd()
946
- } : {},
947
- ...parserOptions
948
- }
949
- },
950
- name: `solvro/typescript/${typeAware ? "type-aware-parser" : "parser"}`
951
- };
952
- }
557
+ import tseslint from "typescript-eslint";
558
+ function typescript() {
953
559
  return [
560
+ // @ts-expect-error ???
561
+ tseslint.configs.strictTypeChecked,
562
+ // @ts-expect-error ???
563
+ tseslint.configs.stylisticTypeChecked,
954
564
  {
955
- // Install the plugins without globs, so they can be configured separately.
956
565
  name: "solvro/typescript/setup",
957
566
  plugins: {
958
- antfu: default3,
959
- "@typescript-eslint": pluginTs
567
+ antfu: default3
960
568
  }
961
569
  },
962
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
963
- ...isTypeAware ? [
964
- makeParser(false, files),
965
- makeParser(true, filesTypeAware, ignoresTypeAware)
966
- ] : [makeParser(false, files)],
967
570
  {
968
- files,
969
571
  name: "solvro/typescript/rules",
970
572
  rules: {
971
- ...pluginTs.configs["eslint-recommended"].overrides[0].rules,
972
- ...pluginTs.configs.strict.rules,
973
- "no-dupe-class-members": "off",
974
- "no-redeclare": "off",
975
- "no-use-before-define": "off",
976
- "no-useless-constructor": "off",
977
573
  "@typescript-eslint/ban-ts-comment": [
978
574
  "error",
979
575
  { "ts-expect-error": "allow-with-description" }
@@ -1021,253 +617,119 @@ async function typescript(options = {}) {
1021
617
  "@typescript-eslint/no-wrapper-object-types": "error",
1022
618
  "@typescript-eslint/triple-slash-reference": "off",
1023
619
  "@typescript-eslint/unified-signatures": "off",
1024
- ...type === "lib" ? {
1025
- "@typescript-eslint/explicit-function-return-type": [
1026
- "error",
1027
- {
1028
- allowExpressions: true,
1029
- allowHigherOrderFunctions: true,
1030
- allowIIFEs: true
1031
- }
1032
- ]
1033
- } : {},
1034
- ...overrides
1035
- }
1036
- },
1037
- ...isTypeAware ? [
1038
- {
1039
- files: filesTypeAware,
1040
- ignores: ignoresTypeAware,
1041
- name: "solvro/typescript/rules-type-aware",
1042
- rules: {
1043
- ...typeAwareRules,
1044
- ...overridesTypeAware
1045
- }
620
+ // prevent unnecessary use of void operator
621
+ "@typescript-eslint/no-meaningless-void-operator": "error",
622
+ // "using non-null assertions cancels the benefits of the strict
623
+ // null-checking mode."
624
+ // warn when one of the types in union / intersection overrides others
625
+ "@typescript-eslint/no-redundant-type-constituents": "warn",
626
+ // prevent variables shadowing
627
+ "no-shadow": "error",
628
+ "@typescript-eslint/no-shadow": "error",
629
+ // prevent assignment of this, signals a wrong usage of it
630
+ "@typescript-eslint/no-this-alias": "error",
631
+ // prevent throwing non-error
632
+ "no-throw-literal": "off",
633
+ // prevent unnecessary explicitly adding a default type argument
634
+ "@typescript-eslint/no-unnecessary-type-arguments": "error",
635
+ // prevent unnecessary assertions that won't change the outcome
636
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
637
+ // prevent extending default types
638
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
639
+ // force typing out function arguments
640
+ "@typescript-eslint/no-unsafe-argument": "error",
641
+ // prevent usage of any via reassigning
642
+ "@typescript-eslint/no-unsafe-assignment": "error",
643
+ // prevent usage of any via calling it
644
+ "@typescript-eslint/no-unsafe-call": "error",
645
+ // prevent usage of any via using it's members
646
+ "@typescript-eslint/no-unsafe-member-access": "error",
647
+ // prevent reverting any from functions
648
+ "@typescript-eslint/no-unsafe-return": "error",
649
+ // prevent unused expressions
650
+ "no-unused-expressions": "off",
651
+ // var<'string'> = 'string' -> var = 'string' as const
652
+ "@typescript-eslint/prefer-as-const": "error",
653
+ // force initializing enums
654
+ "@typescript-eslint/prefer-enum-initializers": "error",
655
+ // prefer for x of obj to for let i = 0...
656
+ "@typescript-eslint/prefer-for-of": "error",
657
+ // prefer includes() to indexOf()
658
+ "@typescript-eslint/prefer-includes": "error",
659
+ // use literals for enum initialization
660
+ "@typescript-eslint/prefer-literal-enum-member": "error",
661
+ // prefer safe cascade of a value when dealing with undefined or null
662
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
663
+ // prefer optional chaining (a?.b)
664
+ "@typescript-eslint/prefer-optional-chain": "error",
665
+ // prefer using type parameter for Array.reduce
666
+ "@typescript-eslint/prefer-reduce-type-parameter": "error",
667
+ // prefer RegExp#exec when no /g flag in regex
668
+ "@typescript-eslint/prefer-regexp-exec": "error",
669
+ // enforce `this` as a type when stating type for a method
670
+ "@typescript-eslint/prefer-return-this-type": "error",
671
+ // enforce startsWith to indexOf === 0
672
+ "@typescript-eslint/prefer-string-starts-ends-with": "error",
673
+ // prevents default behavior of .sort() - which is confusing
674
+ "@typescript-eslint/require-array-sort-compare": "error",
675
+ // no async functions without awaits in body
676
+ "require-await": "off",
677
+ "@typescript-eslint/require-await": "error",
678
+ // prevent number + string
679
+ "@typescript-eslint/restrict-plus-operands": "error",
680
+ // only allow string in templates
681
+ "@typescript-eslint/restrict-template-expressions": "error",
682
+ // prevent returning await
683
+ "no-return-await": "off",
684
+ "@typescript-eslint/return-await": "error",
685
+ // only booleans in ifs and whiles
686
+ "@typescript-eslint/strict-boolean-expressions": "error",
687
+ // check if all paths are followed in code
688
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
689
+ "dot-notation": "off",
690
+ "no-implied-eval": "off",
691
+ "@typescript-eslint/await-thenable": "error",
692
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
693
+ "@typescript-eslint/no-floating-promises": "error",
694
+ "@typescript-eslint/no-for-in-array": "error",
695
+ "@typescript-eslint/no-implied-eval": "error",
696
+ "@typescript-eslint/no-misused-promises": "error",
697
+ "@typescript-eslint/promise-function-async": "error",
698
+ "@typescript-eslint/unbound-method": "error"
1046
699
  }
1047
- ] : []
700
+ }
1048
701
  ];
1049
702
  }
1050
703
 
1051
704
  // eslint-config/configs/unicorn.ts
1052
- init_esm_shims();
1053
- async function unicorn(options = {}) {
705
+ function unicorn() {
1054
706
  return [
1055
707
  {
1056
708
  name: "solvro/unicorn/rules",
1057
709
  plugins: {
1058
710
  unicorn: default6
1059
711
  },
1060
- rules: {
1061
- ...options.allRecommended ? default6.configs["flat/recommended"].rules : {
1062
- "unicorn/consistent-empty-array-spread": "error",
1063
- "unicorn/error-message": "error",
1064
- "unicorn/escape-case": "error",
1065
- "unicorn/new-for-builtins": "error",
1066
- "unicorn/no-instanceof-array": "error",
1067
- "unicorn/no-new-array": "error",
1068
- "unicorn/no-new-buffer": "error",
1069
- "unicorn/number-literal-case": "error",
1070
- "unicorn/prefer-dom-node-text-content": "error",
1071
- "unicorn/prefer-includes": "error",
1072
- "unicorn/prefer-node-protocol": "error",
1073
- "unicorn/prefer-number-properties": "error",
1074
- "unicorn/prefer-string-starts-ends-with": "error",
1075
- "unicorn/prefer-type-error": "error",
1076
- "unicorn/throw-new-error": "error"
1077
- }
1078
- }
712
+ rules: default6.configs["flat/recommended"].rules
1079
713
  }
1080
714
  ];
1081
715
  }
1082
716
 
1083
- // eslint-config/factory.ts
1084
- var flatConfigProps = [
1085
- "name",
1086
- "languageOptions",
1087
- "linterOptions",
1088
- "processor",
1089
- "plugins",
1090
- "rules",
1091
- "settings"
1092
- ];
1093
- function solvro(options = {}, ...userConfigs) {
1094
- const {
1095
- componentExts = [],
1096
- gitignore: enableGitignore = true,
1097
- jsx: enableJsx = true,
1098
- react: enableReact = false,
1099
- regexp: enableRegexp = true,
1100
- typescript: enableTypeScript = isPackageExists3("typescript"),
1101
- unicorn: enableUnicorn = true
1102
- } = options;
1103
- let isInEditor = options.isInEditor;
1104
- if (isInEditor == null) {
1105
- isInEditor = isInEditorEnv();
1106
- if (isInEditor)
1107
- console.log(
1108
- "[@solvro/config] Detected running in editor, some rules are disabled."
1109
- );
1110
- }
1111
- const configs2 = [];
1112
- if (enableGitignore) {
1113
- if (typeof enableGitignore !== "boolean") {
1114
- configs2.push(
1115
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1116
- r({
1117
- name: "solvro/gitignore",
1118
- ...enableGitignore
1119
- })
1120
- ])
1121
- );
1122
- } else {
1123
- configs2.push(
1124
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1125
- r({
1126
- name: "solvro/gitignore",
1127
- strict: false
1128
- })
1129
- ])
1130
- );
1131
- }
1132
- }
1133
- const typescriptOptions = resolveSubOptions(options, "typescript");
1134
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
1135
- configs2.push(
1136
- ignores(options.ignores),
1137
- javascript({
1138
- isInEditor,
1139
- overrides: getOverrides(options, "javascript")
1140
- }),
1141
- comments(),
1142
- node(),
1143
- jsdoc(),
1144
- imports(),
1145
- command()
1146
- );
1147
- if (enableUnicorn) {
1148
- configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
1149
- }
1150
- if (enableJsx) {
1151
- configs2.push(jsx());
1152
- }
1153
- if (enableTypeScript) {
1154
- configs2.push(
1155
- typescript({
1156
- ...typescriptOptions,
1157
- componentExts,
1158
- overrides: getOverrides(options, "typescript"),
1159
- type: options.type
1160
- })
1161
- );
1162
- }
1163
- if (enableRegexp) {
1164
- configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1165
- }
1166
- if (options.test ?? true) {
1167
- configs2.push(
1168
- test({
1169
- isInEditor,
1170
- overrides: getOverrides(options, "test")
1171
- })
1172
- );
1173
- }
1174
- if (enableReact) {
1175
- configs2.push(
1176
- react({
1177
- ...typescriptOptions,
1178
- overrides: getOverrides(options, "react"),
1179
- tsconfigPath
1180
- })
1181
- );
1182
- }
1183
- if (options.markdown ?? true) {
1184
- configs2.push(
1185
- markdown({
1186
- componentExts,
1187
- overrides: getOverrides(options, "markdown")
1188
- })
1189
- );
1190
- }
1191
- if (options.formatters) {
1192
- configs2.push(formatters());
1193
- }
1194
- configs2.push(disables());
1195
- if ("files" in options) {
1196
- throw new Error(
1197
- '[@solvro/config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.'
1198
- );
1199
- }
1200
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
1201
- if (key in options) acc[key] = options[key];
1202
- return acc;
1203
- }, {});
1204
- if (Object.keys(fusedConfig).length) configs2.push([fusedConfig]);
1205
- let composer = new FlatConfigComposer();
1206
- composer = composer.append(...configs2, ...userConfigs);
1207
- return composer;
1208
- }
1209
- function resolveSubOptions(options, key) {
1210
- return typeof options[key] === "boolean" ? {} : options[key] || {};
1211
- }
1212
- function getOverrides(options, key) {
1213
- const sub = resolveSubOptions(options, key);
1214
- return {
1215
- ...options.overrides?.[key],
1216
- ..."overrides" in sub ? sub.overrides : {}
1217
- };
1218
- }
1219
-
1220
- // eslint-config/types.ts
1221
- init_esm_shims();
1222
-
1223
717
  // eslint-config/index.ts
1224
- var eslint_config_default = solvro;
718
+ var solvro = (...configs) => tseslint2.config(
719
+ ...react(),
720
+ ...typescript(),
721
+ ...javascript(),
722
+ ...jsdoc(),
723
+ ...unicorn(),
724
+ ...disables(),
725
+ ...imports(),
726
+ ...comments(),
727
+ ...ignores(),
728
+ ...formatters(),
729
+ ...node(),
730
+ ...configs
731
+ );
1225
732
  export {
1226
- GLOB_ALL_SRC,
1227
- GLOB_EXCLUDE,
1228
- GLOB_HTML,
1229
- GLOB_JS,
1230
- GLOB_JSON,
1231
- GLOB_JSON5,
1232
- GLOB_JSX,
1233
- GLOB_MARKDOWN,
1234
- GLOB_MARKDOWN_CODE,
1235
- GLOB_MARKDOWN_IN_MARKDOWN,
1236
- GLOB_SRC,
1237
- GLOB_SRC_EXT,
1238
- GLOB_STYLE,
1239
- GLOB_SVG,
1240
- GLOB_TESTS,
1241
- GLOB_TOML,
1242
- GLOB_TS,
1243
- GLOB_TSX,
1244
- GLOB_XML,
1245
- combine,
1246
- command,
1247
- comments,
1248
- eslint_config_default as default,
1249
- disables,
1250
- ensurePackages,
1251
- formatters,
1252
- getOverrides,
1253
- ignores,
1254
- imports,
1255
- interopDefault,
1256
- isInEditorEnv,
1257
- isInGitHooksOrLintStaged,
1258
- isPackageInScope,
1259
- javascript,
1260
- jsdoc,
1261
- jsx,
1262
- markdown,
1263
- node,
1264
- parserPlain,
1265
- react,
1266
- regexp,
1267
- resolveSubOptions,
1268
- solvro,
1269
- test,
1270
- toArray,
1271
- typescript,
1272
- unicorn
733
+ solvro
1273
734
  };
735
+ //# sourceMappingURL=index.js.map