@solvro/config 2.0.0-beta.3 → 2.0.0-beta.4

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,9 +1,30 @@
1
+ import {
2
+ default as default2,
3
+ default2 as default3,
4
+ default6 as default4
5
+ } from "../chunk-HM3MY7J3.js";
6
+ import {
7
+ init_esm_shims
8
+ } from "../chunk-J5OUMHDO.js";
9
+
10
+ // src/eslint/index.ts
11
+ init_esm_shims();
12
+ import { findUpSync as findUpSync2 } from "find-up-simple";
13
+ import { isPackageListed } from "local-pkg";
14
+ import path3 from "path";
15
+ import tseslint3 from "typescript-eslint";
16
+
17
+ // src/eslint/presets/base.ts
18
+ init_esm_shims();
19
+
1
20
  // node_modules/eslint-config-flat-gitignore/dist/index.mjs
21
+ init_esm_shims();
2
22
  import fs2 from "fs";
3
23
  import path2, { join, resolve, relative, dirname } from "path";
4
24
  import process2 from "process";
5
25
 
6
26
  // node_modules/@eslint/compat/dist/esm/index.js
27
+ init_esm_shims();
7
28
  import fs from "fs";
8
29
  import path from "path";
9
30
  function convertIgnorePatternToMinimatch(pattern) {
@@ -126,56 +147,8 @@ function parseGitSubmodules(content) {
126
147
  return content.split(/\r?\n/u).map((line) => line.match(/path\s*=\s*(.+)/u)).filter((match) => match !== null).map((match) => match[1].trim());
127
148
  }
128
149
 
129
- // src/eslint/index.ts
130
- import { findUpSync as findUpSync2 } from "find-up-simple";
131
- import { isPackageListed } from "local-pkg";
132
- import path3 from "path";
133
- import tseslint4 from "typescript-eslint";
134
- import { configApp } from "@adonisjs/eslint-config";
135
-
136
- // src/eslint/configs/a11y.ts
137
- import jsxA11y from "eslint-plugin-jsx-a11y";
138
- import globals from "globals";
139
- function a11y() {
140
- return [
141
- {
142
- files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
143
- ...jsxA11y.flatConfigs.recommended,
144
- languageOptions: {
145
- ...jsxA11y.flatConfigs.recommended.languageOptions,
146
- globals: {
147
- ...globals.serviceworker,
148
- ...globals.browser
149
- }
150
- },
151
- settings: {
152
- "jsx-a11y": {
153
- components: {
154
- Input: "input",
155
- Button: "button",
156
- Link: "a",
157
- Label: "label",
158
- Select: "select",
159
- Textarea: "textarea"
160
- },
161
- attributes: {
162
- for: ["htmlFor", "for"]
163
- }
164
- }
165
- }
166
- }
167
- ];
168
- }
169
-
170
- // src/eslint/plugins.ts
171
- import { default as default2 } from "@eslint-community/eslint-plugin-eslint-comments";
172
- import { default as default3 } from "eslint-plugin-antfu";
173
- import { default as default4 } from "eslint-plugin-import";
174
- import { default as default5 } from "eslint-plugin-n";
175
- import { default as default6 } from "eslint-plugin-unicorn";
176
- import { default as default7 } from "eslint-plugin-unused-imports";
177
-
178
150
  // src/eslint/configs/comments.ts
151
+ init_esm_shims();
179
152
  function comments() {
180
153
  return [
181
154
  {
@@ -195,9 +168,11 @@ function comments() {
195
168
  }
196
169
 
197
170
  // src/eslint/configs/disables.ts
171
+ init_esm_shims();
198
172
  import tseslint from "typescript-eslint";
199
173
 
200
174
  // src/eslint/globs.ts
175
+ init_esm_shims();
201
176
  var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
202
177
  var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
203
178
  var GLOB_JS = "**/*.?([cm])js";
@@ -303,6 +278,7 @@ function disables() {
303
278
  }
304
279
 
305
280
  // src/eslint/configs/formatters.ts
281
+ init_esm_shims();
306
282
  import prettierConfig from "eslint-config-prettier";
307
283
  function formatters() {
308
284
  return [
@@ -317,6 +293,7 @@ function formatters() {
317
293
  }
318
294
 
319
295
  // src/eslint/configs/ignores.ts
296
+ init_esm_shims();
320
297
  function ignores() {
321
298
  return [
322
299
  {
@@ -326,90 +303,19 @@ function ignores() {
326
303
  ];
327
304
  }
328
305
 
329
- // src/eslint/configs/imports.ts
330
- var forbiddenUiLibraries = [
331
- "@headlessui/react",
332
- "@mui/material",
333
- "@chakra-ui/react",
334
- "@chakra-ui/core",
335
- "@nextui-org/react",
336
- "react-bootstrap",
337
- "antd"
338
- ];
339
- function imports({
340
- forbidDefaultExport = true
341
- } = {}) {
342
- const config = [
343
- default4.flatConfigs.typescript,
344
- {
345
- name: "solvro/imports/rules",
346
- plugins: {
347
- antfu: default3
348
- },
349
- rules: {
350
- "antfu/import-dedupe": "error",
351
- "antfu/no-import-dist": "error",
352
- "antfu/no-import-node-modules-by-path": "error",
353
- ...default4.flatConfigs.recommended.rules,
354
- "import/no-dynamic-require": "warn",
355
- "import/no-unresolved": "off",
356
- "import/consistent-type-specifier-style": "warn",
357
- "@typescript-eslint/no-restricted-imports": [
358
- "error",
359
- {
360
- paths: [
361
- {
362
- name: "axios",
363
- message: "Please use fetch instead"
364
- },
365
- ...forbiddenUiLibraries.map((library) => ({
366
- name: library,
367
- message: `Please use ui.shadcn.com components instead.`
368
- }))
369
- ]
370
- }
371
- ]
372
- }
373
- }
374
- ];
375
- if (forbidDefaultExport) {
376
- config.push(
377
- {
378
- rules: { "import/no-default-export": "error" }
379
- },
380
- {
381
- files: [
382
- "tsup.config.*",
383
- "eslint.config.*",
384
- ".commitlintrc.*",
385
- "knip.*",
386
- "next.config.*",
387
- "commitlint.config.*",
388
- ".releaserc.*",
389
- "vitest.config.*",
390
- "playwright.config.*"
391
- ],
392
- rules: {
393
- "import/no-default-export": "off"
394
- }
395
- }
396
- );
397
- }
398
- return config;
399
- }
400
-
401
306
  // src/eslint/configs/javascript.ts
307
+ init_esm_shims();
402
308
  import eslint from "@eslint/js";
403
- import globals2 from "globals";
309
+ import globals from "globals";
404
310
  function javascript() {
405
311
  return [
406
312
  {
407
313
  languageOptions: {
408
314
  ecmaVersion: 2022,
409
315
  globals: {
410
- ...globals2.browser,
411
- ...globals2.es2021,
412
- ...globals2.node,
316
+ ...globals.browser,
317
+ ...globals.es2021,
318
+ ...globals.node,
413
319
  document: "readonly",
414
320
  navigator: "readonly",
415
321
  window: "readonly"
@@ -432,7 +338,7 @@ function javascript() {
432
338
  name: "solvro/javascript/rules",
433
339
  plugins: {
434
340
  antfu: default3,
435
- "unused-imports": default7
341
+ "unused-imports": default4
436
342
  },
437
343
  rules: {
438
344
  ...eslint.configs.recommended.rules,
@@ -622,6 +528,7 @@ function javascript() {
622
528
  }
623
529
 
624
530
  // src/eslint/configs/jsdoc.ts
531
+ init_esm_shims();
625
532
  import jsdocPlugin from "eslint-plugin-jsdoc";
626
533
  function jsdoc() {
627
534
  return [
@@ -651,129 +558,8 @@ function jsdoc() {
651
558
  ];
652
559
  }
653
560
 
654
- // src/eslint/configs/node.ts
655
- function node() {
656
- return [
657
- {
658
- name: "solvro/node/rules",
659
- plugins: {
660
- node: default5
661
- },
662
- rules: {
663
- "node/handle-callback-err": ["error", "^(err|error)$"],
664
- "node/no-deprecated-api": "error",
665
- "node/no-exports-assign": "error",
666
- "node/no-new-require": "error",
667
- "node/no-path-concat": "error",
668
- "node/prefer-global/buffer": ["error"],
669
- "node/prefer-global/process": ["error"],
670
- "node/process-exit-as-throw": "error"
671
- }
672
- }
673
- ];
674
- }
675
-
676
- // src/eslint/configs/react.ts
677
- import pluginQuery from "@tanstack/eslint-plugin-query";
678
- import pluginReact from "eslint-plugin-react";
679
- import pluginReactHooks from "eslint-plugin-react-hooks";
680
- import { isPackageExists } from "local-pkg";
681
- var nextJsPackages = ["next"];
682
- async function react() {
683
- const isUsingNext = nextJsPackages.some((index) => isPackageExists(index));
684
- const nextjsConfig = [];
685
- if (isUsingNext) {
686
- const nextPlugin = await import("@next/eslint-plugin-next").then(
687
- (d) => d.default
688
- );
689
- nextjsConfig.push(
690
- {
691
- name: "solvro/next/setup",
692
- plugins: {
693
- "@next/next": nextPlugin
694
- },
695
- rules: nextPlugin.configs.recommended.rules
696
- },
697
- {
698
- files: [
699
- "**/app/**/{page,loading,layout,template,error,not-found,unauthorized,forbidden,default,robots,sitemap}.{js,jsx,ts,tsx}",
700
- "**/pages/**/*.{js,jsx,ts,tsx}"
701
- ],
702
- name: "solvro/next/pages",
703
- rules: {
704
- "import/no-default-export": "off"
705
- }
706
- }
707
- );
708
- }
709
- return [
710
- {
711
- name: "solvro/react/setup",
712
- plugins: {
713
- react: pluginReact,
714
- "react-hooks": pluginReactHooks
715
- }
716
- },
717
- ...nextjsConfig,
718
- {
719
- files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
720
- languageOptions: {
721
- parserOptions: {
722
- ecmaFeatures: {
723
- jsx: true
724
- }
725
- },
726
- sourceType: "module"
727
- },
728
- settings: {
729
- react: {
730
- version: "detect"
731
- }
732
- },
733
- name: "solvro/react/rules",
734
- rules: {
735
- ...pluginReact.configs.flat.recommended.rules,
736
- ...pluginReact.configs.flat["jsx-runtime"].rules,
737
- "react/no-danger": "warn",
738
- "react/jsx-no-leaked-render": "warn",
739
- // recommended rules react-hooks
740
- "react-hooks/exhaustive-deps": "warn",
741
- "react-hooks/rules-of-hooks": "error",
742
- "react/jsx-no-useless-fragment": "error",
743
- "react/function-component-definition": [
744
- "error",
745
- {
746
- unnamedComponents: "arrow-function",
747
- namedComponents: "function-declaration"
748
- }
749
- ],
750
- "react/hook-use-state": [
751
- "error",
752
- {
753
- allowDestructuredState: true
754
- }
755
- ],
756
- "react/no-array-index-key": "warn"
757
- }
758
- },
759
- ...pluginQuery.configs["flat/recommended"],
760
- {
761
- name: "solvro/react/disables",
762
- files: ["**/components/ui/*.{jsx,tsx}"],
763
- rules: {
764
- "react/prop-types": "off",
765
- "no-shadow": "off",
766
- "@typescript-eslint/no-shadow": "off",
767
- "@typescript-eslint/restrict-template-expressions": "off",
768
- "unicorn/no-document-cookie": "off",
769
- "@typescript-eslint/no-redeclare": "off",
770
- "@typescript-eslint/no-deprecated": "off"
771
- }
772
- }
773
- ];
774
- }
775
-
776
561
  // src/eslint/configs/typescript-relaxed.ts
562
+ init_esm_shims();
777
563
  import tseslint2 from "typescript-eslint";
778
564
  function typescriptRelaxed() {
779
565
  return [
@@ -818,261 +604,21 @@ function typescriptRelaxed() {
818
604
  ];
819
605
  }
820
606
 
821
- // src/eslint/configs/typescript-strict.ts
822
- import tseslint3 from "typescript-eslint";
823
- function typescriptStrict() {
824
- return [
825
- ...tseslint3.configs.strictTypeChecked,
826
- ...tseslint3.configs.stylisticTypeChecked,
827
- {
828
- name: "solvro/typescript-strict/setup",
829
- plugins: {
830
- antfu: default3
831
- }
832
- },
833
- {
834
- files: ["**/*.{ts,tsx}"],
835
- name: "solvro/typescript-strict/rules",
836
- rules: {
837
- "@typescript-eslint/ban-ts-comment": [
838
- "error",
839
- { "ts-expect-error": "allow-with-description" }
840
- ],
841
- "@typescript-eslint/consistent-type-definitions": [
842
- "error",
843
- "interface"
844
- ],
845
- "@typescript-eslint/consistent-type-imports": [
846
- "error",
847
- {
848
- disallowTypeAnnotations: false,
849
- prefer: "type-imports"
850
- }
851
- ],
852
- "@typescript-eslint/method-signature-style": ["error", "property"],
853
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
854
- "@typescript-eslint/no-dupe-class-members": "error",
855
- "@typescript-eslint/no-empty-object-type": [
856
- "error",
857
- { allowInterfaces: "always" }
858
- ],
859
- "@typescript-eslint/no-import-type-side-effects": "error",
860
- "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }],
861
- "@typescript-eslint/no-require-imports": "error",
862
- "@typescript-eslint/no-unused-expressions": [
863
- "error",
864
- {
865
- allowShortCircuit: true,
866
- allowTaggedTemplates: true,
867
- allowTernary: true
868
- }
869
- ],
870
- "@typescript-eslint/no-use-before-define": [
871
- "error",
872
- { classes: false, functions: false, variables: true }
873
- ],
874
- "@typescript-eslint/no-wrapper-object-types": "error",
875
- // prevent unnecessary use of void operator
876
- "@typescript-eslint/no-meaningless-void-operator": "error",
877
- // "using non-null assertions cancels the benefits of the strict
878
- // null-checking mode."
879
- // warn when one of the types in union / intersection overrides others
880
- "@typescript-eslint/no-redundant-type-constituents": "warn",
881
- // prevent variables shadowing
882
- "no-shadow": "error",
883
- "@typescript-eslint/no-shadow": "error",
884
- // prevent assignment of this, signals a wrong usage of it
885
- "@typescript-eslint/no-this-alias": "error",
886
- // prevent throwing non-error
887
- "no-throw-literal": "off",
888
- // prevent unnecessary explicitly adding a default type argument
889
- "@typescript-eslint/no-unnecessary-type-arguments": "error",
890
- // prevent unnecessary assertions that won't change the outcome
891
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
892
- // prevent extending default types
893
- "@typescript-eslint/no-unnecessary-type-constraint": "error",
894
- // force typing out function arguments
895
- "@typescript-eslint/no-unsafe-argument": "error",
896
- // prevent usage of any via reassigning
897
- "@typescript-eslint/no-unsafe-assignment": "error",
898
- // prevent usage of any via calling it
899
- "@typescript-eslint/no-unsafe-call": "error",
900
- // prevent usage of any via using it's members
901
- "@typescript-eslint/no-unsafe-member-access": "error",
902
- // prevent reverting any from functions
903
- "@typescript-eslint/no-unsafe-return": "error",
904
- // prevent unused expressions
905
- "no-unused-expressions": "off",
906
- // var<'string'> = 'string' -> var = 'string' as const
907
- "@typescript-eslint/prefer-as-const": "error",
908
- // force initializing enums
909
- "@typescript-eslint/prefer-enum-initializers": "error",
910
- // prefer for x of obj to for let i = 0...
911
- "@typescript-eslint/prefer-for-of": "error",
912
- // prefer includes() to indexOf()
913
- "@typescript-eslint/prefer-includes": "error",
914
- // use literals for enum initialization
915
- "@typescript-eslint/prefer-literal-enum-member": "error",
916
- // prefer safe cascade of a value when dealing with undefined or null
917
- "@typescript-eslint/prefer-nullish-coalescing": "error",
918
- // prefer optional chaining (a?.b)
919
- "@typescript-eslint/prefer-optional-chain": "error",
920
- // prefer using type parameter for Array.reduce
921
- "@typescript-eslint/prefer-reduce-type-parameter": "error",
922
- // prefer RegExp#exec when no /g flag in regex
923
- "@typescript-eslint/prefer-regexp-exec": "error",
924
- // enforce `this` as a type when stating type for a method
925
- "@typescript-eslint/prefer-return-this-type": "error",
926
- // enforce startsWith to indexOf === 0
927
- "@typescript-eslint/prefer-string-starts-ends-with": "error",
928
- // prevents default behavior of .sort() - which is confusing
929
- "@typescript-eslint/require-array-sort-compare": "error",
930
- // no async functions without awaits in body
931
- "require-await": "off",
932
- "@typescript-eslint/require-await": "error",
933
- // prevent number + string
934
- "@typescript-eslint/restrict-plus-operands": "error",
935
- // only allow string in templates
936
- "@typescript-eslint/restrict-template-expressions": "error",
937
- // prevent returning await
938
- "no-return-await": "off",
939
- "@typescript-eslint/return-await": "error",
940
- // only booleans in ifs and whiles
941
- "@typescript-eslint/strict-boolean-expressions": "error",
942
- // check if all paths are followed in code
943
- "@typescript-eslint/switch-exhaustiveness-check": "error",
944
- "dot-notation": "off",
945
- "no-implied-eval": "off",
946
- "@typescript-eslint/await-thenable": "error",
947
- "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
948
- "@typescript-eslint/no-floating-promises": "error",
949
- "@typescript-eslint/no-for-in-array": "error",
950
- "@typescript-eslint/no-implied-eval": "error",
951
- "@typescript-eslint/no-misused-promises": "error",
952
- "@typescript-eslint/promise-function-async": "error",
953
- "@typescript-eslint/unbound-method": "error",
954
- "no-restricted-imports": "off"
955
- }
956
- }
957
- ];
958
- }
959
-
960
- // src/eslint/configs/unicorn.ts
961
- function unicorn() {
962
- return [
963
- {
964
- name: "solvro/unicorn/rules",
965
- plugins: {
966
- unicorn: default6
967
- },
968
- rules: {
969
- ...default6.configs["flat/recommended"].rules,
970
- "unicorn/no-array-reduce": "off",
971
- "unicorn/no-null": "off",
972
- "unicorn/no-useless-switch-case": "off",
973
- "unicorn/prefer-global-this": "off",
974
- "unicorn/prevent-abbreviations": [
975
- "error",
976
- {
977
- replacements: {
978
- env: false,
979
- envs: false,
980
- props: false,
981
- prop: false,
982
- ref: false
983
- },
984
- allowList: {
985
- e2e: true
986
- },
987
- ignore: [String.raw`e2e`]
988
- }
989
- ]
990
- }
991
- }
992
- ];
993
- }
994
-
995
- // src/eslint/index.ts
996
- var builtinAdonisConfig = configApp();
997
- var adonisConfig = [
998
- ...builtinAdonisConfig,
999
- ...node(),
1000
- ...imports(),
1001
- {
1002
- rules: {
1003
- "@typescript-eslint/naming-convention": [
1004
- "error",
1005
- {
1006
- selector: ["enum", "enumMember", "class", "interface", "typeLike"],
1007
- format: ["PascalCase"],
1008
- leadingUnderscore: "allow",
1009
- trailingUnderscore: "allow"
1010
- },
1011
- {
1012
- selector: ["classProperty", "classMethod", "method", "variableLike"],
1013
- format: ["camelCase"],
1014
- leadingUnderscore: "allow",
1015
- trailingUnderscore: "allow"
1016
- },
1017
- {
1018
- selector: "variable",
1019
- format: ["camelCase", "UPPER_CASE", "PascalCase"],
1020
- leadingUnderscore: "allow",
1021
- trailingUnderscore: "allow"
1022
- }
1023
- ]
1024
- }
1025
- }
1026
- ];
1027
- var nestjsConfig = [
1028
- ...node(),
1029
- ...unicorn(),
1030
- ...typescriptStrict(),
1031
- ...imports({ forbidDefaultExport: true }),
1032
- {
1033
- rules: {
1034
- "no-implicit-coercion": [
1035
- "error",
1036
- {
1037
- allow: ["+"]
1038
- }
1039
- ],
1040
- "unicorn/prefer-top-level-await": "off"
1041
- }
1042
- },
1043
- {
1044
- rules: {
1045
- "@typescript-eslint/no-extraneous-class": [
1046
- "error",
1047
- {
1048
- allowEmpty: true
1049
- }
1050
- ]
1051
- },
1052
- files: ["**/*.module.ts"]
1053
- },
1054
- {
1055
- rules: {
1056
- "@typescript-eslint/no-floating-promises": "off"
1057
- },
1058
- files: ["./src/main.ts"]
1059
- }
1060
- ];
1061
- var reactConfig = async () => [
1062
- ...a11y(),
1063
- ...unicorn(),
1064
- ...typescriptStrict(),
1065
- ...imports({ forbidDefaultExport: true }),
1066
- ...await react()
1067
- ];
1068
- var configs = [
607
+ // src/eslint/presets/base.ts
608
+ var basePreset = () => [
1069
609
  ignore(),
1070
610
  ...javascript(),
1071
611
  ...jsdoc(),
1072
612
  ...comments(),
1073
613
  ...typescriptRelaxed()
1074
614
  ];
1075
- var defaultOverrides = [...ignores(), ...formatters(), ...disables()];
615
+ var defaultOverridesPreset = () => [
616
+ ...ignores(),
617
+ ...formatters(),
618
+ ...disables()
619
+ ];
620
+
621
+ // src/eslint/index.ts
1076
622
  var solvro = async (...overrides) => {
1077
623
  const isAdonis = await isPackageListed("@adonisjs/core");
1078
624
  const isReact = await isPackageListed("react");
@@ -1080,15 +626,20 @@ var solvro = async (...overrides) => {
1080
626
  if (isReact && isAdonis) {
1081
627
  throw new Error("You can't use both Adonis and React in the same project");
1082
628
  }
1083
- const newConfig = [];
629
+ const configs = basePreset();
630
+ const projectConfigs = [];
1084
631
  if (isAdonis) {
1085
- newConfig.push(...adonisConfig);
1086
- }
1087
- if (isNestJs) {
1088
- newConfig.push(...nestjsConfig);
1089
- }
1090
- if (isReact) {
1091
- newConfig.push(...await reactConfig());
632
+ const { adonisPreset } = await import("../adonis-HMBH6E55.js");
633
+ projectConfigs.push(...adonisPreset());
634
+ } else if (isNestJs) {
635
+ const { nestjsPreset } = await import("../nestjs-JMOHWBQG.js");
636
+ projectConfigs.push(...nestjsPreset());
637
+ } else if (isReact) {
638
+ const { reactPreset } = await import("../react-4BBIFFXI.js");
639
+ projectConfigs.push(...await reactPreset());
640
+ } else {
641
+ const { nodePreset } = await import("../node-S7MI3CIK.js");
642
+ projectConfigs.push(...nodePreset());
1092
643
  }
1093
644
  const tsConfigPath = findUpSync2("tsconfig.json", {
1094
645
  cwd: process.cwd()
@@ -1097,17 +648,19 @@ var solvro = async (...overrides) => {
1097
648
  throw new Error("No tsconfig.json found");
1098
649
  }
1099
650
  const rootDirectory = path3.dirname(tsConfigPath);
1100
- configs.push({
651
+ const tsConfig = {
1101
652
  languageOptions: {
1102
653
  parserOptions: {
1103
654
  projectService: true,
1104
655
  tsconfigRootDir: rootDirectory
1105
656
  }
1106
657
  }
1107
- });
1108
- return tseslint4.config(
658
+ };
659
+ const defaultOverrides = defaultOverridesPreset();
660
+ return tseslint3.config(
1109
661
  ...configs,
1110
- ...newConfig,
662
+ tsConfig,
663
+ ...projectConfigs,
1111
664
  ...defaultOverrides,
1112
665
  ...overrides
1113
666
  );