@vitest/eslint-plugin 1.1.20 → 1.1.21

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Verité Mugabo Makuza
3
+ Copyright (c) 2022 - PRESENT Verité Mugabo Makuza
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.cjs CHANGED
@@ -23,7 +23,7 @@ function _interopNamespaceCompat(e) {
23
23
  const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
24
24
  const ts__default = /*#__PURE__*/_interopDefaultCompat(ts);
25
25
 
26
- const version = "1.1.19";
26
+ const version = "1.1.20";
27
27
 
28
28
  function createEslintRule(rule) {
29
29
  const createRule = utils.ESLintUtils.RuleCreator(
@@ -34,8 +34,7 @@ function createEslintRule(rule) {
34
34
  const joinNames = (a, b) => a && b ? `${a}.${b}` : null;
35
35
  const isFunction = (node) => node.type === utils.AST_NODE_TYPES.FunctionExpression || node.type === utils.AST_NODE_TYPES.ArrowFunctionExpression;
36
36
  function getNodeName(node) {
37
- if (isSupportedAccessor(node))
38
- return getAccessorValue(node);
37
+ if (isSupportedAccessor(node)) return getAccessorValue(node);
39
38
  switch (node.type) {
40
39
  case utils.AST_NODE_TYPES.TaggedTemplateExpression:
41
40
  return getNodeName(node.tag);
@@ -102,6 +101,8 @@ var HookName = /* @__PURE__ */ ((HookName2) => {
102
101
  return HookName2;
103
102
  })(HookName || {});
104
103
  var ModifierName = /* @__PURE__ */ ((ModifierName2) => {
104
+ ModifierName2["to"] = "to";
105
+ ModifierName2["have"] = "have";
105
106
  ModifierName2["not"] = "not";
106
107
  ModifierName2["rejects"] = "rejects";
107
108
  ModifierName2["resolves"] = "resolves";
@@ -174,10 +175,10 @@ const findModifiersAndMatcher = (members) => {
174
175
  if (!ModifierName.hasOwnProperty(name))
175
176
  return "modifier-unknown";
176
177
  } else if (modifiers.length === 1) {
177
- if (name !== ModifierName.not)
178
+ if (name !== ModifierName.not && name != ModifierName.have)
178
179
  return "modifier-unknown";
179
180
  const firstModifier = getAccessorValue(modifiers[0]);
180
- if (firstModifier !== ModifierName.resolves && firstModifier !== ModifierName.rejects)
181
+ if (firstModifier !== ModifierName.resolves && firstModifier !== ModifierName.rejects && firstModifier !== ModifierName.to)
181
182
  return "modifier-unknown";
182
183
  } else {
183
184
  return "modifier-unknown";
@@ -344,6 +345,8 @@ const describeImportDefAsImport = (def) => {
344
345
  return null;
345
346
  if (def.node.type !== utils.AST_NODE_TYPES.ImportSpecifier)
346
347
  return null;
348
+ if (def.node.imported.type != utils.AST_NODE_TYPES.Identifier)
349
+ return null;
347
350
  if (def.parent.importKind === "type")
348
351
  return null;
349
352
  return {
@@ -467,8 +470,7 @@ const lowerCaseTitle = createEslintRule({
467
470
  return {
468
471
  CallExpression(node) {
469
472
  const vitestFnCall = parseVitestFnCall(node, context);
470
- if (!vitestFnCall || !hasStringAsFirstArgument)
471
- return;
473
+ if (!vitestFnCall || !hasStringAsFirstArgument) return;
472
474
  if (vitestFnCall?.type === "describe") {
473
475
  numberOfDescribeBlocks++;
474
476
  if (ignoreTopLevelDescribe && numberOfDescribeBlocks === 1)
@@ -478,13 +480,10 @@ const lowerCaseTitle = createEslintRule({
478
480
  }
479
481
  const [firstArgument] = node.arguments;
480
482
  const description = getStringValue(firstArgument);
481
- if (typeof description !== "string")
482
- return;
483
- if (allowedPrefixes.some((prefix) => description.startsWith(prefix)))
484
- return;
483
+ if (typeof description !== "string") return;
484
+ if (allowedPrefixes.some((prefix) => description.startsWith(prefix))) return;
485
485
  const firstCharacter = description.charAt(0);
486
- if (ignores.includes(vitestFnCall.name) || lowercaseFirstCharacterOnly && (!firstCharacter || firstCharacter === firstCharacter.toLowerCase()) || !lowercaseFirstCharacterOnly && description === description.toLowerCase())
487
- return;
486
+ if (ignores.includes(vitestFnCall.name) || lowercaseFirstCharacterOnly && (!firstCharacter || firstCharacter === firstCharacter.toLowerCase()) || !lowercaseFirstCharacterOnly && description === description.toLowerCase()) return;
488
487
  context.report({
489
488
  messageId: lowercaseFirstCharacterOnly ? "lowerCaseTitle" : "fullyLowerCaseTitle",
490
489
  node: node.arguments[0],
@@ -542,8 +541,7 @@ const maxNestedDescribe = createEslintRule({
542
541
  create(context, [{ max }]) {
543
542
  const stack = [];
544
543
  function pushStack(node) {
545
- if (node.parent?.type !== "CallExpression")
546
- return;
544
+ if (node.parent?.type !== "CallExpression") return;
547
545
  if (node.parent.callee.type !== "Identifier" || node.parent.callee.name !== "describe")
548
546
  return;
549
547
  stack.push(0);
@@ -555,8 +553,7 @@ const maxNestedDescribe = createEslintRule({
555
553
  }
556
554
  }
557
555
  function popStack(node) {
558
- if (node.parent?.type !== "CallExpression")
559
- return;
556
+ if (node.parent?.type !== "CallExpression") return;
560
557
  if (node.parent.callee.type !== "Identifier" || node.parent.callee.name !== "describe")
561
558
  return;
562
559
  stack.pop();
@@ -682,8 +679,7 @@ const noFocusedTests = createEslintRule({
682
679
  }
683
680
  if (callee.type === "TaggedTemplateExpression") {
684
681
  const tagCall = callee.tag.type === "MemberExpression" ? callee.tag.object : null;
685
- if (!tagCall)
686
- return;
682
+ if (!tagCall) return;
687
683
  if (tagCall.type === "MemberExpression" && isTestOrDescribe(tagCall.object) && isOnly(tagCall.property)) {
688
684
  context.report({
689
685
  node: tagCall.property,
@@ -757,18 +753,6 @@ function parsePluginSettings(settings) {
757
753
  }
758
754
 
759
755
  const RULE_NAME$U = "expect-expect";
760
- function matchesAssertFunctionName(nodeName, patterns) {
761
- return patterns.some(
762
- (p) => new RegExp(
763
- `^${p.split(".").map((x) => {
764
- if (x === "**")
765
- return "[_a-z\\d\\.]*";
766
- return x.replace(/\*/gu, "[a-z\\d]*");
767
- }).join("\\.")}(\\.|$)`,
768
- "ui"
769
- ).test(nodeName)
770
- );
771
- }
772
756
  const expectExpect = createEslintRule({
773
757
  name: RULE_NAME$U,
774
758
  meta: {
@@ -801,8 +785,8 @@ const expectExpect = createEslintRule({
801
785
  create(context, [{ assertFunctionNames = ["expect"], additionalTestBlockFunctions = [] }]) {
802
786
  const unchecked = [];
803
787
  const settings = parsePluginSettings(context.settings);
804
- if (settings.typecheck)
805
- assertFunctionNames.push("expectTypeOf", "assertType");
788
+ if (settings.typecheck) assertFunctionNames.push("expectTypeOf", "assertType");
789
+ const assertFunctionRegexps = assertFunctionNames.map(buildPatternRegexp);
806
790
  function checkCallExpression(nodes) {
807
791
  for (const node of nodes) {
808
792
  const index = node.type === utils.AST_NODE_TYPES.CallExpression ? unchecked.indexOf(node) : -1;
@@ -827,10 +811,9 @@ const expectExpect = createEslintRule({
827
811
  return;
828
812
  const name = getNodeName(node) ?? "";
829
813
  if (isTypeOfVitestFnCall(node, context, ["test"]) || additionalTestBlockFunctions.includes(name)) {
830
- if (node.callee.type === utils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "todo"))
831
- return;
814
+ if (node.callee.type === utils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "todo")) return;
832
815
  unchecked.push(node);
833
- } else if (matchesAssertFunctionName(name, assertFunctionNames)) {
816
+ } else if (assertFunctionRegexps.some((p) => p.test(name))) {
834
817
  checkCallExpression(context.sourceCode.getAncestors(node));
835
818
  }
836
819
  },
@@ -845,6 +828,17 @@ const expectExpect = createEslintRule({
845
828
  };
846
829
  }
847
830
  });
831
+ function buildPatternRegexp(pattern) {
832
+ const parts = pattern.split(".").map((x) => {
833
+ if (x === "**")
834
+ return "[_a-z\\d\\.]*";
835
+ return x.replace(/\*/gu, "[a-z\\d]*");
836
+ });
837
+ return new RegExp(
838
+ `^${parts.join("\\.")}(\\.|$)`,
839
+ "ui"
840
+ );
841
+ }
848
842
 
849
843
  const RULE_NAME$T = "consistent-test-it";
850
844
  const buildFixer = (callee, nodeName, preferredTestKeyword) => (fixer) => [
@@ -910,6 +904,8 @@ const consistentTestIt = createEslintRule({
910
904
  for (const specifier of node.specifiers) {
911
905
  if (specifier.type !== "ImportSpecifier")
912
906
  continue;
907
+ if (specifier.imported.type !== "Identifier")
908
+ continue;
913
909
  if (specifier.local.name !== specifier.imported.name)
914
910
  continue;
915
911
  if (specifier.local.name === oppositeTestKeyword) {
@@ -929,8 +925,7 @@ const consistentTestIt = createEslintRule({
929
925
  if (node.callee.type === utils.AST_NODE_TYPES.Identifier && node.callee.name === "bench")
930
926
  return;
931
927
  const vitestFnCall = parseVitestFnCall(node, context);
932
- if (!vitestFnCall)
933
- return;
928
+ if (!vitestFnCall) return;
934
929
  if (vitestFnCall.type === "describe") {
935
930
  describeNestingLevel++;
936
931
  return;
@@ -1496,8 +1491,7 @@ const noDisabledTests = createEslintRule({
1496
1491
  return {
1497
1492
  CallExpression(node) {
1498
1493
  const vitestFnCall = parseVitestFnCall(node, context);
1499
- if (!vitestFnCall)
1500
- return;
1494
+ if (!vitestFnCall) return;
1501
1495
  if (vitestFnCall.type === "describe")
1502
1496
  suiteDepth++;
1503
1497
  if (vitestFnCall.type === "test") {
@@ -1577,16 +1571,13 @@ const noDoneCallback = createEslintRule({
1577
1571
  if (isVitestEach && node.callee.type !== utils.AST_NODE_TYPES.TaggedTemplateExpression)
1578
1572
  return;
1579
1573
  const isInsideConcurrentTestOrDescribe = context.sourceCode.getAncestors(node).some((ancestor) => {
1580
- if (ancestor.type !== utils.AST_NODE_TYPES.CallExpression)
1581
- return false;
1574
+ if (ancestor.type !== utils.AST_NODE_TYPES.CallExpression) return false;
1582
1575
  const isNotInsideDescribeOrTest = !isTypeOfVitestFnCall(ancestor, context, ["describe", "test"]);
1583
- if (isNotInsideDescribeOrTest)
1584
- return false;
1576
+ if (isNotInsideDescribeOrTest) return false;
1585
1577
  const isTestRunningConcurrently = ancestor.callee.type === utils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(ancestor.callee.property, "concurrent");
1586
1578
  return isTestRunningConcurrently;
1587
1579
  });
1588
- if (isInsideConcurrentTestOrDescribe)
1589
- return;
1580
+ if (isInsideConcurrentTestOrDescribe) return;
1590
1581
  const callback = findCallbackArg(node, isVitestEach, context);
1591
1582
  const callbackArgIndex = Number(isVitestEach);
1592
1583
  if (!callback || !isFunction(callback) || callback.params.length !== 1 + callbackArgIndex)
@@ -1673,14 +1664,13 @@ const noDuplicateHooks = createEslintRule({
1673
1664
  const hooksContexts = [{}];
1674
1665
  return {
1675
1666
  CallExpression(node) {
1676
- var _a;
1677
1667
  const vitestFnCall = parseVitestFnCall(node, context);
1678
1668
  if (vitestFnCall?.type === "describe")
1679
1669
  hooksContexts.push({});
1680
1670
  if (vitestFnCall?.type !== "hook")
1681
1671
  return;
1682
1672
  const currentLayer = hooksContexts[hooksContexts.length - 1];
1683
- currentLayer[_a = vitestFnCall.name] || (currentLayer[_a] = 0);
1673
+ currentLayer[vitestFnCall.name] ||= 0;
1684
1674
  currentLayer[vitestFnCall.name] += 1;
1685
1675
  if (currentLayer[vitestFnCall.name] > 1) {
1686
1676
  context.report({
@@ -2074,18 +2064,15 @@ const noTestReturnStatement = createEslintRule({
2074
2064
  return;
2075
2065
  const body = getBody(node.arguments);
2076
2066
  const returnStmt = body.find((stmt) => stmt.type === utils.AST_NODE_TYPES.ReturnStatement);
2077
- if (!returnStmt)
2078
- return;
2067
+ if (!returnStmt) return;
2079
2068
  context.report({ messageId: "noTestReturnStatement", node: returnStmt });
2080
2069
  },
2081
2070
  FunctionDeclaration(node) {
2082
2071
  const declaredVariables = context.sourceCode.getDeclaredVariables(node);
2083
2072
  const testCallExpressions = getTestCallExpressionsFromDeclaredVariables(declaredVariables, context);
2084
- if (testCallExpressions.length === 0)
2085
- return;
2073
+ if (testCallExpressions.length === 0) return;
2086
2074
  const returnStmt = node.body.body.find((stmt) => stmt.type === utils.AST_NODE_TYPES.ReturnStatement);
2087
- if (!returnStmt)
2088
- return;
2075
+ if (!returnStmt) return;
2089
2076
  context.report({ messageId: "noTestReturnStatement", node: returnStmt });
2090
2077
  }
2091
2078
  };
@@ -2112,8 +2099,7 @@ const preferCalledWith = createEslintRule({
2112
2099
  return {
2113
2100
  CallExpression(node) {
2114
2101
  const vitestFnCall = parseVitestFnCall(node, context);
2115
- if (vitestFnCall?.type !== "expect")
2116
- return;
2102
+ if (vitestFnCall?.type !== "expect") return;
2117
2103
  if (vitestFnCall.modifiers.some(
2118
2104
  (node2) => getAccessorValue(node2) === "not"
2119
2105
  ))
@@ -2156,8 +2142,7 @@ function isFunctionType(type) {
2156
2142
  }
2157
2143
  function isClassType(type) {
2158
2144
  const symbol = type.getSymbol();
2159
- if (!symbol)
2160
- return false;
2145
+ if (!symbol) return false;
2161
2146
  return symbol.getDeclarations()?.some((declaration) => ts__default.isClassDeclaration(declaration) || ts__default.isClassExpression(declaration)) ?? false;
2162
2147
  }
2163
2148
  const compileMatcherPatterns = (matchers) => {
@@ -2256,17 +2241,15 @@ const validTitle = createEslintRule({
2256
2241
  return {
2257
2242
  CallExpression(node) {
2258
2243
  const vitestFnCall = parseVitestFnCall(node, context);
2259
- if (vitestFnCall?.type !== "describe" && vitestFnCall?.type !== "test" && vitestFnCall?.type !== "it")
2260
- return;
2244
+ if (vitestFnCall?.type !== "describe" && vitestFnCall?.type !== "test" && vitestFnCall?.type !== "it") return;
2245
+ if (vitestFnCall.members.some((m) => m.type == utils.AST_NODE_TYPES.Identifier && m.name == "extend")) return;
2261
2246
  const [argument] = node.arguments;
2262
2247
  if (settings.typecheck) {
2263
2248
  const services = utils.ESLintUtils.getParserServices(context);
2264
2249
  const type = services.getTypeAtLocation(argument);
2265
- if (isFunctionType(type) || isClassType(type))
2266
- return;
2250
+ if (isFunctionType(type) || isClassType(type)) return;
2267
2251
  }
2268
- if (!argument || allowArguments && argument.type === utils.AST_NODE_TYPES.Identifier)
2269
- return;
2252
+ if (!argument || allowArguments && argument.type === utils.AST_NODE_TYPES.Identifier) return;
2270
2253
  if (!isStringNode(argument)) {
2271
2254
  if (argument.type === utils.AST_NODE_TYPES.BinaryExpression && doesBinaryExpressionContainStringNode(argument))
2272
2255
  return;
@@ -2500,6 +2483,8 @@ const validExpect = createEslintRule({
2500
2483
  return;
2501
2484
  } else if (vitestFnCall?.type !== "expect") {
2502
2485
  return;
2486
+ } else if (vitestFnCall.modifiers.some((mod) => mod.type === utils.AST_NODE_TYPES.Identifier && mod.name == "to")) {
2487
+ return;
2503
2488
  }
2504
2489
  const { parent: expect } = vitestFnCall.head.node;
2505
2490
  if (expect?.type !== utils.AST_NODE_TYPES.CallExpression)
@@ -2708,8 +2693,7 @@ const preferToBeTruthy = createEslintRule({
2708
2693
  return {
2709
2694
  CallExpression(node) {
2710
2695
  const vitestFnCall = parseVitestFnCall(node, context);
2711
- if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf"))
2712
- return;
2696
+ if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf")) return;
2713
2697
  if (vitestFnCall.args.length === 1 && isTrueLiteral(getFirstMatcherArg(vitestFnCall)) && EqualityMatcher.hasOwnProperty(getAccessorValue(vitestFnCall.matcher))) {
2714
2698
  context.report({
2715
2699
  node: vitestFnCall.matcher,
@@ -2746,8 +2730,7 @@ const preferToBeFalsy = createEslintRule({
2746
2730
  return {
2747
2731
  CallExpression(node) {
2748
2732
  const vitestFnCall = parseVitestFnCall(node, context);
2749
- if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf"))
2750
- return;
2733
+ if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf")) return;
2751
2734
  if (vitestFnCall.args.length === 1 && isFalseLiteral(getFirstMatcherArg(vitestFnCall)) && EqualityMatcher.hasOwnProperty(getAccessorValue(vitestFnCall.matcher))) {
2752
2735
  context.report({
2753
2736
  node: vitestFnCall.matcher,
@@ -2908,8 +2891,7 @@ const preferStrictEqual = createEslintRule({
2908
2891
  return {
2909
2892
  CallExpression(node) {
2910
2893
  const vitestFnCall = parseVitestFnCall(node, context);
2911
- if (vitestFnCall?.type !== "expect")
2912
- return;
2894
+ if (vitestFnCall?.type !== "expect") return;
2913
2895
  const { matcher } = vitestFnCall;
2914
2896
  if (isSupportedAccessor(matcher, "toEqual")) {
2915
2897
  context.report({
@@ -2949,8 +2931,7 @@ const preferExpectResolves = createEslintRule({
2949
2931
  create: (context) => ({
2950
2932
  CallExpression(node) {
2951
2933
  const vitestFnCall = parseVitestFnCall(node, context);
2952
- if (vitestFnCall?.type !== "expect")
2953
- return;
2934
+ if (vitestFnCall?.type !== "expect") return;
2954
2935
  const { parent } = vitestFnCall.head.node;
2955
2936
  if (parent?.type !== utils.AST_NODE_TYPES.CallExpression)
2956
2937
  return;
@@ -2999,13 +2980,11 @@ const preferEach = createEslintRule({
2999
2980
  return "describe";
3000
2981
  };
3001
2982
  const enterForLoop = () => {
3002
- if (vitestFnCalls.length === 0 || inTestCaseCall)
3003
- return;
2983
+ if (vitestFnCalls.length === 0 || inTestCaseCall) return;
3004
2984
  vitestFnCalls.length = 0;
3005
2985
  };
3006
2986
  const exitForLoop = (node) => {
3007
- if (vitestFnCalls.length === 0 || inTestCaseCall)
3008
- return;
2987
+ if (vitestFnCalls.length === 0 || inTestCaseCall) return;
3009
2988
  context.report({
3010
2989
  node,
3011
2990
  messageId: "preferEach",
@@ -3093,8 +3072,7 @@ const preferHooksInOrder = createEslintRule({
3093
3072
  let inHook = false;
3094
3073
  return {
3095
3074
  CallExpression(node) {
3096
- if (inHook)
3097
- return;
3075
+ if (inHook) return;
3098
3076
  const vitestFnCall = parseVitestFnCall(node, context);
3099
3077
  if (vitestFnCall?.type !== "hook") {
3100
3078
  previousHookIndex = -1;
@@ -3158,8 +3136,7 @@ const preferMockPromiseShorthand = createEslintRule({
3158
3136
  defaultOptions: [],
3159
3137
  create(context) {
3160
3138
  const report = (property, isOnce, outerArgNode, innerArgNode = outerArgNode) => {
3161
- if (innerArgNode?.type !== utils.AST_NODE_TYPES.CallExpression)
3162
- return;
3139
+ if (innerArgNode?.type !== utils.AST_NODE_TYPES.CallExpression) return;
3163
3140
  const argName = getNodeName(innerArgNode);
3164
3141
  if (argName !== "Promise.resolve" && argName !== "Promise.reject")
3165
3142
  return;
@@ -3203,7 +3180,7 @@ const preferMockPromiseShorthand = createEslintRule({
3203
3180
  }
3204
3181
  });
3205
3182
 
3206
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
3183
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
3207
3184
  const eslintRequire = node_module.createRequire(require$1.resolve("eslint"));
3208
3185
  eslintRequire.resolve("espree");
3209
3186
  const STATEMENT_LIST_PARENTS = /* @__PURE__ */ new Set([
@@ -3265,13 +3242,10 @@ const preferViMocked = createEslintRule({
3265
3242
  create(context) {
3266
3243
  function check(node) {
3267
3244
  const { typeAnnotation } = node;
3268
- if (typeAnnotation.type !== utils.AST_NODE_TYPES.TSTypeReference)
3269
- return;
3245
+ if (typeAnnotation.type !== utils.AST_NODE_TYPES.TSTypeReference) return;
3270
3246
  const { typeName } = typeAnnotation;
3271
- if (typeName.type !== utils.AST_NODE_TYPES.Identifier)
3272
- return;
3273
- if (!mockTypes.includes(typeName.name))
3274
- return;
3247
+ if (typeName.type !== utils.AST_NODE_TYPES.Identifier) return;
3248
+ if (!mockTypes.includes(typeName.name)) return;
3275
3249
  const fnName = context.sourceCode.text.slice(
3276
3250
  ...followTypeAssertionChain(node.expression).range
3277
3251
  );
@@ -3285,8 +3259,7 @@ const preferViMocked = createEslintRule({
3285
3259
  }
3286
3260
  return {
3287
3261
  TSAsExpression(node) {
3288
- if (node.parent.type === utils.AST_NODE_TYPES.TSAsExpression)
3289
- return;
3262
+ if (node.parent.type === utils.AST_NODE_TYPES.TSAsExpression) return;
3290
3263
  check(node);
3291
3264
  },
3292
3265
  TSTypeAssertion(node) {
@@ -3300,12 +3273,10 @@ const RULE_NAME$j = "prefer-snapshot-hint";
3300
3273
  const snapshotMatchers = ["toMatchSnapshot", "toThrowErrorMatchingSnapshot"];
3301
3274
  const snapshotMatcherNames = snapshotMatchers;
3302
3275
  const isSnapshotMatcherWithoutHint = (expectFnCall) => {
3303
- if (expectFnCall.args.length === 0)
3304
- return true;
3276
+ if (expectFnCall.args.length === 0) return true;
3305
3277
  if (!isSupportedAccessor(expectFnCall.matcher, "toMatchSnapshot"))
3306
3278
  return expectFnCall.args.length !== 1;
3307
- if (expectFnCall.args.length === 2)
3308
- return false;
3279
+ if (expectFnCall.args.length === 2) return false;
3309
3280
  const [arg] = expectFnCall.args;
3310
3281
  return !isStringNode(arg);
3311
3282
  };
@@ -3380,8 +3351,7 @@ const preferSnapshotHint = createEslintRule({
3380
3351
  return;
3381
3352
  }
3382
3353
  const matcherName = getAccessorValue(vitestFnCall.matcher);
3383
- if (!snapshotMatcherNames.includes(matcherName))
3384
- return;
3354
+ if (!snapshotMatcherNames.includes(matcherName)) return;
3385
3355
  snapshotMatchers2.push(vitestFnCall);
3386
3356
  }
3387
3357
  };
@@ -3402,8 +3372,7 @@ const hasNonEachMembersAndParams = (vitestFnCall, functionExpression) => {
3402
3372
  };
3403
3373
  const reportUnexpectedReturnInDescribe = (blockStatement, context) => {
3404
3374
  blockStatement.body.forEach((node) => {
3405
- if (node.type !== utils.AST_NODE_TYPES.ReturnStatement)
3406
- return;
3375
+ if (node.type !== utils.AST_NODE_TYPES.ReturnStatement) return;
3407
3376
  context.report({
3408
3377
  messageId: "unexpectedReturnInDescribe",
3409
3378
  node
@@ -3431,8 +3400,7 @@ const validDescribeCallback = createEslintRule({
3431
3400
  return {
3432
3401
  CallExpression(node) {
3433
3402
  const vitestFnCall = parseVitestFnCall(node, context);
3434
- if (vitestFnCall?.type !== "describe")
3435
- return;
3403
+ if (vitestFnCall?.type !== "describe") return;
3436
3404
  if (vitestFnCall?.members[0]?.type === utils.AST_NODE_TYPES.Identifier && vitestFnCall.members[0].name === "todo")
3437
3405
  return;
3438
3406
  if (node.arguments.length < 1) {
@@ -3529,8 +3497,7 @@ const requireTopLevelDescribe = createEslintRule({
3529
3497
  return {
3530
3498
  CallExpression(node) {
3531
3499
  const vitestFnCall = parseVitestFnCall(node, context);
3532
- if (!vitestFnCall)
3533
- return;
3500
+ if (!vitestFnCall) return;
3534
3501
  if (vitestFnCall.type === "describe") {
3535
3502
  numberOfDescribeBlocks++;
3536
3503
  if (numberOfDescribeBlocks === 1) {
@@ -3584,8 +3551,7 @@ const requireToThrowMessage = createEslintRule({
3584
3551
  return {
3585
3552
  CallExpression(node) {
3586
3553
  const vitestFnCall = parseVitestFnCall(node, context);
3587
- if (vitestFnCall?.type !== "expect")
3588
- return;
3554
+ if (vitestFnCall?.type !== "expect") return;
3589
3555
  const { matcher } = vitestFnCall;
3590
3556
  const matcherName = getAccessorValue(matcher);
3591
3557
  if (vitestFnCall.args.length === 0 && ["toThrow", "toThrowError"].includes(matcherName) && !vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not")) {
@@ -3672,11 +3638,9 @@ const requireHook = createEslintRule({
3672
3638
  checkBlockBody(program.body);
3673
3639
  },
3674
3640
  CallExpression(node) {
3675
- if (!isTypeOfVitestFnCall(node, context, ["describe"]) || node.arguments.length < 2)
3676
- return;
3641
+ if (!isTypeOfVitestFnCall(node, context, ["describe"]) || node.arguments.length < 2) return;
3677
3642
  const [, testFn] = node.arguments;
3678
- if (!isFunction(testFn) || testFn.body.type !== utils.AST_NODE_TYPES.BlockStatement)
3679
- return;
3643
+ if (!isFunction(testFn) || testFn.body.type !== utils.AST_NODE_TYPES.BlockStatement) return;
3680
3644
  checkBlockBody(testFn.body.body);
3681
3645
  }
3682
3646
  };
@@ -3716,19 +3680,15 @@ const requireLocalTestContextForConcurrentSnapshots = createEslintRule({
3716
3680
  "toThrowErrorMatchingInlineSnapshot"
3717
3681
  // @ts-ignore
3718
3682
  ].includes(node.callee?.property.name);
3719
- if (isNotASnapshotAssertion)
3720
- return;
3683
+ if (isNotASnapshotAssertion) return;
3721
3684
  const isInsideSequentialDescribeOrTest = !context.sourceCode.getAncestors(node).some((ancestor) => {
3722
- if (ancestor.type !== utils.AST_NODE_TYPES.CallExpression)
3723
- return false;
3685
+ if (ancestor.type !== utils.AST_NODE_TYPES.CallExpression) return false;
3724
3686
  const isNotInsideDescribeOrTest = !isTypeOfVitestFnCall(ancestor, context, ["describe", "test"]);
3725
- if (isNotInsideDescribeOrTest)
3726
- return false;
3687
+ if (isNotInsideDescribeOrTest) return false;
3727
3688
  const isTestRunningConcurrently = ancestor.callee.type === utils.AST_NODE_TYPES.MemberExpression && isSupportedAccessor(ancestor.callee.property, "concurrent");
3728
3689
  return isTestRunningConcurrently;
3729
3690
  });
3730
- if (isInsideSequentialDescribeOrTest)
3731
- return;
3691
+ if (isInsideSequentialDescribeOrTest) return;
3732
3692
  context.report({
3733
3693
  node,
3734
3694
  messageId: "requireLocalTestContext"
@@ -3740,8 +3700,7 @@ const requireLocalTestContextForConcurrentSnapshots = createEslintRule({
3740
3700
 
3741
3701
  const RULE_NAME$d = "prefer-todo";
3742
3702
  const isTargetedTestCase = (vitestFnCall) => {
3743
- if (vitestFnCall.members.some((s) => getAccessorValue(s) !== "skip"))
3744
- return false;
3703
+ if (vitestFnCall.members.some((s) => getAccessorValue(s) !== "skip")) return false;
3745
3704
  if (vitestFnCall.name.startsWith("x"))
3746
3705
  return false;
3747
3706
  return !vitestFnCall.name.startsWith("f");
@@ -3847,11 +3806,9 @@ const preferSpyOn = createEslintRule({
3847
3806
  return {
3848
3807
  AssignmentExpression(node) {
3849
3808
  const { left, right } = node;
3850
- if (left.type !== utils.AST_NODE_TYPES.MemberExpression)
3851
- return;
3809
+ if (left.type !== utils.AST_NODE_TYPES.MemberExpression) return;
3852
3810
  const vitestFnCall = getVitestFnCall(right);
3853
- if (!vitestFnCall)
3854
- return;
3811
+ if (!vitestFnCall) return;
3855
3812
  context.report({
3856
3813
  node,
3857
3814
  messageId: "useViSpayOn",
@@ -3932,8 +3889,7 @@ const preferComparisonMatcher = createEslintRule({
3932
3889
  if (vitestFnCall?.type !== "expect" || vitestFnCall.args.length === 0)
3933
3890
  return;
3934
3891
  const { parent: expect } = vitestFnCall.head.node;
3935
- if (expect?.type !== utils.AST_NODE_TYPES.CallExpression)
3936
- return;
3892
+ if (expect?.type !== utils.AST_NODE_TYPES.CallExpression) return;
3937
3893
  const {
3938
3894
  arguments: [comparison],
3939
3895
  range: [, expectCallEnd]
@@ -3945,8 +3901,7 @@ const preferComparisonMatcher = createEslintRule({
3945
3901
  const [modifier] = vitestFnCall.modifiers;
3946
3902
  const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
3947
3903
  const preferredMatcher = determineMatcher(comparison.operator, matcherArg.value === hasNot);
3948
- if (!preferredMatcher)
3949
- return;
3904
+ if (!preferredMatcher) return;
3950
3905
  context.report({
3951
3906
  fix(fixer) {
3952
3907
  const { sourceCode } = context;
@@ -3999,8 +3954,7 @@ const preferToContain = createEslintRule({
3999
3954
  if (vitestFnCall?.type !== "expect" || vitestFnCall.args.length === 0)
4000
3955
  return;
4001
3956
  const { parent: expect } = vitestFnCall.head.node;
4002
- if (expect?.type !== utils.AST_NODE_TYPES.CallExpression)
4003
- return;
3957
+ if (expect?.type !== utils.AST_NODE_TYPES.CallExpression) return;
4004
3958
  const {
4005
3959
  arguments: [includesCall],
4006
3960
  range: [, expectCallEnd]
@@ -4248,8 +4202,7 @@ var StatementType = /* @__PURE__ */ ((StatementType2) => {
4248
4202
  const paddingAlwaysTester = (prevNode, nextNode, paddingContext) => {
4249
4203
  const { sourceCode, ruleContext } = paddingContext;
4250
4204
  const paddingLines = getPaddingLineSequences(prevNode, nextNode, sourceCode);
4251
- if (paddingLines.length > 0)
4252
- return;
4205
+ if (paddingLines.length > 0) return;
4253
4206
  ruleContext.report({
4254
4207
  node: nextNode,
4255
4208
  messageId: "missingPadding",
@@ -4364,8 +4317,7 @@ const testPadding = (prevNode, nextNode, paddingContext) => {
4364
4317
  };
4365
4318
  const verifyNode = (node, paddingContext) => {
4366
4319
  const { scopeInfo } = paddingContext;
4367
- if (!isValidParent(node?.parent.type))
4368
- return;
4320
+ if (!isValidParent(node?.parent.type)) return;
4369
4321
  if (scopeInfo.prevNode) {
4370
4322
  testPadding(scopeInfo.prevNode, node, paddingContext);
4371
4323
  }
@@ -4995,48 +4947,6 @@ const plugin = {
4995
4947
  [RULE_NAME$2]: paddingAroundTestBlocks,
4996
4948
  [RULE_NAME]: validExpectInPromise
4997
4949
  },
4998
- configs: {
4999
- "legacy-recommended": createConfigLegacy(recommended),
5000
- "legacy-all": createConfigLegacy(allRules),
5001
- "recommended": {
5002
- plugins: {
5003
- get vitest() {
5004
- return plugin;
5005
- }
5006
- },
5007
- rules: createConfig(recommended)
5008
- },
5009
- "all": {
5010
- plugins: {
5011
- get vitest() {
5012
- return plugin;
5013
- }
5014
- },
5015
- rules: createConfig(allRules)
5016
- },
5017
- "env": {
5018
- languageOptions: {
5019
- globals: {
5020
- suite: "writable",
5021
- test: "writable",
5022
- describe: "writable",
5023
- it: "writable",
5024
- expectTypeOf: "writable",
5025
- assertType: "writable",
5026
- expect: "writable",
5027
- assert: "writable",
5028
- vitest: "writable",
5029
- vi: "writable",
5030
- beforeAll: "writable",
5031
- afterAll: "writable",
5032
- beforeEach: "writable",
5033
- afterEach: "writable",
5034
- onTestFailed: "writable",
5035
- onTestFinished: "writable"
5036
- }
5037
- }
5038
- }
5039
- },
5040
4950
  environments: {
5041
4951
  env: {
5042
4952
  globals: {
@@ -5060,5 +4970,43 @@ const plugin = {
5060
4970
  }
5061
4971
  }
5062
4972
  };
4973
+ plugin.configs = {
4974
+ "legacy-recommended": createConfigLegacy(recommended),
4975
+ "legacy-all": createConfigLegacy(allRules),
4976
+ "recommended": {
4977
+ plugins: {
4978
+ ["vitest"]: plugin
4979
+ },
4980
+ rules: createConfig(recommended)
4981
+ },
4982
+ "all": {
4983
+ plugins: {
4984
+ ["vitest"]: plugin
4985
+ },
4986
+ rules: createConfig(allRules)
4987
+ },
4988
+ "env": {
4989
+ languageOptions: {
4990
+ globals: {
4991
+ suite: "writable",
4992
+ test: "writable",
4993
+ describe: "writable",
4994
+ it: "writable",
4995
+ expectTypeOf: "writable",
4996
+ assertType: "writable",
4997
+ expect: "writable",
4998
+ assert: "writable",
4999
+ vitest: "writable",
5000
+ vi: "writable",
5001
+ beforeAll: "writable",
5002
+ afterAll: "writable",
5003
+ beforeEach: "writable",
5004
+ afterEach: "writable",
5005
+ onTestFailed: "writable",
5006
+ onTestFinished: "writable"
5007
+ }
5008
+ }
5009
+ }
5010
+ };
5063
5011
 
5064
5012
  module.exports = plugin;