@solvro/config 1.1.0 → 1.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.
@@ -34,12 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
36
  // node_modules/tsup/assets/cjs_shims.js
37
- var getImportMetaUrl, importMetaUrl;
38
37
  var init_cjs_shims = __esm({
39
38
  "node_modules/tsup/assets/cjs_shims.js"() {
40
39
  "use strict";
41
- getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
- importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
43
40
  }
44
41
  });
45
42
 
@@ -259,76 +256,11 @@ var require_eslint_config_prettier = __commonJS({
259
256
  // eslint-config/index.ts
260
257
  var eslint_config_exports = {};
261
258
  __export(eslint_config_exports, {
262
- GLOB_ALL_SRC: () => GLOB_ALL_SRC,
263
- GLOB_EXCLUDE: () => GLOB_EXCLUDE,
264
- GLOB_HTML: () => GLOB_HTML,
265
- GLOB_JS: () => GLOB_JS,
266
- GLOB_JSON: () => GLOB_JSON,
267
- GLOB_JSON5: () => GLOB_JSON5,
268
- GLOB_JSX: () => GLOB_JSX,
269
- GLOB_MARKDOWN: () => GLOB_MARKDOWN,
270
- GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
271
- GLOB_MARKDOWN_IN_MARKDOWN: () => GLOB_MARKDOWN_IN_MARKDOWN,
272
- GLOB_SRC: () => GLOB_SRC,
273
- GLOB_SRC_EXT: () => GLOB_SRC_EXT,
274
- GLOB_STYLE: () => GLOB_STYLE,
275
- GLOB_SVG: () => GLOB_SVG,
276
- GLOB_TESTS: () => GLOB_TESTS,
277
- GLOB_TOML: () => GLOB_TOML,
278
- GLOB_TS: () => GLOB_TS,
279
- GLOB_TSX: () => GLOB_TSX,
280
- GLOB_XML: () => GLOB_XML,
281
- combine: () => combine,
282
- command: () => command,
283
- comments: () => comments,
284
- default: () => eslint_config_default,
285
- disables: () => disables,
286
- ensurePackages: () => ensurePackages,
287
- formatters: () => formatters,
288
- getOverrides: () => getOverrides,
289
- ignores: () => ignores,
290
- imports: () => imports,
291
- interopDefault: () => interopDefault,
292
- isInEditorEnv: () => isInEditorEnv,
293
- isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
294
- isPackageInScope: () => isPackageInScope,
295
- javascript: () => javascript,
296
- jsdoc: () => jsdoc,
297
- jsx: () => jsx,
298
- markdown: () => markdown,
299
- node: () => node,
300
- parserPlain: () => parserPlain,
301
- react: () => react,
302
- regexp: () => regexp,
303
- resolveSubOptions: () => resolveSubOptions,
304
- solvro: () => solvro,
305
- test: () => test,
306
- toArray: () => toArray,
307
- typescript: () => typescript,
308
- unicorn: () => unicorn
259
+ solvro: () => solvro
309
260
  });
310
261
  module.exports = __toCommonJS(eslint_config_exports);
311
262
  init_cjs_shims();
312
-
313
- // eslint-config/factory.ts
314
- init_cjs_shims();
315
- var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
316
- var import_local_pkg3 = require("local-pkg");
317
-
318
- // eslint-config/configs/index.ts
319
- init_cjs_shims();
320
-
321
- // eslint-config/configs/command.ts
322
- init_cjs_shims();
323
- var import_config = __toESM(require("eslint-plugin-command/config"), 1);
324
- async function command() {
325
- return [
326
- {
327
- ...(0, import_config.default)(),
328
- name: "solvro/command/rules"
329
- }
330
- ];
331
- }
263
+ var import_typescript_eslint2 = __toESM(require("typescript-eslint"), 1);
332
264
 
333
265
  // eslint-config/configs/comments.ts
334
266
  init_cjs_shims();
@@ -344,11 +276,12 @@ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
344
276
  var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
345
277
 
346
278
  // eslint-config/configs/comments.ts
347
- async function comments() {
279
+ function comments() {
348
280
  return [
349
281
  {
350
282
  name: "solvro/eslint-comments/rules",
351
283
  plugins: {
284
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
352
285
  "eslint-comments": import_eslint_plugin_eslint_comments.default
353
286
  },
354
287
  rules: {
@@ -368,19 +301,7 @@ init_cjs_shims();
368
301
  init_cjs_shims();
369
302
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
370
303
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
371
- var GLOB_JS = "**/*.?([cm])js";
372
- var GLOB_JSX = "**/*.?([cm])jsx";
373
- var GLOB_TS = "**/*.?([cm])ts";
374
- var GLOB_TSX = "**/*.?([cm])tsx";
375
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
376
- var GLOB_JSON = "**/*.json";
377
- var GLOB_JSON5 = "**/*.json5";
378
304
  var GLOB_MARKDOWN = "**/*.md";
379
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
380
- var GLOB_TOML = "**/*.toml";
381
- var GLOB_XML = "**/*.xml";
382
- var GLOB_SVG = "**/*.svg";
383
- var GLOB_HTML = "**/*.htm?(l)";
384
305
  var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
385
306
  var GLOB_TESTS = [
386
307
  `**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -389,15 +310,6 @@ var GLOB_TESTS = [
389
310
  `**/*.bench.${GLOB_SRC_EXT}`,
390
311
  `**/*.benchmark.${GLOB_SRC_EXT}`
391
312
  ];
392
- var GLOB_ALL_SRC = [
393
- GLOB_SRC,
394
- GLOB_STYLE,
395
- GLOB_JSON,
396
- GLOB_JSON5,
397
- GLOB_MARKDOWN,
398
- GLOB_XML,
399
- GLOB_HTML
400
- ];
401
313
  var GLOB_EXCLUDE = [
402
314
  "**/node_modules",
403
315
  "**/dist",
@@ -433,7 +345,7 @@ var GLOB_EXCLUDE = [
433
345
  ];
434
346
 
435
347
  // eslint-config/configs/disables.ts
436
- async function disables() {
348
+ function disables() {
437
349
  return [
438
350
  {
439
351
  files: [`**/scripts/${GLOB_SRC}`],
@@ -491,86 +403,22 @@ async function disables() {
491
403
 
492
404
  // eslint-config/configs/formatters.ts
493
405
  init_cjs_shims();
494
-
495
- // eslint-config/utils.ts
496
- init_cjs_shims();
497
- var import_local_pkg = require("local-pkg");
498
- var import_node_process = __toESM(require("process"), 1);
499
- var import_node_url = require("url");
500
- var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
501
- var isCwdInScope = (0, import_local_pkg.isPackageExists)("@solvro/config");
502
- var parserPlain = {
503
- meta: {
504
- name: "parser-plain"
505
- },
506
- parseForESLint: (code) => ({
507
- ast: {
508
- body: [],
509
- comments: [],
510
- loc: { end: code.length, start: 0 },
511
- range: [0, code.length],
512
- tokens: [],
513
- type: "Program"
514
- },
515
- scopeManager: null,
516
- services: { isPlain: true },
517
- visitorKeys: {
518
- Program: []
406
+ var import_eslint_config_prettier = __toESM(require_eslint_config_prettier(), 1);
407
+ function formatters() {
408
+ return [
409
+ {
410
+ name: "solvro/prettier",
411
+ ...import_eslint_config_prettier.default
519
412
  }
520
- })
521
- };
522
- async function combine(...configs2) {
523
- const resolved = await Promise.all(configs2);
524
- return resolved.flat();
525
- }
526
- function toArray(value) {
527
- return Array.isArray(value) ? value : [value];
528
- }
529
- async function interopDefault(m) {
530
- const resolved = await m;
531
- return resolved.default || resolved;
532
- }
533
- function isPackageInScope(name) {
534
- return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
535
- }
536
- async function ensurePackages(packages) {
537
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
538
- return;
539
- const nonExistingPackages = packages.filter(
540
- (i) => i && !isPackageInScope(i)
541
- );
542
- if (nonExistingPackages.length === 0) return;
543
- const p = await import("@clack/prompts");
544
- const result = await p.confirm({
545
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
546
- });
547
- if (result)
548
- await import("@antfu/install-pkg").then(
549
- (i) => i.installPackage(nonExistingPackages, { dev: true })
550
- );
551
- }
552
- function isInEditorEnv() {
553
- if (import_node_process.default.env.CI) return false;
554
- if (isInGitHooksOrLintStaged()) return false;
555
- return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
556
- }
557
- function isInGitHooksOrLintStaged() {
558
- return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
559
- }
560
-
561
- // eslint-config/configs/formatters.ts
562
- async function formatters() {
563
- await ensurePackages(["eslint-plugin-prettier"]);
564
- const prettierConfig = await interopDefault(Promise.resolve().then(() => __toESM(require_eslint_config_prettier(), 1)));
565
- return [prettierConfig];
413
+ ];
566
414
  }
567
415
 
568
416
  // eslint-config/configs/ignores.ts
569
417
  init_cjs_shims();
570
- async function ignores(userIgnores = []) {
418
+ function ignores() {
571
419
  return [
572
420
  {
573
- ignores: [...GLOB_EXCLUDE, ...userIgnores],
421
+ ignores: [...GLOB_EXCLUDE],
574
422
  name: "solvro/ignores"
575
423
  }
576
424
  ];
@@ -578,12 +426,13 @@ async function ignores(userIgnores = []) {
578
426
 
579
427
  // eslint-config/configs/imports.ts
580
428
  init_cjs_shims();
581
- async function imports() {
429
+ function imports() {
582
430
  return [
583
431
  {
584
432
  name: "solvro/imports/rules",
585
433
  plugins: {
586
434
  antfu: import_eslint_plugin_antfu.default,
435
+ // @ts-expect-error ???
587
436
  "import-x": pluginImport
588
437
  },
589
438
  rules: {
@@ -603,9 +452,9 @@ async function imports() {
603
452
 
604
453
  // eslint-config/configs/javascript.ts
605
454
  init_cjs_shims();
455
+ var import_js = __toESM(require("@eslint/js"), 1);
606
456
  var import_globals = __toESM(require("globals"), 1);
607
- async function javascript(options = {}) {
608
- const { isInEditor = false, overrides = {} } = options;
457
+ function javascript() {
609
458
  return [
610
459
  {
611
460
  languageOptions: {
@@ -639,6 +488,7 @@ async function javascript(options = {}) {
639
488
  "unused-imports": import_eslint_plugin_unused_imports.default
640
489
  },
641
490
  rules: {
491
+ ...import_js.default.configs.recommended.rules,
642
492
  "accessor-pairs": [
643
493
  "error",
644
494
  { enforceForClassMembers: true, setWithoutGet: true }
@@ -814,7 +664,7 @@ async function javascript(options = {}) {
814
664
  "prefer-template": "error",
815
665
  "symbol-description": "error",
816
666
  "unicode-bom": ["error", "never"],
817
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
667
+ "unused-imports/no-unused-imports": "error",
818
668
  "unused-imports/no-unused-vars": [
819
669
  "error",
820
670
  {
@@ -831,8 +681,7 @@ async function javascript(options = {}) {
831
681
  ],
832
682
  "valid-typeof": ["error", { requireStringLiterals: true }],
833
683
  "vars-on-top": "error",
834
- yoda: ["error", "never"],
835
- ...overrides
684
+ yoda: ["error", "never"]
836
685
  }
837
686
  }
838
687
  ];
@@ -840,12 +689,13 @@ async function javascript(options = {}) {
840
689
 
841
690
  // eslint-config/configs/jsdoc.ts
842
691
  init_cjs_shims();
843
- async function jsdoc() {
692
+ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
693
+ function jsdoc() {
844
694
  return [
845
695
  {
846
696
  name: "solvro/jsdoc/rules",
847
697
  plugins: {
848
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
698
+ jsdoc: import_eslint_plugin_jsdoc.default
849
699
  },
850
700
  rules: {
851
701
  "jsdoc/check-access": "warn",
@@ -868,105 +718,9 @@ async function jsdoc() {
868
718
  ];
869
719
  }
870
720
 
871
- // eslint-config/configs/jsx.ts
872
- init_cjs_shims();
873
- async function jsx() {
874
- return [
875
- {
876
- files: [GLOB_JSX, GLOB_TSX],
877
- languageOptions: {
878
- parserOptions: {
879
- ecmaFeatures: {
880
- jsx: true
881
- }
882
- }
883
- },
884
- name: "solvro/jsx/setup"
885
- }
886
- ];
887
- }
888
-
889
- // eslint-config/configs/markdown.ts
890
- init_cjs_shims();
891
- var import_eslint_merge_processors = require("eslint-merge-processors");
892
- async function markdown(options = {}) {
893
- const {
894
- componentExts = [],
895
- files = [GLOB_MARKDOWN],
896
- overrides = {}
897
- } = options;
898
- const markdown2 = await interopDefault(import("@eslint/markdown"));
899
- return [
900
- {
901
- name: "solvro/markdown/setup",
902
- plugins: {
903
- markdown: markdown2
904
- }
905
- },
906
- {
907
- files,
908
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
909
- name: "solvro/markdown/processor",
910
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
911
- // but not the markdown file itself. We use `eslint-merge-processors` to
912
- // add a pass-through processor for the markdown file itself.
913
- processor: (0, import_eslint_merge_processors.mergeProcessors)([
914
- markdown2.processors.markdown,
915
- import_eslint_merge_processors.processorPassThrough
916
- ])
917
- },
918
- {
919
- files,
920
- languageOptions: {
921
- parser: parserPlain
922
- },
923
- name: "solvro/markdown/parser"
924
- },
925
- {
926
- files: [
927
- GLOB_MARKDOWN_CODE,
928
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
929
- ],
930
- languageOptions: {
931
- parserOptions: {
932
- ecmaFeatures: {
933
- impliedStrict: true
934
- }
935
- }
936
- },
937
- name: "solvro/markdown/disables",
938
- rules: {
939
- "antfu/no-top-level-await": "off",
940
- "no-alert": "off",
941
- "no-console": "off",
942
- "no-labels": "off",
943
- "no-lone-blocks": "off",
944
- "no-restricted-syntax": "off",
945
- "no-undef": "off",
946
- "no-unused-expressions": "off",
947
- "no-unused-labels": "off",
948
- "no-unused-vars": "off",
949
- "node/prefer-global/process": "off",
950
- "@typescript-eslint/consistent-type-imports": "off",
951
- "@typescript-eslint/explicit-function-return-type": "off",
952
- "@typescript-eslint/no-namespace": "off",
953
- "@typescript-eslint/no-redeclare": "off",
954
- "@typescript-eslint/no-require-imports": "off",
955
- "@typescript-eslint/no-unused-expressions": "off",
956
- "@typescript-eslint/no-unused-vars": "off",
957
- "@typescript-eslint/no-use-before-define": "off",
958
- "unicode-bom": "off",
959
- "unused-imports/no-unused-imports": "off",
960
- "unused-imports/no-unused-vars": "off",
961
- ...overrides
962
- }
963
- }
964
- ];
965
- }
966
-
967
721
  // eslint-config/configs/node.ts
968
722
  init_cjs_shims();
969
- async function node() {
723
+ function node() {
970
724
  return [
971
725
  {
972
726
  name: "solvro/node/rules",
@@ -989,61 +743,41 @@ async function node() {
989
743
 
990
744
  // eslint-config/configs/react.ts
991
745
  init_cjs_shims();
992
- var import_local_pkg2 = require("local-pkg");
993
- var ReactRefreshAllowConstantExportPackages = ["vite"];
746
+ var import_eslint_plugin_next = __toESM(require("@next/eslint-plugin-next"), 1);
747
+ var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
748
+ var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
749
+ var import_eslint_plugin_react_refresh = __toESM(require("eslint-plugin-react-refresh"), 1);
750
+ var import_local_pkg = require("local-pkg");
994
751
  var NextJsPackages = ["next"];
995
- async function react(options = {}) {
996
- const {
997
- files = [GLOB_SRC],
998
- filesTypeAware = [GLOB_TS, GLOB_TSX],
999
- ignoresTypeAware = [`${GLOB_MARKDOWN}/**`],
1000
- overrides = {},
1001
- tsconfigPath
1002
- } = options;
1003
- await ensurePackages([
1004
- "eslint-plugin-react",
1005
- "eslint-plugin-react-hooks",
1006
- "eslint-plugin-react-refresh"
1007
- ]);
1008
- const isTypeAware = !!tsconfigPath;
1009
- const typeAwareRules = {
1010
- "react/jsx-no-leaked-render": "warn"
1011
- };
1012
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all(
1013
- [
1014
- interopDefault(import("eslint-plugin-react")),
1015
- interopDefault(import("eslint-plugin-react-hooks")),
1016
- interopDefault(import("eslint-plugin-react-refresh"))
1017
- ]
1018
- );
1019
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1020
- (i) => (0, import_local_pkg2.isPackageExists)(i)
1021
- );
1022
- const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
752
+ function react() {
753
+ const isUsingNext = NextJsPackages.some((index) => (0, import_local_pkg.isPackageExists)(index));
1023
754
  const nextjsConfig = [];
1024
755
  if (isUsingNext) {
1025
- await ensurePackages(["@next/eslint-plugin-next"]);
1026
- const nextPlugin = await interopDefault(import("@next/eslint-plugin-next"));
1027
756
  nextjsConfig.push({
1028
757
  name: "solvro/next/setup",
1029
758
  plugins: {
1030
- "@next/next": nextPlugin
759
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
760
+ "@next/next": import_eslint_plugin_next.default
1031
761
  },
1032
- rules: nextPlugin.configs.recommended.rules
762
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
763
+ rules: import_eslint_plugin_next.default.configs.recommended.rules
1033
764
  });
1034
765
  }
1035
766
  return [
1036
767
  {
1037
768
  name: "solvro/react/setup",
1038
769
  plugins: {
1039
- react: pluginReact,
1040
- "react-hooks": pluginReactHooks,
1041
- "react-refresh": pluginReactRefresh
770
+ // @ts-expect-error ???
771
+ react: import_eslint_plugin_react.default,
772
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
773
+ "react-hooks": import_eslint_plugin_react_hooks.default,
774
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
775
+ "react-refresh": import_eslint_plugin_react_refresh.default
1042
776
  }
1043
777
  },
1044
778
  ...nextjsConfig,
1045
779
  {
1046
- files,
780
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
1047
781
  languageOptions: {
1048
782
  parserOptions: {
1049
783
  ecmaFeatures: {
@@ -1059,18 +793,18 @@ async function react(options = {}) {
1059
793
  },
1060
794
  name: "solvro/react/rules",
1061
795
  rules: {
1062
- ...pluginReact.configs.flat?.recommended.rules,
1063
- ...pluginReact.configs.flat?.["jsx-runtime"].rules,
796
+ ...import_eslint_plugin_react.default.configs.flat?.recommended.rules,
797
+ ...import_eslint_plugin_react.default.configs.flat?.["jsx-runtime"].rules,
798
+ "react/jsx-no-leaked-render": "warn",
1064
799
  // recommended rules react-hooks
1065
800
  "react-hooks/exhaustive-deps": "warn",
1066
801
  "react-hooks/rules-of-hooks": "error",
1067
802
  "react/jsx-no-useless-fragment": "error",
1068
- "react/jsx-no-leaked-render": "warn",
1069
803
  // react refresh
1070
804
  "react-refresh/only-export-components": [
1071
805
  "warn",
1072
806
  {
1073
- allowConstantExport: isAllowConstantExport,
807
+ allowConstantExport: false,
1074
808
  allowExportNames: [
1075
809
  ...isUsingNext ? [
1076
810
  "dynamic",
@@ -1089,95 +823,7 @@ async function react(options = {}) {
1089
823
  ] : []
1090
824
  ]
1091
825
  }
1092
- ],
1093
- // overrides
1094
- ...overrides
1095
- }
1096
- },
1097
- ...isTypeAware ? [
1098
- {
1099
- files: filesTypeAware,
1100
- ignores: ignoresTypeAware,
1101
- name: "antfu/react/type-aware-rules",
1102
- rules: {
1103
- ...typeAwareRules
1104
- }
1105
- }
1106
- ] : []
1107
- ];
1108
- }
1109
-
1110
- // eslint-config/configs/regexp.ts
1111
- init_cjs_shims();
1112
- var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1113
- async function regexp(options = {}) {
1114
- const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1115
- const rules = {
1116
- ...config.rules
1117
- };
1118
- if (options.level === "warn") {
1119
- for (const key in rules) {
1120
- if (rules[key] === "error") rules[key] = "warn";
1121
- }
1122
- }
1123
- return [
1124
- {
1125
- ...config,
1126
- name: "solvro/regexp/rules",
1127
- rules: {
1128
- ...rules,
1129
- ...options.overrides
1130
- }
1131
- }
1132
- ];
1133
- }
1134
-
1135
- // eslint-config/configs/test.ts
1136
- init_cjs_shims();
1137
- var _pluginTest;
1138
- async function test(options = {}) {
1139
- const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1140
- const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1141
- interopDefault(import("@vitest/eslint-plugin")),
1142
- // @ts-expect-error missing types
1143
- interopDefault(import("eslint-plugin-no-only-tests"))
1144
- ]);
1145
- _pluginTest = _pluginTest || {
1146
- ...pluginVitest,
1147
- rules: {
1148
- ...pluginVitest.rules,
1149
- // extend `test/no-only-tests` rule
1150
- ...pluginNoOnlyTests.rules
1151
- }
1152
- };
1153
- return [
1154
- {
1155
- name: "solvro/test/setup",
1156
- plugins: {
1157
- "no-only-tests": _pluginTest
1158
- }
1159
- },
1160
- {
1161
- files,
1162
- name: "solvro/test/rules",
1163
- rules: {
1164
- "no-only-tests/consistent-test-it": [
1165
- "error",
1166
- { fn: "it", withinDescribe: "it" }
1167
- ],
1168
- "no-only-tests/no-identical-title": "error",
1169
- "no-only-tests/no-import-node-test": "error",
1170
- "no-only-tests/no-only-tests": isInEditor ? "off" : "error",
1171
- "no-only-tests/prefer-hooks-in-order": "error",
1172
- "no-only-tests/prefer-lowercase-title": "error",
1173
- // Disables
1174
- ...{
1175
- "antfu/no-top-level-await": "off",
1176
- "no-unused-expressions": "off",
1177
- "node/prefer-global/process": "off",
1178
- "@typescript-eslint/explicit-function-return-type": "off"
1179
- },
1180
- ...overrides
826
+ ]
1181
827
  }
1182
828
  }
1183
829
  ];
@@ -1185,100 +831,22 @@ async function test(options = {}) {
1185
831
 
1186
832
  // eslint-config/configs/typescript.ts
1187
833
  init_cjs_shims();
1188
- var import_node_process2 = __toESM(require("process"), 1);
1189
- async function typescript(options = {}) {
1190
- const {
1191
- componentExts = [],
1192
- overrides = {},
1193
- overridesTypeAware = {},
1194
- parserOptions = {},
1195
- type = "app"
1196
- } = options;
1197
- const files = options.files ?? [
1198
- GLOB_TS,
1199
- GLOB_TSX,
1200
- ...componentExts.map((ext) => `**/*.${ext}`)
1201
- ];
1202
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
1203
- const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`];
1204
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
1205
- const isTypeAware = !!tsconfigPath;
1206
- const typeAwareRules = {
1207
- "dot-notation": "off",
1208
- "no-implied-eval": "off",
1209
- "@typescript-eslint/await-thenable": "error",
1210
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
1211
- "@typescript-eslint/no-floating-promises": "error",
1212
- "@typescript-eslint/no-for-in-array": "error",
1213
- "@typescript-eslint/no-implied-eval": "error",
1214
- "@typescript-eslint/no-misused-promises": "error",
1215
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
1216
- "@typescript-eslint/no-unsafe-argument": "error",
1217
- "@typescript-eslint/no-unsafe-assignment": "error",
1218
- "@typescript-eslint/no-unsafe-call": "error",
1219
- "@typescript-eslint/no-unsafe-member-access": "error",
1220
- "@typescript-eslint/no-unsafe-return": "error",
1221
- "@typescript-eslint/promise-function-async": "error",
1222
- "@typescript-eslint/restrict-plus-operands": "error",
1223
- "@typescript-eslint/restrict-template-expressions": "error",
1224
- "@typescript-eslint/return-await": ["error", "in-try-catch"],
1225
- "@typescript-eslint/strict-boolean-expressions": [
1226
- "error",
1227
- { allowNullableBoolean: true, allowNullableObject: true }
1228
- ],
1229
- "@typescript-eslint/switch-exhaustiveness-check": "error",
1230
- "@typescript-eslint/unbound-method": "error"
1231
- };
1232
- const [pluginTs, parserTs] = await Promise.all([
1233
- interopDefault(import("@typescript-eslint/eslint-plugin")),
1234
- interopDefault(import("@typescript-eslint/parser"))
1235
- ]);
1236
- function makeParser(typeAware, files2, ignores2) {
1237
- return {
1238
- files: files2,
1239
- ...ignores2 ? { ignores: ignores2 } : {},
1240
- languageOptions: {
1241
- parser: parserTs,
1242
- parserOptions: {
1243
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1244
- sourceType: "module",
1245
- ...typeAware ? {
1246
- projectService: {
1247
- allowDefaultProject: ["./*.js"],
1248
- defaultProject: tsconfigPath
1249
- },
1250
- tsconfigRootDir: import_node_process2.default.cwd()
1251
- } : {},
1252
- ...parserOptions
1253
- }
1254
- },
1255
- name: `solvro/typescript/${typeAware ? "type-aware-parser" : "parser"}`
1256
- };
1257
- }
834
+ var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
835
+ function typescript() {
1258
836
  return [
837
+ // @ts-expect-error ???
838
+ import_typescript_eslint.default.configs.strictTypeChecked,
839
+ // @ts-expect-error ???
840
+ import_typescript_eslint.default.configs.stylisticTypeChecked,
1259
841
  {
1260
- // Install the plugins without globs, so they can be configured separately.
1261
842
  name: "solvro/typescript/setup",
1262
843
  plugins: {
1263
- antfu: import_eslint_plugin_antfu.default,
1264
- "@typescript-eslint": pluginTs
844
+ antfu: import_eslint_plugin_antfu.default
1265
845
  }
1266
846
  },
1267
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
1268
- ...isTypeAware ? [
1269
- makeParser(false, files),
1270
- makeParser(true, filesTypeAware, ignoresTypeAware)
1271
- ] : [makeParser(false, files)],
1272
847
  {
1273
- files,
1274
848
  name: "solvro/typescript/rules",
1275
849
  rules: {
1276
- ...pluginTs.configs["eslint-recommended"].overrides[0].rules,
1277
- ...pluginTs.configs.strict.rules,
1278
- "no-dupe-class-members": "off",
1279
- "no-redeclare": "off",
1280
- "no-use-before-define": "off",
1281
- "no-useless-constructor": "off",
1282
850
  "@typescript-eslint/ban-ts-comment": [
1283
851
  "error",
1284
852
  { "ts-expect-error": "allow-with-description" }
@@ -1326,253 +894,121 @@ async function typescript(options = {}) {
1326
894
  "@typescript-eslint/no-wrapper-object-types": "error",
1327
895
  "@typescript-eslint/triple-slash-reference": "off",
1328
896
  "@typescript-eslint/unified-signatures": "off",
1329
- ...type === "lib" ? {
1330
- "@typescript-eslint/explicit-function-return-type": [
1331
- "error",
1332
- {
1333
- allowExpressions: true,
1334
- allowHigherOrderFunctions: true,
1335
- allowIIFEs: true
1336
- }
1337
- ]
1338
- } : {},
1339
- ...overrides
1340
- }
1341
- },
1342
- ...isTypeAware ? [
1343
- {
1344
- files: filesTypeAware,
1345
- ignores: ignoresTypeAware,
1346
- name: "solvro/typescript/rules-type-aware",
1347
- rules: {
1348
- ...typeAwareRules,
1349
- ...overridesTypeAware
1350
- }
897
+ // prevent unnecessary use of void operator
898
+ "@typescript-eslint/no-meaningless-void-operator": "error",
899
+ // "using non-null assertions cancels the benefits of the strict
900
+ // null-checking mode."
901
+ // warn when one of the types in union / intersection overrides others
902
+ "@typescript-eslint/no-redundant-type-constituents": "warn",
903
+ // prevent variables shadowing
904
+ "no-shadow": "error",
905
+ "@typescript-eslint/no-shadow": "error",
906
+ // prevent assignment of this, signals a wrong usage of it
907
+ "@typescript-eslint/no-this-alias": "error",
908
+ // prevent throwing non-error
909
+ "no-throw-literal": "off",
910
+ // prevent unnecessary explicitly adding a default type argument
911
+ "@typescript-eslint/no-unnecessary-type-arguments": "error",
912
+ // prevent unnecessary assertions that won't change the outcome
913
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
914
+ // prevent extending default types
915
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
916
+ // force typing out function arguments
917
+ "@typescript-eslint/no-unsafe-argument": "error",
918
+ // prevent usage of any via reassigning
919
+ "@typescript-eslint/no-unsafe-assignment": "error",
920
+ // prevent usage of any via calling it
921
+ "@typescript-eslint/no-unsafe-call": "error",
922
+ // prevent usage of any via using it's members
923
+ "@typescript-eslint/no-unsafe-member-access": "error",
924
+ // prevent reverting any from functions
925
+ "@typescript-eslint/no-unsafe-return": "error",
926
+ // prevent unused expressions
927
+ "no-unused-expressions": "off",
928
+ // var<'string'> = 'string' -> var = 'string' as const
929
+ "@typescript-eslint/prefer-as-const": "error",
930
+ // force initializing enums
931
+ "@typescript-eslint/prefer-enum-initializers": "error",
932
+ // prefer for x of obj to for let i = 0...
933
+ "@typescript-eslint/prefer-for-of": "error",
934
+ // prefer includes() to indexOf()
935
+ "@typescript-eslint/prefer-includes": "error",
936
+ // use literals for enum initialization
937
+ "@typescript-eslint/prefer-literal-enum-member": "error",
938
+ // prefer safe cascade of a value when dealing with undefined or null
939
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
940
+ // prefer optional chaining (a?.b)
941
+ "@typescript-eslint/prefer-optional-chain": "error",
942
+ // prefer using type parameter for Array.reduce
943
+ "@typescript-eslint/prefer-reduce-type-parameter": "error",
944
+ // prefer RegExp#exec when no /g flag in regex
945
+ "@typescript-eslint/prefer-regexp-exec": "error",
946
+ // enforce `this` as a type when stating type for a method
947
+ "@typescript-eslint/prefer-return-this-type": "error",
948
+ // enforce startsWith to indexOf === 0
949
+ "@typescript-eslint/prefer-string-starts-ends-with": "error",
950
+ // prevents default behavior of .sort() - which is confusing
951
+ "@typescript-eslint/require-array-sort-compare": "error",
952
+ // no async functions without awaits in body
953
+ "require-await": "off",
954
+ "@typescript-eslint/require-await": "error",
955
+ // prevent number + string
956
+ "@typescript-eslint/restrict-plus-operands": "error",
957
+ // only allow string in templates
958
+ "@typescript-eslint/restrict-template-expressions": "error",
959
+ // prevent returning await
960
+ "no-return-await": "off",
961
+ "@typescript-eslint/return-await": "error",
962
+ // only booleans in ifs and whiles
963
+ "@typescript-eslint/strict-boolean-expressions": "error",
964
+ // check if all paths are followed in code
965
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
966
+ "dot-notation": "off",
967
+ "no-implied-eval": "off",
968
+ "@typescript-eslint/await-thenable": "error",
969
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
970
+ "@typescript-eslint/no-floating-promises": "error",
971
+ "@typescript-eslint/no-for-in-array": "error",
972
+ "@typescript-eslint/no-implied-eval": "error",
973
+ "@typescript-eslint/no-misused-promises": "error",
974
+ "@typescript-eslint/promise-function-async": "error",
975
+ "@typescript-eslint/unbound-method": "error"
1351
976
  }
1352
- ] : []
977
+ }
1353
978
  ];
1354
979
  }
1355
980
 
1356
981
  // eslint-config/configs/unicorn.ts
1357
982
  init_cjs_shims();
1358
- async function unicorn(options = {}) {
983
+ function unicorn() {
1359
984
  return [
1360
985
  {
1361
986
  name: "solvro/unicorn/rules",
1362
987
  plugins: {
1363
988
  unicorn: import_eslint_plugin_unicorn.default
1364
989
  },
1365
- rules: {
1366
- ...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
1367
- "unicorn/consistent-empty-array-spread": "error",
1368
- "unicorn/error-message": "error",
1369
- "unicorn/escape-case": "error",
1370
- "unicorn/new-for-builtins": "error",
1371
- "unicorn/no-instanceof-array": "error",
1372
- "unicorn/no-new-array": "error",
1373
- "unicorn/no-new-buffer": "error",
1374
- "unicorn/number-literal-case": "error",
1375
- "unicorn/prefer-dom-node-text-content": "error",
1376
- "unicorn/prefer-includes": "error",
1377
- "unicorn/prefer-node-protocol": "error",
1378
- "unicorn/prefer-number-properties": "error",
1379
- "unicorn/prefer-string-starts-ends-with": "error",
1380
- "unicorn/prefer-type-error": "error",
1381
- "unicorn/throw-new-error": "error"
1382
- }
1383
- }
990
+ rules: import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules
1384
991
  }
1385
992
  ];
1386
993
  }
1387
994
 
1388
- // eslint-config/factory.ts
1389
- var flatConfigProps = [
1390
- "name",
1391
- "languageOptions",
1392
- "linterOptions",
1393
- "processor",
1394
- "plugins",
1395
- "rules",
1396
- "settings"
1397
- ];
1398
- function solvro(options = {}, ...userConfigs) {
1399
- const {
1400
- componentExts = [],
1401
- gitignore: enableGitignore = true,
1402
- jsx: enableJsx = true,
1403
- react: enableReact = false,
1404
- regexp: enableRegexp = true,
1405
- typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
1406
- unicorn: enableUnicorn = true
1407
- } = options;
1408
- let isInEditor = options.isInEditor;
1409
- if (isInEditor == null) {
1410
- isInEditor = isInEditorEnv();
1411
- if (isInEditor)
1412
- console.log(
1413
- "[@solvro/config] Detected running in editor, some rules are disabled."
1414
- );
1415
- }
1416
- const configs2 = [];
1417
- if (enableGitignore) {
1418
- if (typeof enableGitignore !== "boolean") {
1419
- configs2.push(
1420
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1421
- r({
1422
- name: "solvro/gitignore",
1423
- ...enableGitignore
1424
- })
1425
- ])
1426
- );
1427
- } else {
1428
- configs2.push(
1429
- interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
1430
- r({
1431
- name: "solvro/gitignore",
1432
- strict: false
1433
- })
1434
- ])
1435
- );
1436
- }
1437
- }
1438
- const typescriptOptions = resolveSubOptions(options, "typescript");
1439
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
1440
- configs2.push(
1441
- ignores(options.ignores),
1442
- javascript({
1443
- isInEditor,
1444
- overrides: getOverrides(options, "javascript")
1445
- }),
1446
- comments(),
1447
- node(),
1448
- jsdoc(),
1449
- imports(),
1450
- command()
1451
- );
1452
- if (enableUnicorn) {
1453
- configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
1454
- }
1455
- if (enableJsx) {
1456
- configs2.push(jsx());
1457
- }
1458
- if (enableTypeScript) {
1459
- configs2.push(
1460
- typescript({
1461
- ...typescriptOptions,
1462
- componentExts,
1463
- overrides: getOverrides(options, "typescript"),
1464
- type: options.type
1465
- })
1466
- );
1467
- }
1468
- if (enableRegexp) {
1469
- configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
1470
- }
1471
- if (options.test ?? true) {
1472
- configs2.push(
1473
- test({
1474
- isInEditor,
1475
- overrides: getOverrides(options, "test")
1476
- })
1477
- );
1478
- }
1479
- if (enableReact) {
1480
- configs2.push(
1481
- react({
1482
- ...typescriptOptions,
1483
- overrides: getOverrides(options, "react"),
1484
- tsconfigPath
1485
- })
1486
- );
1487
- }
1488
- if (options.markdown ?? true) {
1489
- configs2.push(
1490
- markdown({
1491
- componentExts,
1492
- overrides: getOverrides(options, "markdown")
1493
- })
1494
- );
1495
- }
1496
- if (options.formatters) {
1497
- configs2.push(formatters());
1498
- }
1499
- configs2.push(disables());
1500
- if ("files" in options) {
1501
- throw new Error(
1502
- '[@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.'
1503
- );
1504
- }
1505
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
1506
- if (key in options) acc[key] = options[key];
1507
- return acc;
1508
- }, {});
1509
- if (Object.keys(fusedConfig).length) configs2.push([fusedConfig]);
1510
- let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
1511
- composer = composer.append(...configs2, ...userConfigs);
1512
- return composer;
1513
- }
1514
- function resolveSubOptions(options, key) {
1515
- return typeof options[key] === "boolean" ? {} : options[key] || {};
1516
- }
1517
- function getOverrides(options, key) {
1518
- const sub = resolveSubOptions(options, key);
1519
- return {
1520
- ...options.overrides?.[key],
1521
- ..."overrides" in sub ? sub.overrides : {}
1522
- };
1523
- }
1524
-
1525
- // eslint-config/types.ts
1526
- init_cjs_shims();
1527
-
1528
995
  // eslint-config/index.ts
1529
- var eslint_config_default = solvro;
996
+ var solvro = (...configs) => import_typescript_eslint2.default.config(
997
+ ...react(),
998
+ ...typescript(),
999
+ ...javascript(),
1000
+ ...jsdoc(),
1001
+ ...unicorn(),
1002
+ ...disables(),
1003
+ ...imports(),
1004
+ ...comments(),
1005
+ ...ignores(),
1006
+ ...formatters(),
1007
+ ...node(),
1008
+ ...configs
1009
+ );
1530
1010
  // Annotate the CommonJS export names for ESM import in node:
1531
1011
  0 && (module.exports = {
1532
- GLOB_ALL_SRC,
1533
- GLOB_EXCLUDE,
1534
- GLOB_HTML,
1535
- GLOB_JS,
1536
- GLOB_JSON,
1537
- GLOB_JSON5,
1538
- GLOB_JSX,
1539
- GLOB_MARKDOWN,
1540
- GLOB_MARKDOWN_CODE,
1541
- GLOB_MARKDOWN_IN_MARKDOWN,
1542
- GLOB_SRC,
1543
- GLOB_SRC_EXT,
1544
- GLOB_STYLE,
1545
- GLOB_SVG,
1546
- GLOB_TESTS,
1547
- GLOB_TOML,
1548
- GLOB_TS,
1549
- GLOB_TSX,
1550
- GLOB_XML,
1551
- combine,
1552
- command,
1553
- comments,
1554
- disables,
1555
- ensurePackages,
1556
- formatters,
1557
- getOverrides,
1558
- ignores,
1559
- imports,
1560
- interopDefault,
1561
- isInEditorEnv,
1562
- isInGitHooksOrLintStaged,
1563
- isPackageInScope,
1564
- javascript,
1565
- jsdoc,
1566
- jsx,
1567
- markdown,
1568
- node,
1569
- parserPlain,
1570
- react,
1571
- regexp,
1572
- resolveSubOptions,
1573
- solvro,
1574
- test,
1575
- toArray,
1576
- typescript,
1577
- unicorn
1012
+ solvro
1578
1013
  });
1014
+ //# sourceMappingURL=index.cjs.map