@vitest/eslint-plugin 1.6.4 → 1.6.5

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.
Files changed (3) hide show
  1. package/dist/index.cjs +130 -102
  2. package/dist/index.js +130 -102
  3. package/package.json +8 -8
package/dist/index.cjs CHANGED
@@ -31,7 +31,7 @@ let __typescript_eslint_scope_manager = require("@typescript-eslint/scope-manage
31
31
  __typescript_eslint_scope_manager = __toESM(__typescript_eslint_scope_manager);
32
32
 
33
33
  //#region package.json
34
- var version = "1.6.4";
34
+ var version = "1.6.5";
35
35
 
36
36
  //#endregion
37
37
  //#region src/utils/index.ts
@@ -1596,8 +1596,7 @@ const parseVitestFnCallWithReason = (node, context) => {
1596
1596
  const determineVitestFnType = (name) => {
1597
1597
  if (name === "expect") return "expect";
1598
1598
  if (name === "expectTypeOf") return "expectTypeOf";
1599
- if (name === "vi") return "vi";
1600
- if (name === "vitest") return "vitest";
1599
+ if (name === "vi" || name === "vitest") return "vi";
1601
1600
  if (Object.prototype.hasOwnProperty.call(DescribeAlias, name)) return "describe";
1602
1601
  if (Object.prototype.hasOwnProperty.call(TestCaseName, name)) return "test";
1603
1602
  if (Object.prototype.hasOwnProperty.call(HookName, name)) return "hook";
@@ -1814,7 +1813,7 @@ const followTypeAssertionChain$1 = (expression) => isTypeCastExpression$1(expres
1814
1813
 
1815
1814
  //#endregion
1816
1815
  //#region src/rules/consistent-each-for.ts
1817
- const RULE_NAME$78 = "consistent-each-for";
1816
+ const RULE_NAME$79 = "consistent-each-for";
1818
1817
  const BASE_FN_NAMES = [
1819
1818
  "test",
1820
1819
  "it",
@@ -1822,7 +1821,7 @@ const BASE_FN_NAMES = [
1822
1821
  "suite"
1823
1822
  ];
1824
1823
  var consistent_each_for_default = createEslintRule({
1825
- name: RULE_NAME$78,
1824
+ name: RULE_NAME$79,
1826
1825
  meta: {
1827
1826
  type: "suggestion",
1828
1827
  docs: {
@@ -1882,11 +1881,11 @@ var consistent_each_for_default = createEslintRule({
1882
1881
 
1883
1882
  //#endregion
1884
1883
  //#region src/rules/consistent-test-filename.ts
1885
- const RULE_NAME$77 = "consistent-test-filename";
1884
+ const RULE_NAME$78 = "consistent-test-filename";
1886
1885
  const defaultPattern = /.*\.test\.[tj]sx?$/;
1887
1886
  const defaultTestsPattern = /.*\.(test|spec)\.[tj]sx?$/;
1888
1887
  var consistent_test_filename_default = createEslintRule({
1889
- name: RULE_NAME$77,
1888
+ name: RULE_NAME$78,
1890
1889
  meta: {
1891
1890
  type: "problem",
1892
1891
  docs: {
@@ -1934,7 +1933,7 @@ var consistent_test_filename_default = createEslintRule({
1934
1933
 
1935
1934
  //#endregion
1936
1935
  //#region src/rules/consistent-test-it.ts
1937
- const RULE_NAME$76 = "consistent-test-it";
1936
+ const RULE_NAME$77 = "consistent-test-it";
1938
1937
  const buildFixer = (callee, nodeName, preferredTestKeyword) => (fixer) => [fixer.replaceText(callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression ? callee.object : callee, getPreferredNodeName(nodeName, preferredTestKeyword))];
1939
1938
  function getPreferredNodeName(nodeName, preferredTestKeyword) {
1940
1939
  if (nodeName === TestCaseName.fit) return "test.only";
@@ -1945,7 +1944,7 @@ function getOppositeTestKeyword(test) {
1945
1944
  return TestCaseName.test;
1946
1945
  }
1947
1946
  var consistent_test_it_default = createEslintRule({
1948
- name: RULE_NAME$76,
1947
+ name: RULE_NAME$77,
1949
1948
  meta: {
1950
1949
  type: "suggestion",
1951
1950
  fixable: "code",
@@ -2054,10 +2053,10 @@ var consistent_test_it_default = createEslintRule({
2054
2053
 
2055
2054
  //#endregion
2056
2055
  //#region src/rules/consistent-vitest-vi.ts
2057
- const RULE_NAME$75 = "consistent-vitest-vi";
2056
+ const RULE_NAME$76 = "consistent-vitest-vi";
2058
2057
  const getOppositeVitestUtilKeyword = (util) => util === UtilName.vi ? UtilName.vitest : UtilName.vi;
2059
2058
  var consistent_vitest_vi_default = createEslintRule({
2060
- name: RULE_NAME$75,
2059
+ name: RULE_NAME$76,
2061
2060
  meta: {
2062
2061
  type: "suggestion",
2063
2062
  fixable: "code",
@@ -2108,7 +2107,9 @@ var consistent_vitest_vi_default = createEslintRule({
2108
2107
  }
2109
2108
  },
2110
2109
  CallExpression(node) {
2111
- if (parseVitestFnCall(node, context)?.type !== oppositeUtilKeyword) return;
2110
+ const vitestFnCall = parseVitestFnCall(node, context);
2111
+ if (vitestFnCall?.type !== "vi") return;
2112
+ if (!isSupportedAccessor(vitestFnCall.head.node, oppositeUtilKeyword)) return;
2112
2113
  const replaceNode = node.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression ? node.callee.object : node.callee;
2113
2114
  context.report({
2114
2115
  node: replaceNode,
@@ -2137,9 +2138,9 @@ function parsePluginSettings(settings) {
2137
2138
 
2138
2139
  //#endregion
2139
2140
  //#region src/rules/expect-expect.ts
2140
- const RULE_NAME$74 = "expect-expect";
2141
+ const RULE_NAME$75 = "expect-expect";
2141
2142
  var expect_expect_default = createEslintRule({
2142
- name: RULE_NAME$74,
2143
+ name: RULE_NAME$75,
2143
2144
  meta: {
2144
2145
  type: "suggestion",
2145
2146
  docs: {
@@ -2215,14 +2216,14 @@ function buildPatternRegexp(pattern) {
2215
2216
 
2216
2217
  //#endregion
2217
2218
  //#region src/rules/hoisted-apis-on-top.ts
2218
- const RULE_NAME$73 = "hoisted-apis-on-top";
2219
+ const RULE_NAME$74 = "hoisted-apis-on-top";
2219
2220
  const hoistedAPIs = [
2220
2221
  "mock",
2221
2222
  "hoisted",
2222
2223
  "unmock"
2223
2224
  ];
2224
2225
  var hoisted_apis_on_top_default = createEslintRule({
2225
- name: RULE_NAME$73,
2226
+ name: RULE_NAME$74,
2226
2227
  meta: {
2227
2228
  hasSuggestions: true,
2228
2229
  type: "suggestion",
@@ -2289,9 +2290,9 @@ var hoisted_apis_on_top_default = createEslintRule({
2289
2290
 
2290
2291
  //#endregion
2291
2292
  //#region src/rules/max-expects.ts
2292
- const RULE_NAME$72 = "max-expects";
2293
+ const RULE_NAME$73 = "max-expects";
2293
2294
  var max_expects_default = createEslintRule({
2294
- name: RULE_NAME$72,
2295
+ name: RULE_NAME$73,
2295
2296
  meta: {
2296
2297
  docs: {
2297
2298
  requiresTypeChecking: false,
@@ -2336,9 +2337,9 @@ var max_expects_default = createEslintRule({
2336
2337
 
2337
2338
  //#endregion
2338
2339
  //#region src/rules/max-nested-describe.ts
2339
- const RULE_NAME$71 = "max-nested-describe";
2340
+ const RULE_NAME$72 = "max-nested-describe";
2340
2341
  var max_nested_describe_default = createEslintRule({
2341
- name: RULE_NAME$71,
2342
+ name: RULE_NAME$72,
2342
2343
  meta: {
2343
2344
  type: "problem",
2344
2345
  docs: {
@@ -2380,9 +2381,9 @@ var max_nested_describe_default = createEslintRule({
2380
2381
 
2381
2382
  //#endregion
2382
2383
  //#region src/rules/no-alias-methods.ts
2383
- const RULE_NAME$70 = "no-alias-methods";
2384
+ const RULE_NAME$71 = "no-alias-methods";
2384
2385
  var no_alias_methods_default = createEslintRule({
2385
- name: RULE_NAME$70,
2386
+ name: RULE_NAME$71,
2386
2387
  meta: {
2387
2388
  docs: {
2388
2389
  description: "disallow alias methods",
@@ -2432,12 +2433,12 @@ var no_alias_methods_default = createEslintRule({
2432
2433
 
2433
2434
  //#endregion
2434
2435
  //#region src/rules/no-commented-out-tests.ts
2435
- const RULE_NAME$69 = "no-commented-out-tests";
2436
+ const RULE_NAME$70 = "no-commented-out-tests";
2436
2437
  function hasTests(node) {
2437
2438
  return /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu.test(node.value);
2438
2439
  }
2439
2440
  var no_commented_out_tests_default = createEslintRule({
2440
- name: RULE_NAME$69,
2441
+ name: RULE_NAME$70,
2441
2442
  meta: {
2442
2443
  docs: {
2443
2444
  description: "disallow commented out tests",
@@ -2466,10 +2467,10 @@ var no_commented_out_tests_default = createEslintRule({
2466
2467
 
2467
2468
  //#endregion
2468
2469
  //#region src/rules/no-conditional-expect.ts
2469
- const RULE_NAME$68 = "no-conditional-expect";
2470
+ const RULE_NAME$69 = "no-conditional-expect";
2470
2471
  const isCatchCall = (node) => node.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "catch");
2471
2472
  var no_conditional_expect_default = createEslintRule({
2472
- name: RULE_NAME$68,
2473
+ name: RULE_NAME$69,
2473
2474
  meta: {
2474
2475
  type: "problem",
2475
2476
  docs: {
@@ -2478,13 +2479,21 @@ var no_conditional_expect_default = createEslintRule({
2478
2479
  recommended: false
2479
2480
  },
2480
2481
  messages: { noConditionalExpect: "Avoid calling `expect` inside conditional statements" },
2481
- schema: []
2482
+ schema: [{
2483
+ type: "object",
2484
+ additionalProperties: false,
2485
+ properties: { expectAssertions: {
2486
+ description: "Enable/disable whether expect.assertions() is taken into account",
2487
+ type: "boolean"
2488
+ } }
2489
+ }]
2482
2490
  },
2483
- defaultOptions: [],
2484
- create(context) {
2491
+ defaultOptions: [{ expectAssertions: false }],
2492
+ create(context, [options]) {
2485
2493
  let conditionalDepth = 0;
2486
2494
  let inTestCase = false;
2487
2495
  let inPromiseCatch = false;
2496
+ let expectAssertions = 0;
2488
2497
  const increaseConditionalDepth = () => inTestCase && conditionalDepth++;
2489
2498
  const decreaseConditionalDepth = () => inTestCase && conditionalDepth--;
2490
2499
  return {
@@ -2495,7 +2504,19 @@ var no_conditional_expect_default = createEslintRule({
2495
2504
  const { type: vitestFnCallType } = parseVitestFnCall(node, context) ?? {};
2496
2505
  if (vitestFnCallType === "test") inTestCase = true;
2497
2506
  if (isCatchCall(node)) inPromiseCatch = true;
2498
- if (inTestCase && vitestFnCallType === "expect" && conditionalDepth > 0) context.report({
2507
+ if (options.expectAssertions && inTestCase) {
2508
+ if (node.callee.type === "MemberExpression") {
2509
+ if (node.callee.object.type === "Identifier" && node.callee.object.name === "expect") {
2510
+ if (node.callee.property.type === "Identifier" && node.callee.property.name === "assertions") {
2511
+ if (node.arguments.length === 1) {
2512
+ const assertions = node.arguments[0];
2513
+ if (assertions.type === "Literal") expectAssertions = Number(assertions.value);
2514
+ }
2515
+ }
2516
+ }
2517
+ }
2518
+ }
2519
+ if (inTestCase && vitestFnCallType === "expect" && conditionalDepth > 0 && expectAssertions === 0) context.report({
2499
2520
  messageId: "noConditionalExpect",
2500
2521
  node
2501
2522
  });
@@ -2505,7 +2526,10 @@ var no_conditional_expect_default = createEslintRule({
2505
2526
  });
2506
2527
  },
2507
2528
  "CallExpression:exit"(node) {
2508
- if (isTypeOfVitestFnCall(node, context, ["test"])) inTestCase = false;
2529
+ if (isTypeOfVitestFnCall(node, context, ["test"])) {
2530
+ inTestCase = false;
2531
+ expectAssertions = 0;
2532
+ }
2509
2533
  if (isCatchCall(node)) inPromiseCatch = false;
2510
2534
  },
2511
2535
  CatchClause: increaseConditionalDepth,
@@ -2524,9 +2548,9 @@ var no_conditional_expect_default = createEslintRule({
2524
2548
 
2525
2549
  //#endregion
2526
2550
  //#region src/rules/no-conditional-in-test.ts
2527
- const RULE_NAME$67 = "no-conditional-in-test";
2551
+ const RULE_NAME$68 = "no-conditional-in-test";
2528
2552
  var no_conditional_in_test_default = createEslintRule({
2529
- name: RULE_NAME$67,
2553
+ name: RULE_NAME$68,
2530
2554
  meta: {
2531
2555
  docs: {
2532
2556
  description: "disallow conditional tests",
@@ -2550,9 +2574,9 @@ var no_conditional_in_test_default = createEslintRule({
2550
2574
 
2551
2575
  //#endregion
2552
2576
  //#region src/rules/no-conditional-tests.ts
2553
- const RULE_NAME$66 = "no-conditional-tests";
2577
+ const RULE_NAME$67 = "no-conditional-tests";
2554
2578
  var no_conditional_tests_default = createEslintRule({
2555
- name: RULE_NAME$66,
2579
+ name: RULE_NAME$67,
2556
2580
  meta: {
2557
2581
  type: "problem",
2558
2582
  docs: {
@@ -2581,9 +2605,9 @@ var no_conditional_tests_default = createEslintRule({
2581
2605
 
2582
2606
  //#endregion
2583
2607
  //#region src/rules/no-disabled-tests.ts
2584
- const RULE_NAME$65 = "no-disabled-tests";
2608
+ const RULE_NAME$66 = "no-disabled-tests";
2585
2609
  var no_disabled_tests_default = createEslintRule({
2586
- name: RULE_NAME$65,
2610
+ name: RULE_NAME$66,
2587
2611
  meta: {
2588
2612
  type: "suggestion",
2589
2613
  docs: {
@@ -2649,7 +2673,7 @@ var no_disabled_tests_default = createEslintRule({
2649
2673
 
2650
2674
  //#endregion
2651
2675
  //#region src/rules/no-done-callback.ts
2652
- const RULE_NAME$64 = "no-done-callback";
2676
+ const RULE_NAME$65 = "no-done-callback";
2653
2677
  const findCallbackArg = (node, isVitestEach, context) => {
2654
2678
  if (isVitestEach) return node.arguments[1];
2655
2679
  const vitestFnCall = parseVitestFnCall(node, context);
@@ -2658,7 +2682,7 @@ const findCallbackArg = (node, isVitestEach, context) => {
2658
2682
  return null;
2659
2683
  };
2660
2684
  var no_done_callback_default = createEslintRule({
2661
- name: RULE_NAME$64,
2685
+ name: RULE_NAME$65,
2662
2686
  meta: {
2663
2687
  type: "suggestion",
2664
2688
  docs: {
@@ -2743,9 +2767,9 @@ var no_done_callback_default = createEslintRule({
2743
2767
 
2744
2768
  //#endregion
2745
2769
  //#region src/rules/no-duplicate-hooks.ts
2746
- const RULE_NAME$63 = "no-duplicate-hooks";
2770
+ const RULE_NAME$64 = "no-duplicate-hooks";
2747
2771
  var no_duplicate_hooks_default = createEslintRule({
2748
- name: RULE_NAME$63,
2772
+ name: RULE_NAME$64,
2749
2773
  meta: {
2750
2774
  docs: {
2751
2775
  recommended: false,
@@ -2782,7 +2806,7 @@ var no_duplicate_hooks_default = createEslintRule({
2782
2806
 
2783
2807
  //#endregion
2784
2808
  //#region src/rules/no-focused-tests.ts
2785
- const RULE_NAME$62 = "no-focused-tests";
2809
+ const RULE_NAME$63 = "no-focused-tests";
2786
2810
  const isTestOrDescribe = (node) => {
2787
2811
  return node.type === "Identifier" && [
2788
2812
  "it",
@@ -2794,7 +2818,7 @@ const isOnly = (node) => {
2794
2818
  return node.type === "Identifier" && node.name === "only";
2795
2819
  };
2796
2820
  var no_focused_tests_default = createEslintRule({
2797
- name: RULE_NAME$62,
2821
+ name: RULE_NAME$63,
2798
2822
  meta: {
2799
2823
  type: "problem",
2800
2824
  docs: {
@@ -2854,9 +2878,9 @@ var no_focused_tests_default = createEslintRule({
2854
2878
 
2855
2879
  //#endregion
2856
2880
  //#region src/rules/no-hooks.ts
2857
- const RULE_NAME$61 = "no-hooks";
2881
+ const RULE_NAME$62 = "no-hooks";
2858
2882
  var no_hooks_default = createEslintRule({
2859
- name: RULE_NAME$61,
2883
+ name: RULE_NAME$62,
2860
2884
  meta: {
2861
2885
  type: "suggestion",
2862
2886
  docs: {
@@ -2899,13 +2923,13 @@ var no_hooks_default = createEslintRule({
2899
2923
 
2900
2924
  //#endregion
2901
2925
  //#region src/rules/no-identical-title.ts
2902
- const RULE_NAME$60 = "no-identical-title";
2926
+ const RULE_NAME$61 = "no-identical-title";
2903
2927
  const newDescribeContext = () => ({
2904
2928
  describeTitles: [],
2905
2929
  testTitles: []
2906
2930
  });
2907
2931
  var no_identical_title_default = createEslintRule({
2908
- name: RULE_NAME$60,
2932
+ name: RULE_NAME$61,
2909
2933
  meta: {
2910
2934
  type: "problem",
2911
2935
  docs: {
@@ -2955,9 +2979,9 @@ var no_identical_title_default = createEslintRule({
2955
2979
 
2956
2980
  //#endregion
2957
2981
  //#region src/rules/no-import-node-test.ts
2958
- const RULE_NAME$59 = "no-import-node-test";
2982
+ const RULE_NAME$60 = "no-import-node-test";
2959
2983
  var no_import_node_test_default = createEslintRule({
2960
- name: RULE_NAME$59,
2984
+ name: RULE_NAME$60,
2961
2985
  meta: {
2962
2986
  docs: {
2963
2987
  description: "disallow importing `node:test`",
@@ -3054,9 +3078,9 @@ const removeNodeFromArray = (fixer, nodes, target) => {
3054
3078
 
3055
3079
  //#endregion
3056
3080
  //#region src/rules/no-importing-vitest-globals.ts
3057
- const RULE_NAME$58 = "no-importing-vitest-globals";
3081
+ const RULE_NAME$59 = "no-importing-vitest-globals";
3058
3082
  var no_importing_vitest_globals_default = createEslintRule({
3059
- name: RULE_NAME$58,
3083
+ name: RULE_NAME$59,
3060
3084
  meta: {
3061
3085
  type: "suggestion",
3062
3086
  docs: {
@@ -3112,9 +3136,9 @@ var no_importing_vitest_globals_default = createEslintRule({
3112
3136
 
3113
3137
  //#endregion
3114
3138
  //#region src/rules/no-interpolation-in-snapshots.ts
3115
- const RULE_NAME$57 = "no-interpolation-in-snapshots";
3139
+ const RULE_NAME$58 = "no-interpolation-in-snapshots";
3116
3140
  var no_interpolation_in_snapshots_default = createEslintRule({
3117
- name: RULE_NAME$57,
3141
+ name: RULE_NAME$58,
3118
3142
  meta: {
3119
3143
  type: "problem",
3120
3144
  docs: {
@@ -3142,7 +3166,7 @@ var no_interpolation_in_snapshots_default = createEslintRule({
3142
3166
 
3143
3167
  //#endregion
3144
3168
  //#region src/rules/no-large-snapshots.ts
3145
- const RULE_NAME$56 = "no-large-snapshots";
3169
+ const RULE_NAME$57 = "no-large-snapshots";
3146
3170
  const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnapshots = {} }) => {
3147
3171
  const startLine = node.loc.start.line;
3148
3172
  const lineCount = node.loc.end.line - startLine;
@@ -3168,7 +3192,7 @@ const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnap
3168
3192
  });
3169
3193
  };
3170
3194
  var no_large_snapshots_default = createEslintRule({
3171
- name: RULE_NAME$56,
3195
+ name: RULE_NAME$57,
3172
3196
  meta: {
3173
3197
  docs: {
3174
3198
  description: "disallow large snapshots",
@@ -3213,9 +3237,9 @@ var no_large_snapshots_default = createEslintRule({
3213
3237
  const mocksDirName = "__mocks__";
3214
3238
  const isMockPath = (path) => path.split(node_path.posix.sep).includes(mocksDirName);
3215
3239
  const isMockImportLiteral = (expression) => isStringNode(expression) && isMockPath(getStringValue(expression));
3216
- const RULE_NAME$55 = "no-mocks-import";
3240
+ const RULE_NAME$56 = "no-mocks-import";
3217
3241
  var no_mocks_import_default = createEslintRule({
3218
- name: RULE_NAME$55,
3242
+ name: RULE_NAME$56,
3219
3243
  meta: {
3220
3244
  type: "problem",
3221
3245
  docs: {
@@ -3247,13 +3271,13 @@ var no_mocks_import_default = createEslintRule({
3247
3271
 
3248
3272
  //#endregion
3249
3273
  //#region src/rules/no-restricted-matchers.ts
3250
- const RULE_NAME$54 = "no-restricted-matchers";
3274
+ const RULE_NAME$55 = "no-restricted-matchers";
3251
3275
  const isChainRestricted = (chain, restriction) => {
3252
3276
  if (Object.prototype.hasOwnProperty.call(ModifierName, restriction) || restriction.endsWith(".not")) return chain.startsWith(restriction);
3253
3277
  return chain === restriction;
3254
3278
  };
3255
3279
  var no_restricted_matchers_default = createEslintRule({
3256
- name: RULE_NAME$54,
3280
+ name: RULE_NAME$55,
3257
3281
  meta: {
3258
3282
  docs: {
3259
3283
  description: "disallow the use of certain matchers",
@@ -3295,9 +3319,9 @@ var no_restricted_matchers_default = createEslintRule({
3295
3319
 
3296
3320
  //#endregion
3297
3321
  //#region src/rules/no-restricted-vi-methods.ts
3298
- const RULE_NAME$53 = "no-restricted-vi-methods";
3322
+ const RULE_NAME$54 = "no-restricted-vi-methods";
3299
3323
  var no_restricted_vi_methods_default = createEslintRule({
3300
- name: RULE_NAME$53,
3324
+ name: RULE_NAME$54,
3301
3325
  meta: {
3302
3326
  type: "suggestion",
3303
3327
  docs: {
@@ -3339,7 +3363,7 @@ var no_restricted_vi_methods_default = createEslintRule({
3339
3363
 
3340
3364
  //#endregion
3341
3365
  //#region src/rules/no-standalone-expect.ts
3342
- const RULE_NAME$52 = "no-standalone-expect";
3366
+ const RULE_NAME$53 = "no-standalone-expect";
3343
3367
  const getBlockType = (statement, context) => {
3344
3368
  const func = statement.parent;
3345
3369
  if (!func) throw new Error("Unexpected block statement. If you feel like this is a bug report https://github.com/veritem/eslint-plugin-vitest/issues/new");
@@ -3352,7 +3376,7 @@ const getBlockType = (statement, context) => {
3352
3376
  return null;
3353
3377
  };
3354
3378
  var no_standalone_expect_default = createEslintRule({
3355
- name: RULE_NAME$52,
3379
+ name: RULE_NAME$53,
3356
3380
  meta: {
3357
3381
  docs: {
3358
3382
  description: "disallow using `expect` outside of `it` or `test` blocks",
@@ -3411,9 +3435,9 @@ var no_standalone_expect_default = createEslintRule({
3411
3435
 
3412
3436
  //#endregion
3413
3437
  //#region src/rules/no-test-prefixes.ts
3414
- const RULE_NAME$51 = "no-test-prefixes";
3438
+ const RULE_NAME$52 = "no-test-prefixes";
3415
3439
  var no_test_prefixes_default = createEslintRule({
3416
- name: RULE_NAME$51,
3440
+ name: RULE_NAME$52,
3417
3441
  meta: {
3418
3442
  docs: {
3419
3443
  description: "disallow using the `f` and `x` prefixes in favour of `.only` and `.skip`",
@@ -3448,14 +3472,14 @@ var no_test_prefixes_default = createEslintRule({
3448
3472
 
3449
3473
  //#endregion
3450
3474
  //#region src/rules/no-test-return-statement.ts
3451
- const RULE_NAME$50 = "no-test-return-statement";
3475
+ const RULE_NAME$51 = "no-test-return-statement";
3452
3476
  const getBody = (args) => {
3453
3477
  const [, secondArg] = args;
3454
3478
  if (secondArg && isFunction(secondArg) && secondArg.body.type === __typescript_eslint_utils.AST_NODE_TYPES.BlockStatement) return secondArg.body.body;
3455
3479
  return [];
3456
3480
  };
3457
3481
  var no_test_return_statement_default = createEslintRule({
3458
- name: RULE_NAME$50,
3482
+ name: RULE_NAME$51,
3459
3483
  meta: {
3460
3484
  type: "problem",
3461
3485
  docs: {
@@ -3726,7 +3750,7 @@ const createPaddingRule = (name, description, configs, deprecated = false) => {
3726
3750
 
3727
3751
  //#endregion
3728
3752
  //#region src/rules/padding-around-after-all-blocks.ts
3729
- const RULE_NAME$49 = "padding-around-after-all-blocks";
3753
+ const RULE_NAME$50 = "padding-around-after-all-blocks";
3730
3754
  const config = [{
3731
3755
  paddingType: PaddingType.Always,
3732
3756
  prevStatementType: StatementType.Any,
@@ -3736,11 +3760,11 @@ const config = [{
3736
3760
  prevStatementType: StatementType.AfterAllToken,
3737
3761
  nextStatementType: StatementType.Any
3738
3762
  }];
3739
- var padding_around_after_all_blocks_default = createPaddingRule(RULE_NAME$49, "Enforce padding around `afterAll` blocks", config);
3763
+ var padding_around_after_all_blocks_default = createPaddingRule(RULE_NAME$50, "Enforce padding around `afterAll` blocks", config);
3740
3764
 
3741
3765
  //#endregion
3742
3766
  //#region src/rules/padding-around-after-each-blocks.ts
3743
- const RULE_NAME$48 = "padding-around-after-each-blocks";
3767
+ const RULE_NAME$49 = "padding-around-after-each-blocks";
3744
3768
  const config$1 = [{
3745
3769
  paddingType: PaddingType.Always,
3746
3770
  prevStatementType: StatementType.Any,
@@ -3750,11 +3774,11 @@ const config$1 = [{
3750
3774
  prevStatementType: StatementType.AfterEachToken,
3751
3775
  nextStatementType: StatementType.Any
3752
3776
  }];
3753
- var padding_around_after_each_blocks_default = createPaddingRule(RULE_NAME$48, "Enforce padding around `afterEach` blocks", config$1);
3777
+ var padding_around_after_each_blocks_default = createPaddingRule(RULE_NAME$49, "Enforce padding around `afterEach` blocks", config$1);
3754
3778
 
3755
3779
  //#endregion
3756
3780
  //#region src/rules/padding-around-before-all-blocks.ts
3757
- const RULE_NAME$47 = "padding-around-before-all-blocks";
3781
+ const RULE_NAME$48 = "padding-around-before-all-blocks";
3758
3782
  const config$2 = [{
3759
3783
  paddingType: PaddingType.Always,
3760
3784
  prevStatementType: StatementType.Any,
@@ -3764,11 +3788,11 @@ const config$2 = [{
3764
3788
  prevStatementType: StatementType.BeforeAllToken,
3765
3789
  nextStatementType: StatementType.Any
3766
3790
  }];
3767
- var padding_around_before_all_blocks_default = createPaddingRule(RULE_NAME$47, "Enforce padding around `beforeAll` blocks", config$2);
3791
+ var padding_around_before_all_blocks_default = createPaddingRule(RULE_NAME$48, "Enforce padding around `beforeAll` blocks", config$2);
3768
3792
 
3769
3793
  //#endregion
3770
3794
  //#region src/rules/padding-around-before-each-blocks.ts
3771
- const RULE_NAME$46 = "padding-around-before-each-blocks";
3795
+ const RULE_NAME$47 = "padding-around-before-each-blocks";
3772
3796
  const config$3 = [{
3773
3797
  paddingType: PaddingType.Always,
3774
3798
  prevStatementType: StatementType.Any,
@@ -3778,11 +3802,11 @@ const config$3 = [{
3778
3802
  prevStatementType: StatementType.BeforeEachToken,
3779
3803
  nextStatementType: StatementType.Any
3780
3804
  }];
3781
- var padding_around_before_each_blocks_default = createPaddingRule(RULE_NAME$46, "Enforce padding around `beforeEach` blocks", config$3);
3805
+ var padding_around_before_each_blocks_default = createPaddingRule(RULE_NAME$47, "Enforce padding around `beforeEach` blocks", config$3);
3782
3806
 
3783
3807
  //#endregion
3784
3808
  //#region src/rules/padding-around-describe-blocks.ts
3785
- const RULE_NAME$45 = "padding-around-describe-blocks";
3809
+ const RULE_NAME$46 = "padding-around-describe-blocks";
3786
3810
  const config$4 = [{
3787
3811
  paddingType: PaddingType.Always,
3788
3812
  prevStatementType: StatementType.Any,
@@ -3800,11 +3824,11 @@ const config$4 = [{
3800
3824
  ],
3801
3825
  nextStatementType: StatementType.Any
3802
3826
  }];
3803
- var padding_around_describe_blocks_default = createPaddingRule(RULE_NAME$45, "Enforce padding around `describe` blocks", config$4);
3827
+ var padding_around_describe_blocks_default = createPaddingRule(RULE_NAME$46, "Enforce padding around `describe` blocks", config$4);
3804
3828
 
3805
3829
  //#endregion
3806
3830
  //#region src/rules/padding-around-expect-groups.ts
3807
- const RULE_NAME$44 = "padding-around-expect-groups";
3831
+ const RULE_NAME$45 = "padding-around-expect-groups";
3808
3832
  const config$5 = [
3809
3833
  {
3810
3834
  paddingType: PaddingType.Always,
@@ -3837,11 +3861,11 @@ const config$5 = [
3837
3861
  nextStatementType: StatementType.ExpectTypeOfToken
3838
3862
  }
3839
3863
  ];
3840
- var padding_around_expect_groups_default = createPaddingRule(RULE_NAME$44, "Enforce padding around `expect` groups", config$5);
3864
+ var padding_around_expect_groups_default = createPaddingRule(RULE_NAME$45, "Enforce padding around `expect` groups", config$5);
3841
3865
 
3842
3866
  //#endregion
3843
3867
  //#region src/rules/padding-around-test-blocks.ts
3844
- const RULE_NAME$43 = "padding-around-test-blocks";
3868
+ const RULE_NAME$44 = "padding-around-test-blocks";
3845
3869
  const config$6 = [{
3846
3870
  paddingType: PaddingType.Always,
3847
3871
  prevStatementType: StatementType.Any,
@@ -3863,12 +3887,12 @@ const config$6 = [{
3863
3887
  ],
3864
3888
  nextStatementType: StatementType.Any
3865
3889
  }];
3866
- var padding_around_test_blocks_default = createPaddingRule(RULE_NAME$43, "Enforce padding around `test` blocks", config$6);
3890
+ var padding_around_test_blocks_default = createPaddingRule(RULE_NAME$44, "Enforce padding around `test` blocks", config$6);
3867
3891
 
3868
3892
  //#endregion
3869
3893
  //#region src/rules/padding-around-all.ts
3870
- const RULE_NAME$42 = "padding-around-all";
3871
- var padding_around_all_default = createPaddingRule(RULE_NAME$42, "Enforce padding around vitest functions", [
3894
+ const RULE_NAME$43 = "padding-around-all";
3895
+ var padding_around_all_default = createPaddingRule(RULE_NAME$43, "Enforce padding around vitest functions", [
3872
3896
  ...config,
3873
3897
  ...config$1,
3874
3898
  ...config$2,
@@ -3880,7 +3904,7 @@ var padding_around_all_default = createPaddingRule(RULE_NAME$42, "Enforce paddin
3880
3904
 
3881
3905
  //#endregion
3882
3906
  //#region src/rules/prefer-called-exactly-once-with.ts
3883
- const RULE_NAME$41 = "prefer-called-exactly-once-with";
3907
+ const RULE_NAME$42 = "prefer-called-exactly-once-with";
3884
3908
  const MATCHERS_TO_COMBINE = ["toHaveBeenCalledOnce", "toHaveBeenCalledWith"];
3885
3909
  const MOCK_CALL_RESET_METHODS = [
3886
3910
  "mockClear",
@@ -3939,7 +3963,7 @@ const hasMockResetBetween = (body, firstCallExpression, secondCallExpression) =>
3939
3963
  };
3940
3964
  const getMemberProperty = (expression) => expression.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression ? expression.callee.property : null;
3941
3965
  var prefer_called_exactly_once_with_default = createEslintRule({
3942
- name: RULE_NAME$41,
3966
+ name: RULE_NAME$42,
3943
3967
  meta: {
3944
3968
  docs: { description: "Prefer `toHaveBeenCalledExactlyOnceWith` over `toHaveBeenCalledOnce` and `toHaveBeenCalledWith`" },
3945
3969
  messages: { preferCalledExactlyOnceWith: "Using `toHaveBeenCalledOnce` and `toHaveBeenCalledWith` on the same target; prefer `toHaveBeenCalledExactlyOnceWith` instead." },
@@ -4007,10 +4031,10 @@ var prefer_called_exactly_once_with_default = createEslintRule({
4007
4031
 
4008
4032
  //#endregion
4009
4033
  //#region src/rules/prefer-called-once.ts
4010
- const RULE_NAME$40 = "prefer-called-once";
4034
+ const RULE_NAME$41 = "prefer-called-once";
4011
4035
  const isOneLiteral = (node) => node.type === __typescript_eslint_utils.AST_NODE_TYPES.Literal && node.value === 1;
4012
4036
  var prefer_called_once_default = createEslintRule({
4013
- name: RULE_NAME$40,
4037
+ name: RULE_NAME$41,
4014
4038
  meta: {
4015
4039
  docs: {
4016
4040
  description: "enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()`",
@@ -4043,9 +4067,9 @@ var prefer_called_once_default = createEslintRule({
4043
4067
 
4044
4068
  //#endregion
4045
4069
  //#region src/rules/prefer-called-times.ts
4046
- const RULE_NAME$39 = "prefer-called-times";
4070
+ const RULE_NAME$40 = "prefer-called-times";
4047
4071
  var prefer_called_times_default = createEslintRule({
4048
- name: RULE_NAME$39,
4072
+ name: RULE_NAME$40,
4049
4073
  meta: {
4050
4074
  docs: {
4051
4075
  description: "enforce using `toBeCalledTimes(1)` or `toHaveBeenCalledTimes(1)`",
@@ -4078,9 +4102,9 @@ var prefer_called_times_default = createEslintRule({
4078
4102
 
4079
4103
  //#endregion
4080
4104
  //#region src/rules/prefer-called-with.ts
4081
- const RULE_NAME$38 = "prefer-called-with";
4105
+ const RULE_NAME$39 = "prefer-called-with";
4082
4106
  var prefer_called_with_default = createEslintRule({
4083
- name: RULE_NAME$38,
4107
+ name: RULE_NAME$39,
4084
4108
  meta: {
4085
4109
  docs: {
4086
4110
  description: "enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`",
@@ -4128,7 +4152,7 @@ const hasOnlyOneArgument = (call) => call.arguments.length === 1;
4128
4152
 
4129
4153
  //#endregion
4130
4154
  //#region src/rules/prefer-comparison-matcher.ts
4131
- const RULE_NAME$37 = "prefer-comparison-matcher";
4155
+ const RULE_NAME$38 = "prefer-comparison-matcher";
4132
4156
  const isString = (node) => {
4133
4157
  return isStringNode(node) || node?.type === __typescript_eslint_utils.AST_NODE_TYPES.TemplateLiteral;
4134
4158
  };
@@ -4154,7 +4178,7 @@ const determineMatcher = (operator, negated) => {
4154
4178
  return null;
4155
4179
  };
4156
4180
  var prefer_comparison_matcher_default = createEslintRule({
4157
- name: RULE_NAME$37,
4181
+ name: RULE_NAME$38,
4158
4182
  meta: {
4159
4183
  type: "suggestion",
4160
4184
  docs: {
@@ -4200,9 +4224,9 @@ var prefer_comparison_matcher_default = createEslintRule({
4200
4224
 
4201
4225
  //#endregion
4202
4226
  //#region src/rules/prefer-describe-function-title.ts
4203
- const RULE_NAME$36 = "prefer-describe-function-title";
4227
+ const RULE_NAME$37 = "prefer-describe-function-title";
4204
4228
  var prefer_describe_function_title_default = createEslintRule({
4205
- name: RULE_NAME$36,
4229
+ name: RULE_NAME$37,
4206
4230
  meta: {
4207
4231
  type: "problem",
4208
4232
  docs: {
@@ -4252,9 +4276,9 @@ var prefer_describe_function_title_default = createEslintRule({
4252
4276
 
4253
4277
  //#endregion
4254
4278
  //#region src/rules/prefer-each.ts
4255
- const RULE_NAME$35 = "prefer-each";
4279
+ const RULE_NAME$36 = "prefer-each";
4256
4280
  var prefer_each_default = createEslintRule({
4257
- name: RULE_NAME$35,
4281
+ name: RULE_NAME$36,
4258
4282
  meta: {
4259
4283
  type: "suggestion",
4260
4284
  docs: {
@@ -4307,9 +4331,9 @@ var prefer_each_default = createEslintRule({
4307
4331
 
4308
4332
  //#endregion
4309
4333
  //#region src/rules/prefer-equality-matcher.ts
4310
- const RULE_NAME$34 = "prefer-equality-matcher";
4334
+ const RULE_NAME$35 = "prefer-equality-matcher";
4311
4335
  var prefer_equality_matcher_default = createEslintRule({
4312
- name: RULE_NAME$34,
4336
+ name: RULE_NAME$35,
4313
4337
  meta: {
4314
4338
  type: "suggestion",
4315
4339
  docs: {
@@ -4367,6 +4391,7 @@ var prefer_equality_matcher_default = createEslintRule({
4367
4391
 
4368
4392
  //#endregion
4369
4393
  //#region src/rules/prefer-expect-assertions.ts
4394
+ const RULE_NAME$34 = "prefer-expect-assertions";
4370
4395
  const isFirstStatement = (node) => {
4371
4396
  let parent = node;
4372
4397
  while (parent) {
@@ -4381,7 +4406,7 @@ const suggestRemovingExtraArguments = (context, func, from) => ({
4381
4406
  fix: (fixer) => removeExtraArgumentsFixer(fixer, context, func, from)
4382
4407
  });
4383
4408
  var prefer_expect_assertions_default = createEslintRule({
4384
- name: "prefer-expect-assertions",
4409
+ name: RULE_NAME$34,
4385
4410
  meta: {
4386
4411
  docs: {
4387
4412
  description: "enforce using expect assertions instead of callbacks",
@@ -5018,10 +5043,13 @@ var prefer_mock_return_shorthand_default = createEslintRule({
5018
5043
  const isOnce = mockFnName.endsWith("Once");
5019
5044
  if (mockFnName !== withOnce("mockImplementation", isOnce)) return;
5020
5045
  const [arg] = node.arguments;
5021
- if (!isFunction(arg) || arg.params.length !== 0) return;
5046
+ if (!isFunction(arg) || arg.params.length !== 0 || arg.async) return;
5022
5047
  const replacement = withOnce("mockReturnValue", isOnce);
5023
5048
  const returnNode = findSingleReturnArgumentNode(arg);
5024
- if (!returnNode) return;
5049
+ if (!returnNode || returnNode.type === __typescript_eslint_utils.AST_NODE_TYPES.UpdateExpression) return;
5050
+ if (returnNode.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier) {
5051
+ if (context.sourceCode.getScope(returnNode).through.some((v) => v.resolved?.defs.some((n) => n.type === "Variable" && n.parent.kind !== "const"))) return;
5052
+ }
5025
5053
  context.report({
5026
5054
  node: property,
5027
5055
  messageId: "useMockShorthand",