@vitest/eslint-plugin 1.6.11 → 1.6.13

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.mjs CHANGED
@@ -4,7 +4,7 @@ import { isAbsolute, posix } from "node:path";
4
4
  import { DefinitionType } from "@typescript-eslint/scope-manager";
5
5
 
6
6
  //#region package.json
7
- var version = "1.6.11";
7
+ var version = "1.6.13";
8
8
 
9
9
  //#endregion
10
10
  //#region src/utils/index.ts
@@ -82,10 +82,6 @@ const isParsedInstanceOfMatcherCall = (expectFnCall, classArg) => {
82
82
  return getAccessorValue(expectFnCall.matcher) === "toBeInstanceOf" && expectFnCall.args.length === 1 && isSupportedAccessor(expectFnCall.args[0], classArg);
83
83
  };
84
84
 
85
- //#endregion
86
- //#region src/utils/require.ts
87
- const require = createRequire(import.meta.url);
88
-
89
85
  //#endregion
90
86
  //#region src/utils/types.ts
91
87
  let UtilName = /* @__PURE__ */ function(UtilName) {
@@ -139,9 +135,7 @@ let EqualityMatcher = /* @__PURE__ */ function(EqualityMatcher) {
139
135
  return EqualityMatcher;
140
136
  }({});
141
137
  function isClassOrFunctionType(type) {
142
- if (type.getCallSignatures().length > 0) return true;
143
- const ts = require("typescript");
144
- return type.getSymbol()?.getDeclarations()?.some((declaration) => ts.isArrowFunction(declaration) || ts.isClassDeclaration(declaration) || ts.isClassExpression(declaration) || ts.isFunctionDeclaration(declaration) || ts.isFunctionExpression(declaration) || ts.isMethodDeclaration(declaration) || ts.isFunctionTypeNode(declaration)) ?? false;
138
+ return type.getCallSignatures().length > 0 || type.getConstructSignatures().length > 0;
145
139
  }
146
140
 
147
141
  //#endregion
@@ -1786,7 +1780,7 @@ const followTypeAssertionChain$1 = (expression) => isTypeCastExpression$1(expres
1786
1780
 
1787
1781
  //#endregion
1788
1782
  //#region src/rules/consistent-each-for.ts
1789
- const RULE_NAME$80 = "consistent-each-for";
1783
+ const RULE_NAME$81 = "consistent-each-for";
1790
1784
  const BASE_FN_NAMES = [
1791
1785
  "test",
1792
1786
  "it",
@@ -1794,7 +1788,7 @@ const BASE_FN_NAMES = [
1794
1788
  "suite"
1795
1789
  ];
1796
1790
  var consistent_each_for_default = createEslintRule({
1797
- name: RULE_NAME$80,
1791
+ name: RULE_NAME$81,
1798
1792
  meta: {
1799
1793
  type: "suggestion",
1800
1794
  docs: {
@@ -1857,11 +1851,11 @@ var consistent_each_for_default = createEslintRule({
1857
1851
 
1858
1852
  //#endregion
1859
1853
  //#region src/rules/consistent-test-filename.ts
1860
- const RULE_NAME$79 = "consistent-test-filename";
1854
+ const RULE_NAME$80 = "consistent-test-filename";
1861
1855
  const defaultPattern = /.*\.test\.[tj]sx?$/;
1862
1856
  const defaultTestsPattern = /.*\.(test|spec)\.[tj]sx?$/;
1863
1857
  var consistent_test_filename_default = createEslintRule({
1864
- name: RULE_NAME$79,
1858
+ name: RULE_NAME$80,
1865
1859
  meta: {
1866
1860
  type: "problem",
1867
1861
  docs: {
@@ -1909,7 +1903,7 @@ var consistent_test_filename_default = createEslintRule({
1909
1903
 
1910
1904
  //#endregion
1911
1905
  //#region src/rules/consistent-test-it.ts
1912
- const RULE_NAME$78 = "consistent-test-it";
1906
+ const RULE_NAME$79 = "consistent-test-it";
1913
1907
  const buildFixer = (callee, nodeName, preferredTestKeyword) => (fixer) => [fixer.replaceText(callee.type === AST_NODE_TYPES.MemberExpression ? callee.object : callee, getPreferredNodeName(nodeName, preferredTestKeyword))];
1914
1908
  function getPreferredNodeName(nodeName, preferredTestKeyword) {
1915
1909
  if (nodeName === TestCaseName.fit) return "test.only";
@@ -1920,7 +1914,7 @@ function getOppositeTestKeyword(test) {
1920
1914
  return TestCaseName.test;
1921
1915
  }
1922
1916
  var consistent_test_it_default = createEslintRule({
1923
- name: RULE_NAME$78,
1917
+ name: RULE_NAME$79,
1924
1918
  meta: {
1925
1919
  type: "suggestion",
1926
1920
  fixable: "code",
@@ -2031,10 +2025,10 @@ var consistent_test_it_default = createEslintRule({
2031
2025
 
2032
2026
  //#endregion
2033
2027
  //#region src/rules/consistent-vitest-vi.ts
2034
- const RULE_NAME$77 = "consistent-vitest-vi";
2028
+ const RULE_NAME$78 = "consistent-vitest-vi";
2035
2029
  const getOppositeVitestUtilKeyword = (util) => util === UtilName.vi ? UtilName.vitest : UtilName.vi;
2036
2030
  var consistent_vitest_vi_default = createEslintRule({
2037
- name: RULE_NAME$77,
2031
+ name: RULE_NAME$78,
2038
2032
  meta: {
2039
2033
  type: "suggestion",
2040
2034
  fixable: "code",
@@ -2116,9 +2110,9 @@ function parsePluginSettings(settings) {
2116
2110
 
2117
2111
  //#endregion
2118
2112
  //#region src/rules/expect-expect.ts
2119
- const RULE_NAME$76 = "expect-expect";
2113
+ const RULE_NAME$77 = "expect-expect";
2120
2114
  var expect_expect_default = createEslintRule({
2121
- name: RULE_NAME$76,
2115
+ name: RULE_NAME$77,
2122
2116
  meta: {
2123
2117
  type: "suggestion",
2124
2118
  docs: {
@@ -2196,14 +2190,14 @@ function buildPatternRegexp(pattern) {
2196
2190
 
2197
2191
  //#endregion
2198
2192
  //#region src/rules/hoisted-apis-on-top.ts
2199
- const RULE_NAME$75 = "hoisted-apis-on-top";
2193
+ const RULE_NAME$76 = "hoisted-apis-on-top";
2200
2194
  const hoistedAPIs = [
2201
2195
  "mock",
2202
2196
  "hoisted",
2203
2197
  "unmock"
2204
2198
  ];
2205
2199
  var hoisted_apis_on_top_default = createEslintRule({
2206
- name: RULE_NAME$75,
2200
+ name: RULE_NAME$76,
2207
2201
  meta: {
2208
2202
  hasSuggestions: true,
2209
2203
  type: "suggestion",
@@ -2269,9 +2263,9 @@ var hoisted_apis_on_top_default = createEslintRule({
2269
2263
 
2270
2264
  //#endregion
2271
2265
  //#region src/rules/max-expects.ts
2272
- const RULE_NAME$74 = "max-expects";
2266
+ const RULE_NAME$75 = "max-expects";
2273
2267
  var max_expects_default = createEslintRule({
2274
- name: RULE_NAME$74,
2268
+ name: RULE_NAME$75,
2275
2269
  meta: {
2276
2270
  docs: {
2277
2271
  requiresTypeChecking: false,
@@ -2319,9 +2313,9 @@ var max_expects_default = createEslintRule({
2319
2313
 
2320
2314
  //#endregion
2321
2315
  //#region src/rules/max-nested-describe.ts
2322
- const RULE_NAME$73 = "max-nested-describe";
2316
+ const RULE_NAME$74 = "max-nested-describe";
2323
2317
  var max_nested_describe_default = createEslintRule({
2324
- name: RULE_NAME$73,
2318
+ name: RULE_NAME$74,
2325
2319
  meta: {
2326
2320
  type: "problem",
2327
2321
  docs: {
@@ -2366,9 +2360,9 @@ var max_nested_describe_default = createEslintRule({
2366
2360
 
2367
2361
  //#endregion
2368
2362
  //#region src/rules/no-alias-methods.ts
2369
- const RULE_NAME$72 = "no-alias-methods";
2363
+ const RULE_NAME$73 = "no-alias-methods";
2370
2364
  var no_alias_methods_default = createEslintRule({
2371
- name: RULE_NAME$72,
2365
+ name: RULE_NAME$73,
2372
2366
  meta: {
2373
2367
  docs: {
2374
2368
  description: "disallow alias methods",
@@ -2392,7 +2386,7 @@ var no_alias_methods_default = createEslintRule({
2392
2386
  toReturnWith: "toHaveReturnedWith",
2393
2387
  lastReturnedWith: "toHaveLastReturnedWith",
2394
2388
  nthReturnedWith: "toHaveNthReturnedWith",
2395
- toThrow: "toThrowError"
2389
+ toThrowError: "toThrow"
2396
2390
  };
2397
2391
  return { CallExpression(node) {
2398
2392
  const vitestFnCall = parseVitestFnCall(node, context);
@@ -2417,12 +2411,12 @@ var no_alias_methods_default = createEslintRule({
2417
2411
 
2418
2412
  //#endregion
2419
2413
  //#region src/rules/no-commented-out-tests.ts
2420
- const RULE_NAME$71 = "no-commented-out-tests";
2414
+ const RULE_NAME$72 = "no-commented-out-tests";
2421
2415
  function hasTests(node) {
2422
2416
  return /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu.test(node.value);
2423
2417
  }
2424
2418
  var no_commented_out_tests_default = createEslintRule({
2425
- name: RULE_NAME$71,
2419
+ name: RULE_NAME$72,
2426
2420
  meta: {
2427
2421
  docs: {
2428
2422
  description: "disallow commented out tests",
@@ -2450,10 +2444,10 @@ var no_commented_out_tests_default = createEslintRule({
2450
2444
 
2451
2445
  //#endregion
2452
2446
  //#region src/rules/no-conditional-expect.ts
2453
- const RULE_NAME$70 = "no-conditional-expect";
2447
+ const RULE_NAME$71 = "no-conditional-expect";
2454
2448
  const isCatchCall = (node) => node.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "catch");
2455
2449
  var no_conditional_expect_default = createEslintRule({
2456
- name: RULE_NAME$70,
2450
+ name: RULE_NAME$71,
2457
2451
  meta: {
2458
2452
  type: "problem",
2459
2453
  docs: {
@@ -2531,9 +2525,9 @@ var no_conditional_expect_default = createEslintRule({
2531
2525
 
2532
2526
  //#endregion
2533
2527
  //#region src/rules/no-conditional-in-test.ts
2534
- const RULE_NAME$69 = "no-conditional-in-test";
2528
+ const RULE_NAME$70 = "no-conditional-in-test";
2535
2529
  var no_conditional_in_test_default = createEslintRule({
2536
- name: RULE_NAME$69,
2530
+ name: RULE_NAME$70,
2537
2531
  meta: {
2538
2532
  docs: {
2539
2533
  description: "disallow conditional tests",
@@ -2556,9 +2550,9 @@ var no_conditional_in_test_default = createEslintRule({
2556
2550
 
2557
2551
  //#endregion
2558
2552
  //#region src/rules/no-conditional-tests.ts
2559
- const RULE_NAME$68 = "no-conditional-tests";
2553
+ const RULE_NAME$69 = "no-conditional-tests";
2560
2554
  var no_conditional_tests_default = createEslintRule({
2561
- name: RULE_NAME$68,
2555
+ name: RULE_NAME$69,
2562
2556
  meta: {
2563
2557
  type: "problem",
2564
2558
  docs: {
@@ -2586,9 +2580,9 @@ var no_conditional_tests_default = createEslintRule({
2586
2580
 
2587
2581
  //#endregion
2588
2582
  //#region src/rules/no-disabled-tests.ts
2589
- const RULE_NAME$67 = "no-disabled-tests";
2583
+ const RULE_NAME$68 = "no-disabled-tests";
2590
2584
  var no_disabled_tests_default = createEslintRule({
2591
- name: RULE_NAME$67,
2585
+ name: RULE_NAME$68,
2592
2586
  meta: {
2593
2587
  type: "suggestion",
2594
2588
  docs: {
@@ -2653,7 +2647,7 @@ var no_disabled_tests_default = createEslintRule({
2653
2647
 
2654
2648
  //#endregion
2655
2649
  //#region src/rules/no-done-callback.ts
2656
- const RULE_NAME$66 = "no-done-callback";
2650
+ const RULE_NAME$67 = "no-done-callback";
2657
2651
  const findCallbackArg = (node, isVitestEach, context) => {
2658
2652
  if (isVitestEach) return node.arguments[1];
2659
2653
  const vitestFnCall = parseVitestFnCall(node, context);
@@ -2662,7 +2656,7 @@ const findCallbackArg = (node, isVitestEach, context) => {
2662
2656
  return null;
2663
2657
  };
2664
2658
  var no_done_callback_default = createEslintRule({
2665
- name: RULE_NAME$66,
2659
+ name: RULE_NAME$67,
2666
2660
  meta: {
2667
2661
  type: "suggestion",
2668
2662
  docs: {
@@ -2746,9 +2740,9 @@ var no_done_callback_default = createEslintRule({
2746
2740
 
2747
2741
  //#endregion
2748
2742
  //#region src/rules/no-duplicate-hooks.ts
2749
- const RULE_NAME$65 = "no-duplicate-hooks";
2743
+ const RULE_NAME$66 = "no-duplicate-hooks";
2750
2744
  var no_duplicate_hooks_default = createEslintRule({
2751
- name: RULE_NAME$65,
2745
+ name: RULE_NAME$66,
2752
2746
  meta: {
2753
2747
  docs: {
2754
2748
  recommended: false,
@@ -2784,9 +2778,9 @@ var no_duplicate_hooks_default = createEslintRule({
2784
2778
 
2785
2779
  //#endregion
2786
2780
  //#region src/rules/no-focused-tests.ts
2787
- const RULE_NAME$64 = "no-focused-tests";
2781
+ const RULE_NAME$65 = "no-focused-tests";
2788
2782
  var no_focused_tests_default = createEslintRule({
2789
- name: RULE_NAME$64,
2783
+ name: RULE_NAME$65,
2790
2784
  meta: {
2791
2785
  type: "problem",
2792
2786
  docs: {
@@ -2827,9 +2821,9 @@ var no_focused_tests_default = createEslintRule({
2827
2821
 
2828
2822
  //#endregion
2829
2823
  //#region src/rules/no-hooks.ts
2830
- const RULE_NAME$63 = "no-hooks";
2824
+ const RULE_NAME$64 = "no-hooks";
2831
2825
  var no_hooks_default = createEslintRule({
2832
- name: RULE_NAME$63,
2826
+ name: RULE_NAME$64,
2833
2827
  meta: {
2834
2828
  type: "suggestion",
2835
2829
  docs: {
@@ -2872,13 +2866,13 @@ var no_hooks_default = createEslintRule({
2872
2866
 
2873
2867
  //#endregion
2874
2868
  //#region src/rules/no-identical-title.ts
2875
- const RULE_NAME$62 = "no-identical-title";
2869
+ const RULE_NAME$63 = "no-identical-title";
2876
2870
  const newDescribeContext = () => ({
2877
2871
  describeTitles: [],
2878
2872
  testTitles: []
2879
2873
  });
2880
2874
  var no_identical_title_default = createEslintRule({
2881
- name: RULE_NAME$62,
2875
+ name: RULE_NAME$63,
2882
2876
  meta: {
2883
2877
  type: "problem",
2884
2878
  docs: {
@@ -2927,9 +2921,9 @@ var no_identical_title_default = createEslintRule({
2927
2921
 
2928
2922
  //#endregion
2929
2923
  //#region src/rules/no-import-node-test.ts
2930
- const RULE_NAME$61 = "no-import-node-test";
2924
+ const RULE_NAME$62 = "no-import-node-test";
2931
2925
  var no_import_node_test_default = createEslintRule({
2932
- name: RULE_NAME$61,
2926
+ name: RULE_NAME$62,
2933
2927
  meta: {
2934
2928
  docs: {
2935
2929
  description: "disallow importing `node:test`",
@@ -3025,9 +3019,9 @@ const removeNodeFromArray = (fixer, nodes, target) => {
3025
3019
 
3026
3020
  //#endregion
3027
3021
  //#region src/rules/no-importing-vitest-globals.ts
3028
- const RULE_NAME$60 = "no-importing-vitest-globals";
3022
+ const RULE_NAME$61 = "no-importing-vitest-globals";
3029
3023
  var no_importing_vitest_globals_default = createEslintRule({
3030
- name: RULE_NAME$60,
3024
+ name: RULE_NAME$61,
3031
3025
  meta: {
3032
3026
  type: "suggestion",
3033
3027
  docs: {
@@ -3082,9 +3076,9 @@ var no_importing_vitest_globals_default = createEslintRule({
3082
3076
 
3083
3077
  //#endregion
3084
3078
  //#region src/rules/no-interpolation-in-snapshots.ts
3085
- const RULE_NAME$59 = "no-interpolation-in-snapshots";
3079
+ const RULE_NAME$60 = "no-interpolation-in-snapshots";
3086
3080
  var no_interpolation_in_snapshots_default = createEslintRule({
3087
- name: RULE_NAME$59,
3081
+ name: RULE_NAME$60,
3088
3082
  meta: {
3089
3083
  type: "problem",
3090
3084
  docs: {
@@ -3111,7 +3105,7 @@ var no_interpolation_in_snapshots_default = createEslintRule({
3111
3105
 
3112
3106
  //#endregion
3113
3107
  //#region src/rules/no-large-snapshots.ts
3114
- const RULE_NAME$58 = "no-large-snapshots";
3108
+ const RULE_NAME$59 = "no-large-snapshots";
3115
3109
  const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnapshots = {} }) => {
3116
3110
  const startLine = node.loc.start.line;
3117
3111
  const lineCount = node.loc.end.line - startLine;
@@ -3137,7 +3131,7 @@ const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnap
3137
3131
  });
3138
3132
  };
3139
3133
  var no_large_snapshots_default = createEslintRule({
3140
- name: RULE_NAME$58,
3134
+ name: RULE_NAME$59,
3141
3135
  meta: {
3142
3136
  docs: {
3143
3137
  description: "disallow large snapshots",
@@ -3189,9 +3183,9 @@ var no_large_snapshots_default = createEslintRule({
3189
3183
  const mocksDirName = "__mocks__";
3190
3184
  const isMockPath = (path) => path.split(posix.sep).includes(mocksDirName);
3191
3185
  const isMockImportLiteral = (expression) => isStringNode(expression) && isMockPath(getStringValue(expression));
3192
- const RULE_NAME$57 = "no-mocks-import";
3186
+ const RULE_NAME$58 = "no-mocks-import";
3193
3187
  var no_mocks_import_default = createEslintRule({
3194
- name: RULE_NAME$57,
3188
+ name: RULE_NAME$58,
3195
3189
  meta: {
3196
3190
  type: "problem",
3197
3191
  docs: {
@@ -3222,13 +3216,13 @@ var no_mocks_import_default = createEslintRule({
3222
3216
 
3223
3217
  //#endregion
3224
3218
  //#region src/rules/no-restricted-matchers.ts
3225
- const RULE_NAME$56 = "no-restricted-matchers";
3219
+ const RULE_NAME$57 = "no-restricted-matchers";
3226
3220
  const isChainRestricted = (chain, restriction) => {
3227
3221
  if (Object.prototype.hasOwnProperty.call(ModifierName, restriction) || restriction.endsWith(".not")) return chain.startsWith(restriction);
3228
3222
  return chain === restriction;
3229
3223
  };
3230
3224
  var no_restricted_matchers_default = createEslintRule({
3231
- name: RULE_NAME$56,
3225
+ name: RULE_NAME$57,
3232
3226
  meta: {
3233
3227
  docs: {
3234
3228
  description: "disallow the use of certain matchers",
@@ -3271,9 +3265,9 @@ var no_restricted_matchers_default = createEslintRule({
3271
3265
 
3272
3266
  //#endregion
3273
3267
  //#region src/rules/no-restricted-vi-methods.ts
3274
- const RULE_NAME$55 = "no-restricted-vi-methods";
3268
+ const RULE_NAME$56 = "no-restricted-vi-methods";
3275
3269
  var no_restricted_vi_methods_default = createEslintRule({
3276
- name: RULE_NAME$55,
3270
+ name: RULE_NAME$56,
3277
3271
  meta: {
3278
3272
  type: "suggestion",
3279
3273
  docs: {
@@ -3316,7 +3310,7 @@ var no_restricted_vi_methods_default = createEslintRule({
3316
3310
 
3317
3311
  //#endregion
3318
3312
  //#region src/rules/no-standalone-expect.ts
3319
- const RULE_NAME$54 = "no-standalone-expect";
3313
+ const RULE_NAME$55 = "no-standalone-expect";
3320
3314
  const getBlockType = (statement, context) => {
3321
3315
  const func = statement.parent;
3322
3316
  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");
@@ -3329,7 +3323,7 @@ const getBlockType = (statement, context) => {
3329
3323
  return null;
3330
3324
  };
3331
3325
  var no_standalone_expect_default = createEslintRule({
3332
- name: RULE_NAME$54,
3326
+ name: RULE_NAME$55,
3333
3327
  meta: {
3334
3328
  docs: {
3335
3329
  description: "disallow using `expect` outside of `it` or `test` blocks",
@@ -3389,9 +3383,9 @@ var no_standalone_expect_default = createEslintRule({
3389
3383
 
3390
3384
  //#endregion
3391
3385
  //#region src/rules/no-test-prefixes.ts
3392
- const RULE_NAME$53 = "no-test-prefixes";
3386
+ const RULE_NAME$54 = "no-test-prefixes";
3393
3387
  var no_test_prefixes_default = createEslintRule({
3394
- name: RULE_NAME$53,
3388
+ name: RULE_NAME$54,
3395
3389
  meta: {
3396
3390
  docs: {
3397
3391
  description: "disallow using the `f` and `x` prefixes in favour of `.only` and `.skip`",
@@ -3425,14 +3419,14 @@ var no_test_prefixes_default = createEslintRule({
3425
3419
 
3426
3420
  //#endregion
3427
3421
  //#region src/rules/no-test-return-statement.ts
3428
- const RULE_NAME$52 = "no-test-return-statement";
3422
+ const RULE_NAME$53 = "no-test-return-statement";
3429
3423
  const getBody = (args) => {
3430
3424
  const [, secondArg] = args;
3431
3425
  if (secondArg && isFunction(secondArg) && secondArg.body.type === AST_NODE_TYPES.BlockStatement) return secondArg.body.body;
3432
3426
  return [];
3433
3427
  };
3434
3428
  var no_test_return_statement_default = createEslintRule({
3435
- name: RULE_NAME$52,
3429
+ name: RULE_NAME$53,
3436
3430
  meta: {
3437
3431
  type: "problem",
3438
3432
  docs: {
@@ -3466,6 +3460,48 @@ var no_test_return_statement_default = createEslintRule({
3466
3460
  }
3467
3461
  });
3468
3462
 
3463
+ //#endregion
3464
+ //#region src/rules/no-unneeded-async-expect-function.ts
3465
+ const RULE_NAME$52 = "no-unneeded-async-expect-function";
3466
+ const getAwaitedCallExpression = (expression) => {
3467
+ if (!expression.async) return null;
3468
+ if (expression.type === AST_NODE_TYPES.ArrowFunctionExpression && expression.body.type === AST_NODE_TYPES.AwaitExpression && expression.body.argument.type === AST_NODE_TYPES.CallExpression) return expression.body.argument;
3469
+ if (expression.body.type !== AST_NODE_TYPES.BlockStatement || expression.body.body.length !== 1) return null;
3470
+ const [callback] = expression.body.body;
3471
+ if (callback.type === AST_NODE_TYPES.ExpressionStatement && callback.expression.type === AST_NODE_TYPES.AwaitExpression && callback.expression.argument.type === AST_NODE_TYPES.CallExpression) return callback.expression.argument;
3472
+ return null;
3473
+ };
3474
+ var no_unneeded_async_expect_function_default = createEslintRule({
3475
+ name: RULE_NAME$52,
3476
+ meta: {
3477
+ docs: { description: "Disallow unnecessary async function wrapper for expected promises" },
3478
+ fixable: "code",
3479
+ messages: { noAsyncWrapperForExpectedPromise: "Unnecessary async function wrapper" },
3480
+ schema: [],
3481
+ type: "suggestion"
3482
+ },
3483
+ create(context) {
3484
+ return { CallExpression(node) {
3485
+ const vitestFnCall = parseVitestFnCall(node, context);
3486
+ if (vitestFnCall?.type !== "expect") return;
3487
+ const { parent } = vitestFnCall.head.node;
3488
+ if (parent?.type !== AST_NODE_TYPES.CallExpression) return;
3489
+ const [awaitNode] = parent.arguments;
3490
+ if (!awaitNode || !isFunction(awaitNode)) return;
3491
+ const innerAsyncFuncCall = getAwaitedCallExpression(awaitNode);
3492
+ if (!innerAsyncFuncCall) return;
3493
+ context.report({
3494
+ node: awaitNode,
3495
+ messageId: "noAsyncWrapperForExpectedPromise",
3496
+ fix(fixer) {
3497
+ const { sourceCode } = context;
3498
+ return [fixer.replaceTextRange(awaitNode.range, sourceCode.getText(innerAsyncFuncCall))];
3499
+ }
3500
+ });
3501
+ } };
3502
+ }
3503
+ });
3504
+
3469
3505
  //#endregion
3470
3506
  //#region src/utils/ast-utils.ts
3471
3507
  const eslintRequire = createRequire(createRequire(import.meta.url).resolve("eslint"));
@@ -5446,11 +5482,46 @@ var prefer_to_contain_default = createEslintRule({
5446
5482
  }
5447
5483
  });
5448
5484
 
5485
+ //#endregion
5486
+ //#region src/rules/prefer-to-have-been-called-times.ts
5487
+ const RULE_NAME$16 = "prefer-to-have-been-called-times";
5488
+ var prefer_to_have_been_called_times_default = createEslintRule({
5489
+ name: RULE_NAME$16,
5490
+ meta: {
5491
+ fixable: "code",
5492
+ docs: { description: "Suggest using `toHaveBeenCalledTimes()`" },
5493
+ messages: { preferMatcher: "Prefer `toHaveBeenCalledTimes`" },
5494
+ type: "suggestion",
5495
+ schema: []
5496
+ },
5497
+ create(context) {
5498
+ return { CallExpression(node) {
5499
+ const vitestFnCall = parseVitestFnCall(node, context);
5500
+ if (vitestFnCall?.type !== "expect") return;
5501
+ const { parent: expect } = vitestFnCall.head.node;
5502
+ if (expect?.type !== AST_NODE_TYPES.CallExpression) return;
5503
+ const { matcher } = vitestFnCall;
5504
+ if (!isSupportedAccessor(matcher, "toHaveLength")) return;
5505
+ const [argument] = expect.arguments;
5506
+ if (argument?.type !== AST_NODE_TYPES.MemberExpression || !isSupportedAccessor(argument.property, "calls")) return;
5507
+ const { object } = argument;
5508
+ if (object.type !== AST_NODE_TYPES.MemberExpression || !isSupportedAccessor(object.property, "mock")) return;
5509
+ context.report({
5510
+ messageId: "preferMatcher",
5511
+ node: matcher,
5512
+ fix(fixer) {
5513
+ return [fixer.removeRange([object.property.range[0] - 1, argument.range[1]]), fixer.replaceTextRange([matcher.parent.object.range[1], matcher.parent.range[1]], ".toHaveBeenCalledTimes")];
5514
+ }
5515
+ });
5516
+ } };
5517
+ }
5518
+ });
5519
+
5449
5520
  //#endregion
5450
5521
  //#region src/rules/prefer-to-have-length.ts
5451
- const RULE_NAME$16 = "prefer-to-have-length";
5522
+ const RULE_NAME$15 = "prefer-to-have-length";
5452
5523
  var prefer_to_have_length_default = createEslintRule({
5453
- name: RULE_NAME$16,
5524
+ name: RULE_NAME$15,
5454
5525
  meta: {
5455
5526
  type: "suggestion",
5456
5527
  docs: {
@@ -5483,7 +5554,7 @@ var prefer_to_have_length_default = createEslintRule({
5483
5554
 
5484
5555
  //#endregion
5485
5556
  //#region src/rules/prefer-todo.ts
5486
- const RULE_NAME$15 = "prefer-todo";
5557
+ const RULE_NAME$14 = "prefer-todo";
5487
5558
  const isTargetedTestCase = (vitestFnCall) => {
5488
5559
  if (vitestFnCall.members.some((s) => getAccessorValue(s) !== "skip")) return false;
5489
5560
  if (vitestFnCall.name.startsWith("x")) return false;
@@ -5498,7 +5569,7 @@ function createTodoFixer(vitestFnCall, fixer) {
5498
5569
  return fixer.replaceText(vitestFnCall.head.node, `${vitestFnCall.head.local}.todo`);
5499
5570
  }
5500
5571
  var prefer_todo_default = createEslintRule({
5501
- name: RULE_NAME$15,
5572
+ name: RULE_NAME$14,
5502
5573
  meta: {
5503
5574
  type: "layout",
5504
5575
  docs: {
@@ -5533,7 +5604,7 @@ var prefer_todo_default = createEslintRule({
5533
5604
 
5534
5605
  //#endregion
5535
5606
  //#region src/rules/prefer-vi-mocked.ts
5536
- const RULE_NAME$14 = "prefer-vi-mocked";
5607
+ const RULE_NAME$13 = "prefer-vi-mocked";
5537
5608
  const mockTypes = [
5538
5609
  "Mock",
5539
5610
  "MockedFunction",
@@ -5541,7 +5612,7 @@ const mockTypes = [
5541
5612
  "MockedObject"
5542
5613
  ];
5543
5614
  var prefer_vi_mocked_default = createEslintRule({
5544
- name: RULE_NAME$14,
5615
+ name: RULE_NAME$13,
5545
5616
  meta: {
5546
5617
  type: "suggestion",
5547
5618
  docs: {
@@ -5583,9 +5654,9 @@ var prefer_vi_mocked_default = createEslintRule({
5583
5654
 
5584
5655
  //#endregion
5585
5656
  //#region src/rules/require-awaited-expect-poll.ts
5586
- const RULE_NAME$13 = "require-awaited-expect-poll";
5657
+ const RULE_NAME$12 = "require-awaited-expect-poll";
5587
5658
  var require_awaited_expect_poll_default = createEslintRule({
5588
- name: RULE_NAME$13,
5659
+ name: RULE_NAME$12,
5589
5660
  meta: {
5590
5661
  docs: {
5591
5662
  requiresTypeChecking: false,
@@ -5631,7 +5702,7 @@ function skipSequenceExpressions(node) {
5631
5702
 
5632
5703
  //#endregion
5633
5704
  //#region src/rules/require-hook.ts
5634
- const RULE_NAME$12 = "require-hook";
5705
+ const RULE_NAME$11 = "require-hook";
5635
5706
  const isVitestFnCall = (node, context) => {
5636
5707
  if (parseVitestFnCall(node, context)) return true;
5637
5708
  return !!getNodeName(node)?.startsWith("vi");
@@ -5650,7 +5721,7 @@ const shouldBeInHook = (node, context, allowedFunctionCalls = []) => {
5650
5721
  }
5651
5722
  };
5652
5723
  var require_hook_default = createEslintRule({
5653
- name: RULE_NAME$12,
5724
+ name: RULE_NAME$11,
5654
5725
  meta: {
5655
5726
  docs: {
5656
5727
  description: "require setup and teardown to be within a hook",
@@ -5690,11 +5761,95 @@ var require_hook_default = createEslintRule({
5690
5761
  }
5691
5762
  });
5692
5763
 
5764
+ //#endregion
5765
+ //#region src/rules/require-local-test-context-for-concurrent-snapshots.ts
5766
+ const RULE_NAME$10 = "require-local-test-context-for-concurrent-snapshots";
5767
+ var require_local_test_context_for_concurrent_snapshots_default = createEslintRule({
5768
+ name: RULE_NAME$10,
5769
+ meta: {
5770
+ docs: {
5771
+ description: "require local Test Context for concurrent snapshot tests",
5772
+ recommended: false
5773
+ },
5774
+ messages: { requireLocalTestContext: "Use local Test Context instead" },
5775
+ type: "problem",
5776
+ schema: []
5777
+ },
5778
+ create(context) {
5779
+ return { CallExpression(node) {
5780
+ const vitestFnCall = parseVitestFnCall(node, context);
5781
+ if (vitestFnCall === null) return;
5782
+ if (vitestFnCall.type !== "expect") return;
5783
+ if (vitestFnCall.type === "expect" && vitestFnCall.head.type === "testContext") return;
5784
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
5785
+ if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return;
5786
+ if (![
5787
+ "toMatchSnapshot",
5788
+ "toMatchInlineSnapshot",
5789
+ "toMatchFileSnapshot",
5790
+ "toThrowErrorMatchingSnapshot",
5791
+ "toThrowErrorMatchingInlineSnapshot"
5792
+ ].includes(node.callee.property.name)) return;
5793
+ if (!context.sourceCode.getAncestors(node).some((ancestor) => {
5794
+ if (ancestor.type !== AST_NODE_TYPES.CallExpression) return false;
5795
+ if (!isTypeOfVitestFnCall(ancestor, context, ["describe", "test"])) return false;
5796
+ return ancestor.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(ancestor.callee.property, "concurrent");
5797
+ })) return;
5798
+ context.report({
5799
+ node,
5800
+ messageId: "requireLocalTestContext"
5801
+ });
5802
+ } };
5803
+ }
5804
+ });
5805
+
5806
+ //#endregion
5807
+ //#region src/rules/require-mock-type-parameters.ts
5808
+ const RULE_NAME$9 = "require-mock-type-parameters";
5809
+ var require_mock_type_parameters_default = createEslintRule({
5810
+ name: RULE_NAME$9,
5811
+ meta: {
5812
+ type: "suggestion",
5813
+ docs: {
5814
+ description: "enforce using type parameters with vitest mock functions",
5815
+ recommended: false
5816
+ },
5817
+ messages: { noTypeParameter: "Missing type parameters" },
5818
+ fixable: "code",
5819
+ schema: [{
5820
+ type: "object",
5821
+ properties: { checkImportFunctions: {
5822
+ description: "Also require type parameters for `importActual` and `importMock`.",
5823
+ type: "boolean"
5824
+ } },
5825
+ additionalProperties: false
5826
+ }],
5827
+ defaultOptions: [{ checkImportFunctions: false }]
5828
+ },
5829
+ create(context, [options]) {
5830
+ return { CallExpression(node) {
5831
+ const vitestFnCall = parseVitestFnCall(node, context);
5832
+ if (vitestFnCall?.type !== "vi") return;
5833
+ for (const member of vitestFnCall.members) {
5834
+ if (!("name" in member) || member.parent.parent.typeArguments !== void 0) continue;
5835
+ if (member.name === "fn") context.report({
5836
+ node: member,
5837
+ messageId: "noTypeParameter"
5838
+ });
5839
+ if (options.checkImportFunctions && ["importActual", "importMock"].includes(member.name)) context.report({
5840
+ node: member,
5841
+ messageId: "noTypeParameter"
5842
+ });
5843
+ }
5844
+ } };
5845
+ }
5846
+ });
5847
+
5693
5848
  //#endregion
5694
5849
  //#region src/rules/require-test-timeout.ts
5695
- const RULE_NAME$11 = "require-test-timeout";
5850
+ const RULE_NAME$8 = "require-test-timeout";
5696
5851
  var require_test_timeout_default = createEslintRule({
5697
- name: RULE_NAME$11,
5852
+ name: RULE_NAME$8,
5698
5853
  meta: {
5699
5854
  type: "suggestion",
5700
5855
  docs: {
@@ -5778,95 +5933,11 @@ var require_test_timeout_default = createEslintRule({
5778
5933
  }
5779
5934
  });
5780
5935
 
5781
- //#endregion
5782
- //#region src/rules/require-local-test-context-for-concurrent-snapshots.ts
5783
- const RULE_NAME$10 = "require-local-test-context-for-concurrent-snapshots";
5784
- var require_local_test_context_for_concurrent_snapshots_default = createEslintRule({
5785
- name: RULE_NAME$10,
5786
- meta: {
5787
- docs: {
5788
- description: "require local Test Context for concurrent snapshot tests",
5789
- recommended: false
5790
- },
5791
- messages: { requireLocalTestContext: "Use local Test Context instead" },
5792
- type: "problem",
5793
- schema: []
5794
- },
5795
- create(context) {
5796
- return { CallExpression(node) {
5797
- const vitestFnCall = parseVitestFnCall(node, context);
5798
- if (vitestFnCall === null) return;
5799
- if (vitestFnCall.type !== "expect") return;
5800
- if (vitestFnCall.type === "expect" && vitestFnCall.head.type === "testContext") return;
5801
- if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
5802
- if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return;
5803
- if (![
5804
- "toMatchSnapshot",
5805
- "toMatchInlineSnapshot",
5806
- "toMatchFileSnapshot",
5807
- "toThrowErrorMatchingSnapshot",
5808
- "toThrowErrorMatchingInlineSnapshot"
5809
- ].includes(node.callee.property.name)) return;
5810
- if (!context.sourceCode.getAncestors(node).some((ancestor) => {
5811
- if (ancestor.type !== AST_NODE_TYPES.CallExpression) return false;
5812
- if (!isTypeOfVitestFnCall(ancestor, context, ["describe", "test"])) return false;
5813
- return ancestor.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(ancestor.callee.property, "concurrent");
5814
- })) return;
5815
- context.report({
5816
- node,
5817
- messageId: "requireLocalTestContext"
5818
- });
5819
- } };
5820
- }
5821
- });
5822
-
5823
- //#endregion
5824
- //#region src/rules/require-mock-type-parameters.ts
5825
- const RULE_NAME$9 = "require-mock-type-parameters";
5826
- var require_mock_type_parameters_default = createEslintRule({
5827
- name: RULE_NAME$9,
5828
- meta: {
5829
- type: "suggestion",
5830
- docs: {
5831
- description: "enforce using type parameters with vitest mock functions",
5832
- recommended: false
5833
- },
5834
- messages: { noTypeParameter: "Missing type parameters" },
5835
- fixable: "code",
5836
- schema: [{
5837
- type: "object",
5838
- properties: { checkImportFunctions: {
5839
- description: "Also require type parameters for `importActual` and `importMock`.",
5840
- type: "boolean"
5841
- } },
5842
- additionalProperties: false
5843
- }],
5844
- defaultOptions: [{ checkImportFunctions: false }]
5845
- },
5846
- create(context, [options]) {
5847
- return { CallExpression(node) {
5848
- const vitestFnCall = parseVitestFnCall(node, context);
5849
- if (vitestFnCall?.type !== "vi") return;
5850
- for (const member of vitestFnCall.members) {
5851
- if (!("name" in member) || member.parent.parent.typeArguments !== void 0) continue;
5852
- if (member.name === "fn") context.report({
5853
- node: member,
5854
- messageId: "noTypeParameter"
5855
- });
5856
- if (options.checkImportFunctions && ["importActual", "importMock"].includes(member.name)) context.report({
5857
- node: member,
5858
- messageId: "noTypeParameter"
5859
- });
5860
- }
5861
- } };
5862
- }
5863
- });
5864
-
5865
5936
  //#endregion
5866
5937
  //#region src/rules/require-to-throw-message.ts
5867
- const RULE_NAME$8 = "require-to-throw-message";
5938
+ const RULE_NAME$7 = "require-to-throw-message";
5868
5939
  var require_to_throw_message_default = createEslintRule({
5869
- name: RULE_NAME$8,
5940
+ name: RULE_NAME$7,
5870
5941
  meta: {
5871
5942
  type: "suggestion",
5872
5943
  docs: {
@@ -5893,9 +5964,9 @@ var require_to_throw_message_default = createEslintRule({
5893
5964
 
5894
5965
  //#endregion
5895
5966
  //#region src/rules/require-top-level-describe.ts
5896
- const RULE_NAME$7 = "require-top-level-describe";
5967
+ const RULE_NAME$6 = "require-top-level-describe";
5897
5968
  var require_top_level_describe_default = createEslintRule({
5898
- name: RULE_NAME$7,
5969
+ name: RULE_NAME$6,
5899
5970
  meta: {
5900
5971
  docs: {
5901
5972
  description: "enforce that all tests are in a top-level describe",
@@ -5962,9 +6033,74 @@ var require_top_level_describe_default = createEslintRule({
5962
6033
  }
5963
6034
  });
5964
6035
 
6036
+ //#endregion
6037
+ //#region src/rules/unbound-method.ts
6038
+ const require$1 = createRequire(import.meta.url);
6039
+ const RULE_NAME$5 = "unbound-method";
6040
+ const toThrowMatchers = [
6041
+ "toThrow",
6042
+ "toThrowError",
6043
+ "toThrowErrorMatchingSnapshot",
6044
+ "toThrowErrorMatchingInlineSnapshot"
6045
+ ];
6046
+ const DEFAULT_MESSAGE = "This rule requires `@typescript-eslint/eslint-plugin`";
6047
+ const baseRule = (() => {
6048
+ try {
6049
+ return require$1("@typescript-eslint/eslint-plugin").rules["unbound-method"];
6050
+ } catch (error) {
6051
+ const errorCode = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
6052
+ if (errorCode === "MODULE_NOT_FOUND" || errorCode === "ERR_REQUIRE_ESM") return null;
6053
+ throw error;
6054
+ }
6055
+ })();
6056
+ var unbound_method_default = createEslintRule({
6057
+ name: RULE_NAME$5,
6058
+ meta: {
6059
+ messages: {
6060
+ unbound: DEFAULT_MESSAGE,
6061
+ unboundWithoutThisAnnotation: DEFAULT_MESSAGE
6062
+ },
6063
+ schema: [{
6064
+ type: "object",
6065
+ properties: { ignoreStatic: {
6066
+ description: "Ignore unbound warnings for static methods.",
6067
+ type: "boolean"
6068
+ } },
6069
+ additionalProperties: false
6070
+ }],
6071
+ type: "problem",
6072
+ ...baseRule?.meta,
6073
+ docs: {
6074
+ ...baseRule?.meta.docs,
6075
+ description: "enforce unbound methods are called with their expected scope",
6076
+ recommended: false,
6077
+ requiresTypeChecking: true
6078
+ },
6079
+ defaultOptions: [{ ignoreStatic: false }]
6080
+ },
6081
+ create(context) {
6082
+ const baseSelectors = baseRule?.create(context);
6083
+ if (!baseSelectors) return {};
6084
+ return {
6085
+ ...baseSelectors,
6086
+ MemberExpression(node) {
6087
+ if (node.parent?.type === AST_NODE_TYPES.CallExpression) {
6088
+ const vitestFnCall = parseVitestFnCall(findTopMostCallExpression(node.parent), context);
6089
+ if (vitestFnCall?.type === "vi" && vitestFnCall.members.length >= 1 && isIdentifier(vitestFnCall.members[0], "mocked")) return;
6090
+ if (vitestFnCall?.type === "expect") {
6091
+ const { matcher } = vitestFnCall;
6092
+ if (!toThrowMatchers.includes(getAccessorValue(matcher))) return;
6093
+ }
6094
+ }
6095
+ baseSelectors?.MemberExpression?.(node);
6096
+ }
6097
+ };
6098
+ }
6099
+ });
6100
+
5965
6101
  //#endregion
5966
6102
  //#region src/rules/valid-describe-callback.ts
5967
- const RULE_NAME$6 = "valid-describe-callback";
6103
+ const RULE_NAME$4 = "valid-describe-callback";
5968
6104
  const paramsLocation = (params) => {
5969
6105
  const [first] = params;
5970
6106
  const last = params[params.length - 1];
@@ -5986,7 +6122,7 @@ const reportUnexpectedReturnInDescribe = (blockStatement, context) => {
5986
6122
  });
5987
6123
  };
5988
6124
  var valid_describe_callback_default = createEslintRule({
5989
- name: RULE_NAME$6,
6125
+ name: RULE_NAME$4,
5990
6126
  meta: {
5991
6127
  type: "problem",
5992
6128
  docs: {
@@ -6052,7 +6188,7 @@ var valid_describe_callback_default = createEslintRule({
6052
6188
 
6053
6189
  //#endregion
6054
6190
  //#region src/rules/valid-expect-in-promise.ts
6055
- const RULE_NAME$5 = "valid-expect-in-promise";
6191
+ const RULE_NAME$3 = "valid-expect-in-promise";
6056
6192
  const isPromiseChainCall = (node) => {
6057
6193
  if (node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property)) {
6058
6194
  if (node.arguments.length === 0) return false;
@@ -6183,7 +6319,7 @@ const isVariableAwaitedOrReturned = (variable, context) => {
6183
6319
  return isValueAwaitedOrReturned(variable.id, body, context);
6184
6320
  };
6185
6321
  var valid_expect_in_promise_default = createEslintRule({
6186
- name: RULE_NAME$5,
6322
+ name: RULE_NAME$3,
6187
6323
  meta: {
6188
6324
  docs: { description: "require promises that have expectations in their chain to be valid" },
6189
6325
  messages: { expectInFloatingPromise: "This promise should either be returned or awaited to ensure the expects in its chain are called" },
@@ -6237,7 +6373,7 @@ var valid_expect_in_promise_default = createEslintRule({
6237
6373
 
6238
6374
  //#endregion
6239
6375
  //#region src/rules/valid-expect.ts
6240
- const RULE_NAME$4 = "valid-expect";
6376
+ const RULE_NAME$2 = "valid-expect";
6241
6377
  const defaultAsyncMatchers = ["toReject", "toResolve"];
6242
6378
  /**
6243
6379
  * Async assertions might be called in Promise
@@ -6272,7 +6408,7 @@ const isAcceptableReturnNode = (node, allowReturn) => {
6272
6408
  return [AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.AwaitExpression].includes(node.type);
6273
6409
  };
6274
6410
  var valid_expect_default = createEslintRule({
6275
- name: RULE_NAME$4,
6411
+ name: RULE_NAME$2,
6276
6412
  meta: {
6277
6413
  docs: {
6278
6414
  description: "enforce valid `expect()` usage",
@@ -6466,9 +6602,13 @@ var valid_expect_default = createEslintRule({
6466
6602
  }
6467
6603
  });
6468
6604
 
6605
+ //#endregion
6606
+ //#region src/utils/require.ts
6607
+ const require = createRequire(import.meta.url);
6608
+
6469
6609
  //#endregion
6470
6610
  //#region src/rules/valid-title.ts
6471
- const RULE_NAME$3 = "valid-title";
6611
+ const RULE_NAME$1 = "valid-title";
6472
6612
  const trimFXPrefix = (word) => ["f", "x"].includes(word.charAt(0)) ? word.substring(1) : word;
6473
6613
  const quoteStringValue = (node) => node.type === AST_NODE_TYPES.TemplateLiteral ? `\`${node.quasis[0].value.raw}\`` : node.raw;
6474
6614
  const MatcherAndMessageSchema = {
@@ -6507,7 +6647,7 @@ const doesBinaryExpressionContainStringNode = (binaryExp) => {
6507
6647
  return isStringNode(binaryExp.left);
6508
6648
  };
6509
6649
  var valid_title_default = createEslintRule({
6510
- name: RULE_NAME$3,
6650
+ name: RULE_NAME$1,
6511
6651
  meta: {
6512
6652
  docs: {
6513
6653
  description: "enforce valid titles",
@@ -6661,9 +6801,9 @@ var valid_title_default = createEslintRule({
6661
6801
 
6662
6802
  //#endregion
6663
6803
  //#region src/rules/warn-todo.ts
6664
- const RULE_NAME$2 = "warn-todo";
6804
+ const RULE_NAME = "warn-todo";
6665
6805
  var warn_todo_default = createEslintRule({
6666
- name: RULE_NAME$2,
6806
+ name: RULE_NAME,
6667
6807
  meta: {
6668
6808
  docs: {
6669
6809
  description: "disallow `.todo` usage",
@@ -6687,83 +6827,6 @@ var warn_todo_default = createEslintRule({
6687
6827
  }
6688
6828
  });
6689
6829
 
6690
- //#endregion
6691
- //#region src/rules/no-unneeded-async-expect-function.ts
6692
- const RULE_NAME$1 = "no-unneeded-async-expect-function";
6693
- const getAwaitedCallExpression = (expression) => {
6694
- if (!expression.async) return null;
6695
- if (expression.type === AST_NODE_TYPES.ArrowFunctionExpression && expression.body.type === AST_NODE_TYPES.AwaitExpression && expression.body.argument.type === AST_NODE_TYPES.CallExpression) return expression.body.argument;
6696
- if (expression.body.type !== AST_NODE_TYPES.BlockStatement || expression.body.body.length !== 1) return null;
6697
- const [callback] = expression.body.body;
6698
- if (callback.type === AST_NODE_TYPES.ExpressionStatement && callback.expression.type === AST_NODE_TYPES.AwaitExpression && callback.expression.argument.type === AST_NODE_TYPES.CallExpression) return callback.expression.argument;
6699
- return null;
6700
- };
6701
- var no_unneeded_async_expect_function_default = createEslintRule({
6702
- name: RULE_NAME$1,
6703
- meta: {
6704
- docs: { description: "Disallow unnecessary async function wrapper for expected promises" },
6705
- fixable: "code",
6706
- messages: { noAsyncWrapperForExpectedPromise: "Unnecessary async function wrapper" },
6707
- schema: [],
6708
- type: "suggestion"
6709
- },
6710
- create(context) {
6711
- return { CallExpression(node) {
6712
- const vitestFnCall = parseVitestFnCall(node, context);
6713
- if (vitestFnCall?.type !== "expect") return;
6714
- const { parent } = vitestFnCall.head.node;
6715
- if (parent?.type !== AST_NODE_TYPES.CallExpression) return;
6716
- const [awaitNode] = parent.arguments;
6717
- if (!awaitNode || !isFunction(awaitNode)) return;
6718
- const innerAsyncFuncCall = getAwaitedCallExpression(awaitNode);
6719
- if (!innerAsyncFuncCall) return;
6720
- context.report({
6721
- node: awaitNode,
6722
- messageId: "noAsyncWrapperForExpectedPromise",
6723
- fix(fixer) {
6724
- const { sourceCode } = context;
6725
- return [fixer.replaceTextRange(awaitNode.range, sourceCode.getText(innerAsyncFuncCall))];
6726
- }
6727
- });
6728
- } };
6729
- }
6730
- });
6731
-
6732
- //#endregion
6733
- //#region src/rules/prefer-to-have-been-called-times.ts
6734
- const RULE_NAME = "prefer-to-have-been-called-times";
6735
- var prefer_to_have_been_called_times_default = createEslintRule({
6736
- name: RULE_NAME,
6737
- meta: {
6738
- fixable: "code",
6739
- docs: { description: "Suggest using `toHaveBeenCalledTimes()`" },
6740
- messages: { preferMatcher: "Prefer `toHaveBeenCalledTimes`" },
6741
- type: "suggestion",
6742
- schema: []
6743
- },
6744
- create(context) {
6745
- return { CallExpression(node) {
6746
- const vitestFnCall = parseVitestFnCall(node, context);
6747
- if (vitestFnCall?.type !== "expect") return;
6748
- const { parent: expect } = vitestFnCall.head.node;
6749
- if (expect?.type !== AST_NODE_TYPES.CallExpression) return;
6750
- const { matcher } = vitestFnCall;
6751
- if (!isSupportedAccessor(matcher, "toHaveLength")) return;
6752
- const [argument] = expect.arguments;
6753
- if (argument?.type !== AST_NODE_TYPES.MemberExpression || !isSupportedAccessor(argument.property, "calls")) return;
6754
- const { object } = argument;
6755
- if (object.type !== AST_NODE_TYPES.MemberExpression || !isSupportedAccessor(object.property, "mock")) return;
6756
- context.report({
6757
- messageId: "preferMatcher",
6758
- node: matcher,
6759
- fix(fixer) {
6760
- return [fixer.removeRange([object.property.range[0] - 1, argument.range[1]]), fixer.replaceTextRange([matcher.parent.object.range[1], matcher.parent.range[1]], ".toHaveBeenCalledTimes")];
6761
- }
6762
- });
6763
- } };
6764
- }
6765
- });
6766
-
6767
6830
  //#endregion
6768
6831
  //#region src/rules/index.ts
6769
6832
  const rules = {
@@ -6838,11 +6901,12 @@ const rules = {
6838
6901
  "prefer-vi-mocked": prefer_vi_mocked_default,
6839
6902
  "require-awaited-expect-poll": require_awaited_expect_poll_default,
6840
6903
  "require-hook": require_hook_default,
6841
- "require-test-timeout": require_test_timeout_default,
6842
6904
  "require-local-test-context-for-concurrent-snapshots": require_local_test_context_for_concurrent_snapshots_default,
6843
6905
  "require-mock-type-parameters": require_mock_type_parameters_default,
6906
+ "require-test-timeout": require_test_timeout_default,
6844
6907
  "require-to-throw-message": require_to_throw_message_default,
6845
6908
  "require-top-level-describe": require_top_level_describe_default,
6909
+ "unbound-method": unbound_method_default,
6846
6910
  "valid-describe-callback": valid_describe_callback_default,
6847
6911
  "valid-expect-in-promise": valid_expect_in_promise_default,
6848
6912
  "valid-expect": valid_expect_default,
@@ -6868,9 +6932,9 @@ const createConfigLegacy = (rules) => ({
6868
6932
  }, {})
6869
6933
  });
6870
6934
  const allRules = {
6935
+ "consistent-each-for": "warn",
6871
6936
  "consistent-test-filename": "warn",
6872
6937
  "consistent-test-it": "warn",
6873
- "consistent-each-for": "warn",
6874
6938
  "consistent-vitest-vi": "warn",
6875
6939
  "expect-expect": "warn",
6876
6940
  "hoisted-apis-on-top": "warn",
@@ -6935,24 +6999,25 @@ const allRules = {
6935
6999
  "prefer-to-have-length": "warn",
6936
7000
  "prefer-todo": "warn",
6937
7001
  "prefer-vi-mocked": "warn",
7002
+ "require-awaited-expect-poll": "warn",
6938
7003
  "require-hook": "warn",
6939
7004
  "require-local-test-context-for-concurrent-snapshots": "warn",
6940
7005
  "require-mock-type-parameters": "warn",
7006
+ "require-test-timeout": "off",
6941
7007
  "require-to-throw-message": "warn",
6942
7008
  "require-top-level-describe": "warn",
7009
+ "unbound-method": "warn",
6943
7010
  "valid-describe-callback": "warn",
6944
7011
  "valid-expect-in-promise": "warn",
6945
7012
  "valid-expect": "warn",
6946
- "valid-title": "warn",
6947
- "require-awaited-expect-poll": "warn",
6948
- "require-test-timeout": "off"
7013
+ "valid-title": "warn"
6949
7014
  };
6950
7015
  const recommendedRules = {
6951
7016
  "expect-expect": "error",
7017
+ "no-commented-out-tests": "error",
6952
7018
  "no-conditional-expect": "error",
6953
7019
  "no-disabled-tests": "warn",
6954
7020
  "no-focused-tests": "error",
6955
- "no-commented-out-tests": "error",
6956
7021
  "no-identical-title": "error",
6957
7022
  "no-import-node-test": "error",
6958
7023
  "no-interpolation-in-snapshots": "error",