eslint-config-un 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -33,16 +33,57 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.6.3_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
36
+ // node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.7.2_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.6.3_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "node_modules/.pnpm/tsup@8.3.5_jiti@2.0.0_postcss@8.4.47_tsx@4.16.2_typescript@5.7.2_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
39
39
  "use strict";
40
40
  }
41
41
  });
42
42
 
43
- // node_modules/.pnpm/@eslint+js@9.14.0/node_modules/@eslint/js/src/configs/eslint-all.js
43
+ // node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/package.json
44
+ var require_package = __commonJS({
45
+ "node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/package.json"(exports2, module2) {
46
+ module2.exports = {
47
+ name: "@eslint/js",
48
+ version: "9.17.0",
49
+ description: "ESLint JavaScript language implementation",
50
+ main: "./src/index.js",
51
+ types: "./types/index.d.ts",
52
+ scripts: {
53
+ "test:types": "tsc -p tests/types/tsconfig.json"
54
+ },
55
+ files: [
56
+ "LICENSE",
57
+ "README.md",
58
+ "src",
59
+ "types"
60
+ ],
61
+ publishConfig: {
62
+ access: "public"
63
+ },
64
+ repository: {
65
+ type: "git",
66
+ url: "https://github.com/eslint/eslint.git",
67
+ directory: "packages/js"
68
+ },
69
+ homepage: "https://eslint.org",
70
+ bugs: "https://github.com/eslint/eslint/issues/",
71
+ keywords: [
72
+ "javascript",
73
+ "eslint-plugin",
74
+ "eslint"
75
+ ],
76
+ license: "MIT",
77
+ engines: {
78
+ node: "^18.18.0 || ^20.9.0 || >=21.1.0"
79
+ }
80
+ };
81
+ }
82
+ });
83
+
84
+ // node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-all.js
44
85
  var require_eslint_all = __commonJS({
45
- "node_modules/.pnpm/@eslint+js@9.14.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports2, module2) {
86
+ "node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports2, module2) {
46
87
  "use strict";
47
88
  init_cjs_shims();
48
89
  module2.exports = Object.freeze({
@@ -249,9 +290,9 @@ var require_eslint_all = __commonJS({
249
290
  }
250
291
  });
251
292
 
252
- // node_modules/.pnpm/@eslint+js@9.14.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
293
+ // node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
253
294
  var require_eslint_recommended = __commonJS({
254
- "node_modules/.pnpm/@eslint+js@9.14.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports2, module2) {
295
+ "node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports2, module2) {
255
296
  "use strict";
256
297
  init_cjs_shims();
257
298
  module2.exports = Object.freeze({
@@ -322,12 +363,17 @@ var require_eslint_recommended = __commonJS({
322
363
  }
323
364
  });
324
365
 
325
- // node_modules/.pnpm/@eslint+js@9.14.0/node_modules/@eslint/js/src/index.js
366
+ // node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js
326
367
  var require_src = __commonJS({
327
- "node_modules/.pnpm/@eslint+js@9.14.0/node_modules/@eslint/js/src/index.js"(exports2, module2) {
368
+ "node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js"(exports2, module2) {
328
369
  "use strict";
329
370
  init_cjs_shims();
371
+ var { version } = require_package();
330
372
  module2.exports = {
373
+ meta: {
374
+ name: "@eslint/js",
375
+ version
376
+ },
331
377
  configs: {
332
378
  all: require_eslint_all(),
333
379
  recommended: require_eslint_recommended()
@@ -345,13 +391,13 @@ __export(src_exports, {
345
391
  module.exports = __toCommonJS(src_exports);
346
392
  init_cjs_shims();
347
393
  var import_node_fs = __toESM(require("fs"), 1);
348
- var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
394
+ var import_eslint_plugin2 = __toESM(require("@stylistic/eslint-plugin"), 1);
349
395
  var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
350
396
  var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
351
397
  var import_eslint_plugin_disable_autofix = __toESM(require("eslint-plugin-disable-autofix"), 1);
352
398
  var import_eslint_plugin_unicorn2 = __toESM(require("eslint-plugin-unicorn"), 1);
353
399
  var import_globals2 = __toESM(require("globals"), 1);
354
- var import_local_pkg = require("local-pkg");
400
+ var import_local_pkg2 = require("local-pkg");
355
401
 
356
402
  // src/configs/css-in-js.ts
357
403
  init_cjs_shims();
@@ -369,7 +415,9 @@ var GLOB_CONFIG_FILES = [
369
415
  `**/*.config.${GLOB_JS_TS_X_EXTENSION}`,
370
416
  `**/.*rc.${GLOB_JS_TS_X_EXTENSION}`
371
417
  ];
372
- var GLOB_TS = "**/*.?([cm])ts";
418
+ var GLOB_TS_EXTENSION = "?([cm])ts";
419
+ var GLOB_TS_X_EXTENSION = `${GLOB_TS_EXTENSION}?(x)`;
420
+ var GLOB_TS = `**/*.${GLOB_TS_EXTENSION}`;
373
421
  var GLOB_TSX = `${GLOB_TS}x`;
374
422
  var GLOB_VUE = "**/*.vue";
375
423
  var GLOB_JSON = "**/*.json";
@@ -393,10 +441,8 @@ var GLOB_MARKDOWN_SUPPORTED_CODE_BLOCKS = `${GLOB_MARKDOWN}/**/*.{${GLOB_SUPPORT
393
441
  var GLOB_MARKDOWN_ALL_CODE_BLOCKS = `${GLOB_MARKDOWN}/**/*.*`;
394
442
  var DEFAULT_GLOBAL_IGNORES = ["**/dist"];
395
443
 
396
- // src/utils.ts
444
+ // src/eslint.ts
397
445
  init_cjs_shims();
398
- var import_node_path = __toESM(require("path"), 1);
399
- var import_utils = require("@antfu/utils");
400
446
  var genFlatConfigEntryName = (name) => `eslint-config-un/${name}`;
401
447
  var createPluginObjectRenamer = (from, to) => {
402
448
  const fromRegex = new RegExp(`^${from}/`);
@@ -407,16 +453,6 @@ var createPluginObjectRenamer = (from, to) => {
407
453
  ])
408
454
  );
409
455
  };
410
- var assignOptions = (options, key) => ({
411
- ...typeof options[key] === "object" && options[key]
412
- });
413
- var arraify = (value) => Array.isArray(value) ? value : value == null ? [] : [value];
414
- var isNonEmptyArray = (value) => Array.isArray(value) && value.length > 0;
415
- var joinPaths = (...paths) => (
416
- // eslint-disable-next-line unicorn/prefer-native-coercion-functions
417
- import_node_path.default.posix.join(...arraify(paths).filter((v) => Boolean(v)))
418
- );
419
- var maybeCall = (fnOrValue, ...args) => typeof fnOrValue === "function" ? fnOrValue(...args) : fnOrValue;
420
456
  var ConfigEntryBuilder = class {
421
457
  constructor(options, internalOptions) {
422
458
  this.options = options;
@@ -456,7 +492,7 @@ var ConfigEntryBuilder = class {
456
492
  (configFinal.rules ||= {})[ruleName] = 0;
457
493
  }
458
494
  if (options?.overrideBaseRule) {
459
- const baseRuleName = ruleName.split("/").slice(1).join("/");
495
+ const baseRuleName = typeof options.overrideBaseRule === "string" ? options.overrideBaseRule : ruleName.split("/").slice(1).join("/");
460
496
  if (baseRuleName) {
461
497
  (configFinal.rules ||= {})[baseRuleName] = 0;
462
498
  }
@@ -542,10 +578,28 @@ var eslintCommentsEslintConfig = (options = {}, internalOptions = {}) => {
542
578
 
543
579
  // src/configs/import.ts
544
580
  init_cjs_shims();
581
+ var import_eslint_import_resolver_typescript = require("eslint-import-resolver-typescript");
545
582
  var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
583
+
584
+ // src/utils.ts
585
+ init_cjs_shims();
586
+ var import_node_path = __toESM(require("path"), 1);
587
+ var import_utils = require("@antfu/utils");
588
+ var assignOptions = (options, key) => ({
589
+ ...typeof options[key] === "object" && options[key]
590
+ });
591
+ var arraify = (value) => Array.isArray(value) ? value : value == null ? [] : [value];
592
+ var isNonEmptyArray = (value) => Array.isArray(value) && value.length > 0;
593
+ var joinPaths = (...paths) => (
594
+ // eslint-disable-next-line unicorn/prefer-native-coercion-functions
595
+ import_node_path.default.posix.join(...arraify(paths).filter((v) => Boolean(v)))
596
+ );
597
+ var maybeCall = (fnOrValue, ...args) => typeof fnOrValue === "function" ? fnOrValue(...args) : fnOrValue;
598
+
599
+ // src/configs/import.ts
546
600
  var pluginRenamer = createPluginObjectRenamer("import-x", "import");
547
601
  var importEslintConfig = (options = {}, internalOptions = {}) => {
548
- const { isTypescriptEnabled } = options;
602
+ const { isTypescriptEnabled, noDuplicatesOptions } = options;
549
603
  const noUnresolvedIgnores = arraify(options.importPatternsToIgnoreWhenTryingToResolve);
550
604
  const builder = new ConfigEntryBuilder(options, internalOptions);
551
605
  builder.addConfig(["import", { includeDefaultFilesAndIgnores: true }], {
@@ -555,16 +609,14 @@ var importEslintConfig = (options = {}, internalOptions = {}) => {
555
609
  },
556
610
  settings: {
557
611
  ...isTypescriptEnabled && import_eslint_plugin_import_x.default.configs.typescript.settings,
558
- "import-x/resolver": {
559
- ...isTypescriptEnabled && {
560
- typescript: {
561
- project: true,
562
- alwaysTryTypes: true
563
- }
564
- },
565
- node: true
566
- // TODO
567
- },
612
+ "import-x/resolver-next": [
613
+ // If the TS resolver goes after the node resolver, `import/no-deprecated` doesn't work
614
+ // TODO should report?
615
+ isTypescriptEnabled && (0, import_eslint_import_resolver_typescript.createTypeScriptImportResolver)({
616
+ alwaysTryTypes: true
617
+ }),
618
+ import_eslint_plugin_import_x.default.createNodeResolver()
619
+ ].filter((v) => typeof v === "object"),
568
620
  ...isTypescriptEnabled && {
569
621
  "import-x/parsers": {
570
622
  "@typescript-eslint/parser": [".ts", ".cts", ".mts", ".tsx", ".ctsx", ".mtsx"]
@@ -582,7 +634,7 @@ var importEslintConfig = (options = {}, internalOptions = {}) => {
582
634
  ),
583
635
  ...typeof options.requireModuleExtensions === "object" && options.requireModuleExtensions
584
636
  }
585
- ]).addRule("import/first", ERROR).addRule("import/newline-after-import", ERROR).addRule("import/no-absolute-path", ERROR).addRule("import/no-cycle", WARNING).addRule("import/no-default-export", ERROR).addRule("import/no-deprecated", WARNING).addRule("import/no-empty-named-blocks", ERROR).addRule("import/no-extraneous-dependencies", ERROR, [{ peerDependencies: false }]).addRule("import/no-mutable-exports", WARNING).addRule("import/no-named-as-default-member", OFF).addRule("import/no-named-as-default", OFF).addRule("import/no-self-import", ERROR).addRule("import/no-unresolved", ERROR, [
637
+ ]).addRule("import/first", ERROR).addRule("import/newline-after-import", ERROR).addRule("import/no-absolute-path", ERROR).addRule("import/no-cycle", WARNING).addRule("import/no-default-export", ERROR).addRule("import/no-deprecated", WARNING).addRule("import/no-duplicates", ERROR, [{ "prefer-inline": true, ...noDuplicatesOptions }]).addRule("import/no-empty-named-blocks", ERROR).addRule("import/no-extraneous-dependencies", ERROR, [{ peerDependencies: false }]).addRule("import/no-mutable-exports", WARNING).addRule("import/no-named-as-default-member", OFF).addRule("import/no-named-as-default", OFF).addRule("import/no-self-import", ERROR).addRule("import/no-unresolved", ERROR, [
586
638
  {
587
639
  ...isNonEmptyArray(noUnresolvedIgnores) && {
588
640
  ignore: noUnresolvedIgnores
@@ -597,6 +649,164 @@ var importEslintConfig = (options = {}, internalOptions = {}) => {
597
649
  return builder.getAllConfigs();
598
650
  };
599
651
 
652
+ // src/configs/jest.ts
653
+ init_cjs_shims();
654
+ var import_eslint_plugin_jest = __toESM(require("eslint-plugin-jest"), 1);
655
+ var import_eslint_plugin_jest_extended = __toESM(require("eslint-plugin-jest-extended"), 1);
656
+ var import_local_pkg = require("local-pkg");
657
+ var generateDefaultTestFiles = (extensions) => [
658
+ `**/*.spec.${extensions}`,
659
+ // GitHub: 2.3M .ts files as of 2024-12-08 (https://github.com/search?q=path%3A**%2F*.spec.ts&type=code&query=path%3A%2F**%2F__tests__%2F**%2F*.ts)
660
+ `**/*.test.${extensions}`,
661
+ // 1.9M
662
+ `__tests__/**/*.${extensions}`,
663
+ // 155k
664
+ `__test__/**/*.${extensions}`
665
+ // 14k
666
+ ];
667
+ var jestEslintConfig = (options = {}, internalOptions = {}) => {
668
+ const {
669
+ settings: pluginSettings,
670
+ testDefinitionKeyword,
671
+ maxAssertionCalls,
672
+ maxNestedDescribes,
673
+ restrictedMethods,
674
+ restrictedMatchers,
675
+ paddingAround = true,
676
+ asyncMatchers,
677
+ minAndMaxExpectArgs,
678
+ typescript: typescriptOnlyRules = internalOptions.isTypescriptEnabled,
679
+ jestExtended = (0, import_local_pkg.getPackageInfoSync)("jest-extended") != null
680
+ } = options;
681
+ const defaultJestEslintConfig = {
682
+ ...pluginSettings && {
683
+ settings: {
684
+ jest: pluginSettings
685
+ }
686
+ },
687
+ languageOptions: {
688
+ // Yes, `globals.globals` is required
689
+ globals: import_eslint_plugin_jest.default.environments.globals.globals
690
+ }
691
+ };
692
+ const defaultJestFiles = generateDefaultTestFiles(GLOB_JS_TS_X_EXTENSION);
693
+ const defaultJestTypescriptFiles = generateDefaultTestFiles(GLOB_TS_X_EXTENSION);
694
+ const hasRestrictedMethods = Object.keys(restrictedMethods || {}).length > 0;
695
+ const hasRestrictedMatchers = Object.keys(restrictedMatchers || {}).length > 0;
696
+ const getPaddingAroundSeverity = (key) => paddingAround === true || paddingAround && paddingAround[key] !== false ? ERROR : OFF;
697
+ const builder = new ConfigEntryBuilder(options, internalOptions);
698
+ builder.addConfig("jest/setup", {
699
+ plugins: {
700
+ jest: import_eslint_plugin_jest.default
701
+ }
702
+ });
703
+ builder.addConfig("jest/extended/setup", {
704
+ plugins: {
705
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
706
+ "jest-extended": import_eslint_plugin_jest_extended.default
707
+ }
708
+ });
709
+ builder.addConfig(
710
+ [
711
+ "jest",
712
+ {
713
+ includeDefaultFilesAndIgnores: true,
714
+ filesFallback: defaultJestFiles
715
+ }
716
+ ],
717
+ {
718
+ ...defaultJestEslintConfig
719
+ }
720
+ ).addBulkRules(import_eslint_plugin_jest.default.configs["flat/recommended"].rules).addRule("jest/consistent-test-it", testDefinitionKeyword === false ? OFF : ERROR, [
721
+ {
722
+ fn: "it",
723
+ withinDescribe: "it",
724
+ ...testDefinitionKeyword
725
+ }
726
+ ]).addRule("jest/expect-expect", ERROR).addRule("jest/max-expects", maxAssertionCalls == null ? OFF : ERROR, [
727
+ { max: maxAssertionCalls }
728
+ ]).addRule("jest/max-nested-describe", maxNestedDescribes == null ? OFF : ERROR, [
729
+ { max: maxNestedDescribes }
730
+ ]).addRule("jest/no-commented-out-tests", WARNING).addRule("jest/no-confusing-set-timeout", ERROR).addRule("jest/no-duplicate-hooks", ERROR).addRule("jest/no-restricted-jest-methods", hasRestrictedMethods ? ERROR : OFF, [
731
+ restrictedMethods || {}
732
+ ]).addRule("jest/no-restricted-matchers", hasRestrictedMatchers ? ERROR : OFF, [
733
+ restrictedMatchers || {}
734
+ ]).addRule("jest/no-test-return-statement", ERROR).addRule("jest/padding-around-after-all-blocks", getPaddingAroundSeverity("afterAll")).addRule("jest/padding-around-after-each-blocks", getPaddingAroundSeverity("afterEach")).addRule("jest/padding-around-before-all-blocks", getPaddingAroundSeverity("beforeAll")).addRule("jest/padding-around-before-each-blocks", getPaddingAroundSeverity("beforeEach")).addRule("jest/padding-around-describe-blocks", getPaddingAroundSeverity("describe")).addRule("jest/padding-around-expect-groups", getPaddingAroundSeverity("expect")).addRule("jest/padding-around-test-blocks", getPaddingAroundSeverity("test")).addRule("jest/prefer-comparison-matcher", ERROR).addRule("jest/prefer-each", WARNING).addRule("jest/prefer-equality-matcher", ERROR).addRule("jest/prefer-expect-assertions", OFF).addRule("jest/prefer-expect-resolves", ERROR).addRule("jest/prefer-hooks-in-order", ERROR).addRule("jest/prefer-hooks-on-top", ERROR).addRule("jest/prefer-jest-mocked", ERROR).addRule("jest/prefer-lowercase-title", ERROR).addRule("jest/prefer-mock-promise-shorthand", ERROR).addRule("jest/prefer-spy-on", ERROR).addRule("jest/prefer-strict-equal", WARNING).addRule("jest/prefer-to-be", ERROR).addRule("jest/prefer-to-contain", ERROR).addRule("jest/prefer-to-have-length", ERROR).addRule("jest/prefer-todo", WARNING).addRule("jest/require-hook", WARNING).addRule("jest/require-to-throw-message", OFF).addRule("jest/require-top-level-describe", OFF).addRule("jest/valid-expect", ERROR, [
735
+ {
736
+ alwaysAwait: true,
737
+ // Default: false
738
+ ...asyncMatchers?.length && { asyncMatchers },
739
+ ...minAndMaxExpectArgs?.[0] != null && minAndMaxExpectArgs[0] >= 0 && {
740
+ minArgs: minAndMaxExpectArgs[0]
741
+ },
742
+ ...minAndMaxExpectArgs?.[1] != null && minAndMaxExpectArgs[1] >= 0 && {
743
+ maxArgs: minAndMaxExpectArgs[1]
744
+ }
745
+ }
746
+ ]).addRule("jest/valid-expect-in-promise", ERROR).addRule("jest/valid-title", ERROR).addOverrides();
747
+ const tsBuilder = new ConfigEntryBuilder(
748
+ typeof typescriptOnlyRules === "object" ? typescriptOnlyRules : {},
749
+ internalOptions
750
+ );
751
+ if (typescriptOnlyRules) {
752
+ builder.addConfig(
753
+ [
754
+ "jest/ts",
755
+ {
756
+ includeDefaultFilesAndIgnores: true,
757
+ filesFallback: defaultJestTypescriptFiles
758
+ }
759
+ ],
760
+ {
761
+ ...defaultJestEslintConfig
762
+ }
763
+ ).addRule("jest/no-untyped-mock-factory", ERROR).addRule("jest/unbound-method", internalOptions.isTypescriptEnabled ? ERROR : OFF, [], {
764
+ // https://github.com/jest-community/eslint-plugin-jest/blob/HEAD/docs/rules/unbound-method.md#how-to-use
765
+ overrideBaseRule: "@typescript-eslint/unbound-method"
766
+ }).addOverrides();
767
+ }
768
+ const jestExtendedBuilder = new ConfigEntryBuilder(
769
+ typeof jestExtended === "object" ? jestExtended : {},
770
+ internalOptions
771
+ );
772
+ if (jestExtended) {
773
+ const { suggestUsing } = typeof jestExtended === "object" ? jestExtended : {};
774
+ const getSuggestUsingJestExtendedMatcherSeverity = (key) => suggestUsing === true || suggestUsing && suggestUsing[key] !== false ? ERROR : OFF;
775
+ jestExtendedBuilder.addConfig(
776
+ [
777
+ "jest/extended",
778
+ {
779
+ includeDefaultFilesAndIgnores: true,
780
+ filesFallback: defaultJestFiles
781
+ }
782
+ ],
783
+ {
784
+ ...defaultJestEslintConfig
785
+ }
786
+ ).addBulkRules(import_eslint_plugin_jest_extended.default.configs["flat/recommended"].rules).addRule(
787
+ "jest-extended/prefer-to-be-array",
788
+ getSuggestUsingJestExtendedMatcherSeverity("toBeArray")
789
+ ).addRule(
790
+ "jest-extended/prefer-to-be-false",
791
+ getSuggestUsingJestExtendedMatcherSeverity("toBeFalse")
792
+ ).addRule(
793
+ "jest-extended/prefer-to-be-object",
794
+ getSuggestUsingJestExtendedMatcherSeverity("toBeObject")
795
+ ).addRule(
796
+ "jest-extended/prefer-to-be-true",
797
+ getSuggestUsingJestExtendedMatcherSeverity("toBeTrue")
798
+ ).addRule(
799
+ "jest-extended/prefer-to-have-been-called-once",
800
+ getSuggestUsingJestExtendedMatcherSeverity("toHaveBeenCalledOnce")
801
+ );
802
+ }
803
+ return [
804
+ ...builder.getAllConfigs(),
805
+ ...tsBuilder.getAllConfigs(),
806
+ ...jestExtendedBuilder.getAllConfigs()
807
+ ];
808
+ };
809
+
600
810
  // src/configs/js.ts
601
811
  init_cjs_shims();
602
812
  var import_js = __toESM(require_src(), 1);
@@ -910,7 +1120,8 @@ var DEFAULT_COLLECTIONS_TO_SORT = {
910
1120
  dependencies: true,
911
1121
  peerDependencies: true,
912
1122
  peerDependenciesMeta: true,
913
- optionalDependencies: true
1123
+ optionalDependencies: true,
1124
+ overrides: true
914
1125
  };
915
1126
  var packageJsonEslintConfig = (options = {}, internalOptions = {}) => {
916
1127
  const builder = new ConfigEntryBuilder(options, internalOptions);
@@ -964,10 +1175,10 @@ var promiseEslintConfig = (options = {}, internalOptions = {}) => {
964
1175
  }
965
1176
  }).addBulkRules(import_eslint_plugin_promise.default.configs.recommended.rules).addRule("promise/always-return", ERROR, [{ ignoreLastCallback: true }]).addRule("promise/catch-or-return", ERROR, [
966
1177
  {
967
- allowThen: true,
1178
+ allowThenStrict: true,
968
1179
  allowFinally: true
969
1180
  }
970
- ]).addRule("promise/no-callback-in-promise", ERROR).addRule("promise/no-multiple-resolved", WARNING).addRule("promise/no-nesting", WARNING).addRule("promise/no-promise-in-callback", WARNING).addRule("promise/no-return-in-finally", ERROR).addRule("promise/no-return-wrap", ERROR, [{ allowReject: true }]).addRule("promise/spec-only", ERROR).addRule("promise/valid-params", ERROR).addOverrides();
1181
+ ]).addRule("promise/no-callback-in-promise", ERROR).addRule("promise/no-multiple-resolved", WARNING).addRule("promise/no-nesting", WARNING).addRule("promise/no-promise-in-callback", WARNING).addRule("promise/no-return-in-finally", ERROR).addRule("promise/no-return-wrap", ERROR, [{ allowReject: true }]).addRule("promise/prefer-catch", ERROR).addRule("promise/spec-only", ERROR).addRule("promise/valid-params", ERROR).addOverrides();
971
1182
  return builder.getAllConfigs();
972
1183
  };
973
1184
 
@@ -1013,7 +1224,7 @@ var sonarEslintConfig = (options = {}, internalOptions = {}) => {
1013
1224
 
1014
1225
  // src/configs/tailwind.ts
1015
1226
  init_cjs_shims();
1016
- var import_utils15 = require("@antfu/utils");
1227
+ var import_utils4 = require("@antfu/utils");
1017
1228
  var import_eslint_plugin_tailwindcss = __toESM(require("eslint-plugin-tailwindcss"), 1);
1018
1229
  var DEFAULT_PLUGIN_SETTINGS = {
1019
1230
  callees: ["classnames", "clsx", "ctl", "cva", "tv"],
@@ -1031,7 +1242,7 @@ var tailwindEslintConfig = (options = {}, internalOptions = {}) => {
1031
1242
  settings: {
1032
1243
  tailwindcss: {
1033
1244
  ...settings,
1034
- ...(0, import_utils15.objectKeys)(DEFAULT_PLUGIN_SETTINGS).reduce(
1245
+ ...(0, import_utils4.objectKeys)(DEFAULT_PLUGIN_SETTINGS).reduce(
1035
1246
  (acc, settingKey) => {
1036
1247
  if (settings[settingKey]) {
1037
1248
  acc[settingKey] = maybeCall(
@@ -1128,7 +1339,7 @@ var tsEslintConfig = (options = {}, internalOptions = {}) => {
1128
1339
  const tsVersion = options.typescriptVersion ? Number.parseFloat(options.typescriptVersion) : void 0;
1129
1340
  const generateBaseOptions = (isTypeAware) => ({
1130
1341
  languageOptions: {
1131
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
1342
+ // @ts-expect-error small types mismatch
1132
1343
  parser: import_typescript_eslint.parser,
1133
1344
  parserOptions: {
1134
1345
  extraFileExtensions: options.extraFileExtensions?.map((ext) => `.${ext}`),
@@ -1271,6 +1482,81 @@ var unicornEslintConfig = (options = {}, internalOptions = {}) => {
1271
1482
  return builder.getAllConfigs();
1272
1483
  };
1273
1484
 
1485
+ // src/configs/vitest.ts
1486
+ init_cjs_shims();
1487
+ var import_eslint_plugin = __toESM(require("@vitest/eslint-plugin"), 1);
1488
+ var vitestEslintConfig = (options = {}, internalOptions = {}) => {
1489
+ const {
1490
+ settings: pluginSettings,
1491
+ testDefinitionKeyword,
1492
+ maxAssertionCalls,
1493
+ maxNestedDescribes,
1494
+ restrictedMethods,
1495
+ restrictedMatchers,
1496
+ asyncMatchers,
1497
+ minAndMaxExpectArgs
1498
+ } = options;
1499
+ const defaultVitestEslintConfig = {
1500
+ ...pluginSettings && {
1501
+ settings: {
1502
+ vitest: pluginSettings
1503
+ }
1504
+ },
1505
+ languageOptions: {
1506
+ // TODO why `eslint-plugin-vitest-globals` is used instead of this?
1507
+ globals: import_eslint_plugin.default.environments.env.globals
1508
+ }
1509
+ };
1510
+ const defaultVitestFiles = generateDefaultTestFiles(GLOB_JS_TS_X_EXTENSION);
1511
+ const hasRestrictedMethods = Object.keys(restrictedMethods || {}).length > 0;
1512
+ const hasRestrictedMatchers = Object.keys(restrictedMatchers || {}).length > 0;
1513
+ const builder = new ConfigEntryBuilder(options, internalOptions);
1514
+ builder.addConfig("vitest/setup", {
1515
+ plugins: {
1516
+ vitest: import_eslint_plugin.default
1517
+ }
1518
+ });
1519
+ builder.addConfig(
1520
+ [
1521
+ "vitest",
1522
+ {
1523
+ includeDefaultFilesAndIgnores: true,
1524
+ filesFallback: defaultVitestFiles
1525
+ }
1526
+ ],
1527
+ {
1528
+ ...defaultVitestEslintConfig
1529
+ }
1530
+ ).addBulkRules(import_eslint_plugin.default.configs.recommended.rules).addRule("vitest/consistent-test-it", testDefinitionKeyword === false ? OFF : ERROR, [
1531
+ {
1532
+ fn: "it",
1533
+ withinDescribe: "it",
1534
+ ...testDefinitionKeyword
1535
+ }
1536
+ ]).addRule("vitest/max-expects", maxAssertionCalls == null ? OFF : ERROR, [
1537
+ { max: maxAssertionCalls }
1538
+ ]).addRule("vitest/max-nested-describe", maxNestedDescribes == null ? OFF : ERROR, [
1539
+ { max: maxNestedDescribes }
1540
+ ]).addRule("vitest/no-alias-methods", ERROR).addRule("vitest/no-commented-out-tests", WARNING).addRule("vitest/no-conditional-expect", ERROR).addRule("vitest/no-conditional-tests", ERROR).addRule("vitest/no-disabled-tests", WARNING).addRule("vitest/no-duplicate-hooks", ERROR).addRule("vitest/no-focused-tests", ERROR).addRule("vitest/no-interpolation-in-snapshots", ERROR).addRule("vitest/no-mocks-import", ERROR).addRule("vitest/no-restricted-matchers", hasRestrictedMatchers ? ERROR : OFF, [
1541
+ restrictedMatchers || {}
1542
+ ]).addRule("vitest/no-restricted-vi-methods", hasRestrictedMethods ? ERROR : OFF, [
1543
+ restrictedMethods || {}
1544
+ ]).addRule("vitest/no-standalone-expect", ERROR).addRule("vitest/no-test-prefixes", ERROR).addRule("vitest/no-test-return-statement", ERROR).addRule("vitest/prefer-comparison-matcher", ERROR).addRule("vitest/prefer-each", WARNING).addRule("vitest/prefer-equality-matcher", ERROR).addRule("vitest/prefer-expect-resolves", ERROR).addRule("vitest/prefer-hooks-in-order", ERROR).addRule("vitest/prefer-hooks-on-top", ERROR).addRule("vitest/prefer-lowercase-title", ERROR).addRule("vitest/prefer-mock-promise-shorthand", ERROR).addRule("vitest/prefer-spy-on", ERROR).addRule("vitest/prefer-strict-equal", WARNING).addRule("vitest/prefer-to-be", ERROR).addRule("vitest/prefer-to-be-falsy", ERROR).addRule("vitest/prefer-to-be-object", ERROR).addRule("vitest/prefer-to-be-truthy", ERROR).addRule("vitest/prefer-to-contain", ERROR).addRule("vitest/prefer-to-have-length", ERROR).addRule("vitest/prefer-todo", WARNING).addRule("vitest/require-hook", WARNING).addRule("vitest/require-to-throw-message", OFF).addRule("vitest/require-top-level-describe", OFF).addRule("vitest/valid-expect", ERROR, [
1545
+ {
1546
+ alwaysAwait: true,
1547
+ // Default: false
1548
+ ...asyncMatchers?.length && { asyncMatchers },
1549
+ ...minAndMaxExpectArgs?.[0] != null && minAndMaxExpectArgs[0] >= 0 && {
1550
+ minArgs: minAndMaxExpectArgs[0]
1551
+ },
1552
+ ...minAndMaxExpectArgs?.[1] != null && minAndMaxExpectArgs[1] >= 0 && {
1553
+ maxArgs: minAndMaxExpectArgs[1]
1554
+ }
1555
+ }
1556
+ ]).addRule("vitest/valid-expect-in-promise", ERROR);
1557
+ return builder.getAllConfigs();
1558
+ };
1559
+
1274
1560
  // src/configs/vue.ts
1275
1561
  init_cjs_shims();
1276
1562
  var import_eslint_plugin_pinia = __toESM(require("eslint-plugin-pinia"), 1);
@@ -1465,7 +1751,11 @@ var vueEslintConfig = (options, internalOptions = {}) => {
1465
1751
  ]).addRule("vue/prefer-define-options", isMin3_3 ? ERROR : OFF).addRule("vue/prefer-prop-type-boolean-first", ERROR).addRule("vue/prefer-separate-static-class", ERROR).addRule("vue/prefer-true-attribute-shorthand", ERROR).addRule(
1466
1752
  "vue/prefer-use-template-ref",
1467
1753
  options.preferUseTemplateRef ?? isMin3_5 ? ERROR : OFF
1468
- ).addRule("vue/require-default-export", ERROR).addRule("vue/require-direct-export", ERROR).addRule("vue/require-explicit-slots", isMin3_3 ? ERROR : OFF).addRule("vue/require-macro-variable-name", ERROR).addRule("vue/require-typed-object-prop", ERROR).addRule("vue/require-typed-ref", ERROR).addRule("vue/v-for-delimiter-style", ERROR, [
1754
+ ).addRule("vue/require-default-export", ERROR).addRule("vue/require-direct-export", ERROR).addRule("vue/require-explicit-slots", isMin3_3 ? ERROR : OFF).addRule("vue/require-macro-variable-name", ERROR).addRule("vue/require-typed-object-prop", ERROR).addRule("vue/require-typed-ref", ERROR).addRule(
1755
+ "vue/slot-name-casing",
1756
+ ERROR
1757
+ /* `camelCase` is default */
1758
+ ).addRule("vue/v-for-delimiter-style", ERROR, [
1469
1759
  "in"
1470
1760
  /* default */
1471
1761
  ]).addRule("vue/v-for-delimiter-style", isVue2 ? ERROR : OFF).addRule("vue/v-on-handler-style", ERROR, ["inline"]).addRule("vue/valid-define-options", isMin3_3 ? ERROR : OFF).addRule("vue/camelcase", ERROR, RULE_CAMELCASE_OPTIONS).addRule(
@@ -1518,29 +1808,32 @@ var vueEslintConfig = (options, internalOptions = {}) => {
1518
1808
  import_eslint_plugin_vuejs_accessibility.default.configs["flat/recommended"].find((v) => "rules" in v)?.rules
1519
1809
  ).addRule("vuejs-accessibility/label-has-for", ERROR, [{ allowChildren: true }]).addBulkRules(options.overridesA11y);
1520
1810
  }
1521
- const piniaBuilder = new ConfigEntryBuilder({}, internalOptions);
1522
- const piniaConfig = piniaBuilder.addConfig(
1523
- [
1524
- "pinia",
1525
- {
1526
- includeDefaultFilesAndIgnores: true,
1527
- ignoreMarkdownCodeBlocks: true
1528
- }
1529
- ],
1530
- {
1531
- plugins: {
1532
- // @ts-expect-error types mismatch
1533
- pinia: import_eslint_plugin_pinia.default
1534
- }
1535
- }
1811
+ const piniaBuilder = new ConfigEntryBuilder(
1812
+ typeof pinia === "object" ? pinia : {},
1813
+ internalOptions
1536
1814
  );
1537
1815
  if (pinia) {
1816
+ const piniaConfig = piniaBuilder.addConfig(
1817
+ [
1818
+ "pinia",
1819
+ {
1820
+ includeDefaultFilesAndIgnores: true,
1821
+ ignoreMarkdownCodeBlocks: true
1822
+ }
1823
+ ],
1824
+ {
1825
+ plugins: {
1826
+ // @ts-expect-error types mismatch
1827
+ pinia: import_eslint_plugin_pinia.default
1828
+ }
1829
+ }
1830
+ );
1538
1831
  piniaConfig.addBulkRules(import_eslint_plugin_pinia.default.configs["recommended-flat"].rules).addRule("pinia/prefer-single-store-per-file", ERROR).addRule("pinia/prefer-use-store-naming-convention", ERROR, [
1539
1832
  {
1540
1833
  checkStoreNameMismatch: true,
1541
1834
  storeSuffix: typeof pinia === "object" && pinia.storesNameSuffix != null ? pinia.storesNameSuffix : DEFAULT_PINIA_STORE_NAME_SUFFIX
1542
1835
  }
1543
- ]).addBulkRules(options.overridesPinia);
1836
+ ]);
1544
1837
  }
1545
1838
  return [...builder.getAllConfigs(), ...piniaBuilder.getAllConfigs()];
1546
1839
  };
@@ -1598,8 +1891,8 @@ var eslintConfig = (options = {}) => {
1598
1891
  ...options.ignores || []
1599
1892
  ];
1600
1893
  const configsOptions = options.configs || {};
1601
- const isVueEnabled = configsOptions.vue !== false && (Boolean(configsOptions.vue) || (0, import_local_pkg.isPackageExists)("vue"));
1602
- const typescriptPackageInfo = (0, import_local_pkg.getPackageInfoSync)("typescript");
1894
+ const isVueEnabled = configsOptions.vue !== false && (Boolean(configsOptions.vue) || (0, import_local_pkg2.isPackageExists)("vue"));
1895
+ const typescriptPackageInfo = (0, import_local_pkg2.getPackageInfoSync)("typescript");
1603
1896
  const isTypescriptEnabled = configsOptions.ts !== false && Boolean(configsOptions.ts || typescriptPackageInfo);
1604
1897
  const gitignoreConfig = typeof options.gitignore === "object" ? (0, import_eslint_config_flat_gitignore.default)(options.gitignore) : import_node_fs.default.existsSync(".gitignore") ? (0, import_eslint_config_flat_gitignore.default)() : null;
1605
1898
  const jsOptions = {
@@ -1610,19 +1903,21 @@ var eslintConfig = (options = {}) => {
1610
1903
  typescriptVersion: typescriptPackageInfo?.version,
1611
1904
  ...assignOptions(configsOptions, "ts")
1612
1905
  };
1613
- const vueFullVersion = (0, import_local_pkg.getPackageInfoSync)("vue")?.version;
1906
+ const vueFullVersion = (0, import_local_pkg2.getPackageInfoSync)("vue")?.version;
1614
1907
  const vueMajorVersionStr = vueFullVersion?.split(".")[0];
1615
1908
  const vueMajorVersion = vueMajorVersionStr === "2" ? 2 : vueMajorVersionStr === "3" ? 3 : void 0;
1616
- const nuxtMajorVersionStr = (0, import_local_pkg.getPackageInfoSync)("nuxt")?.version?.split(".")[0];
1909
+ const nuxtMajorVersionStr = (0, import_local_pkg2.getPackageInfoSync)("nuxt")?.version?.split(".")[0];
1617
1910
  const nuxtMajorVersion = nuxtMajorVersionStr === "3" ? 3 : void 0;
1618
1911
  const vueOptions = {
1619
1912
  majorVersion: vueMajorVersion ?? 3,
1620
1913
  fullVersion: vueFullVersion,
1621
1914
  nuxtMajorVersion,
1622
- pinia: (0, import_local_pkg.isPackageExists)("pinia"),
1915
+ pinia: (0, import_local_pkg2.isPackageExists)("pinia"),
1623
1916
  enforceTypescriptInScriptSection: isTypescriptEnabled,
1624
1917
  ...assignOptions(configsOptions, "vue")
1625
1918
  };
1919
+ const jestPackageInfo = (0, import_local_pkg2.getPackageInfoSync)("jest");
1920
+ const vitestPackageInfo = (0, import_local_pkg2.getPackageInfoSync)("vitest");
1626
1921
  const isUnicornEnabled = Boolean(configsOptions.unicorn ?? true);
1627
1922
  const unicornOptions = {
1628
1923
  ...assignOptions(configsOptions, "unicorn")
@@ -1644,7 +1939,7 @@ var eslintConfig = (options = {}) => {
1644
1939
  const sonarOptions = {
1645
1940
  ...assignOptions(configsOptions, "sonar")
1646
1941
  };
1647
- const isTailwindEnabled = configsOptions.tailwind === false ? false : configsOptions.tailwind ? true : (0, import_local_pkg.isPackageExists)("tailwindcss");
1942
+ const isTailwindEnabled = configsOptions.tailwind === false ? false : configsOptions.tailwind ? true : (0, import_local_pkg2.isPackageExists)("tailwindcss");
1648
1943
  const tailwindOptions = {
1649
1944
  ...assignOptions(configsOptions, "tailwind")
1650
1945
  };
@@ -1664,6 +1959,14 @@ var eslintConfig = (options = {}) => {
1664
1959
  const cssInJsOptions = {
1665
1960
  ...assignOptions(configsOptions, "cssInJs")
1666
1961
  };
1962
+ const isJestEnabled = Boolean(configsOptions.jest ?? jestPackageInfo != null);
1963
+ const jestOptions = {
1964
+ ...assignOptions(configsOptions, "jest")
1965
+ };
1966
+ const isVitestEnabled = Boolean(configsOptions.vitest ?? vitestPackageInfo != null);
1967
+ const vitestOptions = {
1968
+ ...assignOptions(configsOptions, "vitest")
1969
+ };
1667
1970
  const isSecurityEnabled = Boolean(configsOptions.security ?? false);
1668
1971
  const securityOptions = {
1669
1972
  ...assignOptions(configsOptions, "security")
@@ -1709,7 +2012,7 @@ var eslintConfig = (options = {}) => {
1709
2012
  "disable-autofix": import_eslint_plugin_disable_autofix.default,
1710
2013
  // Used in multiple configs and we can't define plugin multiple times
1711
2014
  unicorn: import_eslint_plugin_unicorn2.default,
1712
- "@stylistic": import_eslint_plugin.default
2015
+ "@stylistic": import_eslint_plugin2.default
1713
2016
  },
1714
2017
  languageOptions: {
1715
2018
  ecmaVersion: "latest",
@@ -1736,6 +2039,8 @@ var eslintConfig = (options = {}) => {
1736
2039
  isRegexpEnabled && regexpEslintConfig(regexpOptions, internalOptions),
1737
2040
  isEslintCommentsEnabled && eslintCommentsEslintConfig(eslintCommentsOptions, internalOptions),
1738
2041
  isCssInJsEnabled && cssInJsEslintConfig(cssInJsOptions, internalOptions),
2042
+ isJestEnabled && jestEslintConfig(jestOptions, internalOptions),
2043
+ isVitestEnabled && vitestEslintConfig(vitestOptions, internalOptions),
1739
2044
  isSecurityEnabled && securityEslintConfig(securityOptions, internalOptions),
1740
2045
  isPreferArrowFunctionsEnabled && preferArrowFunctionsEslintConfig(preferArrowFunctionsOptions, internalOptions),
1741
2046
  isYamlEnabled && yamlEslintConfig(yamlOptions, internalOptions),