@vitest/eslint-plugin 1.1.4 → 1.1.6

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 ts from 'typescript';
5
5
  import { createRequire } from 'node:module';
6
6
 
7
- const version = "1.1.3";
7
+ const version = "1.1.5";
8
8
 
9
9
  function createEslintRule(rule) {
10
10
  const createRule = ESLintUtils.RuleCreator(
@@ -341,12 +341,12 @@ const getFirstMatcherArg = (expectFnCall) => {
341
341
  const [firstArg] = expectFnCall.args;
342
342
  if (firstArg.type === AST_NODE_TYPES.SpreadElement)
343
343
  return firstArg;
344
- return followTypeAssertionChain(firstArg);
344
+ return followTypeAssertionChain$1(firstArg);
345
345
  };
346
- const isTypeCastExpression = (node) => node.type === AST_NODE_TYPES.TSAsExpression || node.type === AST_NODE_TYPES.TSTypeAssertion;
347
- const followTypeAssertionChain = (expression) => isTypeCastExpression(expression) ? followTypeAssertionChain(expression.expression) : expression;
346
+ const isTypeCastExpression$1 = (node) => node.type === AST_NODE_TYPES.TSAsExpression || node.type === AST_NODE_TYPES.TSTypeAssertion;
347
+ const followTypeAssertionChain$1 = (expression) => isTypeCastExpression$1(expression) ? followTypeAssertionChain$1(expression.expression) : expression;
348
348
 
349
- const RULE_NAME$X = "prefer-lowercase-title";
349
+ const RULE_NAME$Y = "prefer-lowercase-title";
350
350
  const hasStringAsFirstArgument = (node) => node.arguments[0] && isStringNode(node.arguments[0]);
351
351
  const populateIgnores = (ignore) => {
352
352
  const ignores = [];
@@ -365,7 +365,7 @@ const populateIgnores = (ignore) => {
365
365
  return ignores;
366
366
  };
367
367
  const lowerCaseTitle = createEslintRule({
368
- name: RULE_NAME$X,
368
+ name: RULE_NAME$Y,
369
369
  meta: {
370
370
  type: "problem",
371
371
  docs: {
@@ -462,9 +462,9 @@ const lowerCaseTitle = createEslintRule({
462
462
  }
463
463
  });
464
464
 
465
- const RULE_NAME$W = "max-nested-describe";
465
+ const RULE_NAME$X = "max-nested-describe";
466
466
  const maxNestedDescribe = createEslintRule({
467
- name: RULE_NAME$W,
467
+ name: RULE_NAME$X,
468
468
  meta: {
469
469
  type: "problem",
470
470
  docs: {
@@ -522,13 +522,13 @@ const maxNestedDescribe = createEslintRule({
522
522
  }
523
523
  });
524
524
 
525
- const RULE_NAME$V = "no-identical-title";
525
+ const RULE_NAME$W = "no-identical-title";
526
526
  const newDescribeContext = () => ({
527
527
  describeTitles: [],
528
528
  testTitles: []
529
529
  });
530
530
  const noIdenticalTitle = createEslintRule({
531
- name: RULE_NAME$V,
531
+ name: RULE_NAME$W,
532
532
  meta: {
533
533
  type: "problem",
534
534
  docs: {
@@ -586,7 +586,7 @@ const noIdenticalTitle = createEslintRule({
586
586
  }
587
587
  });
588
588
 
589
- const RULE_NAME$U = "no-focused-tests";
589
+ const RULE_NAME$V = "no-focused-tests";
590
590
  const isTestOrDescribe = (node) => {
591
591
  return node.type === "Identifier" && ["it", "test", "describe"].includes(node.name);
592
592
  };
@@ -594,7 +594,7 @@ const isOnly = (node) => {
594
594
  return node.type === "Identifier" && node.name === "only";
595
595
  };
596
596
  const noFocusedTests = createEslintRule({
597
- name: RULE_NAME$U,
597
+ name: RULE_NAME$V,
598
598
  meta: {
599
599
  type: "problem",
600
600
  docs: {
@@ -666,9 +666,9 @@ const noFocusedTests = createEslintRule({
666
666
  }
667
667
  });
668
668
 
669
- const RULE_NAME$T = "no-conditional-tests";
669
+ const RULE_NAME$U = "no-conditional-tests";
670
670
  const noConditionalTest = createEslintRule({
671
- name: RULE_NAME$T,
671
+ name: RULE_NAME$U,
672
672
  meta: {
673
673
  type: "problem",
674
674
  docs: {
@@ -708,7 +708,7 @@ function parsePluginSettings(settings) {
708
708
  };
709
709
  }
710
710
 
711
- const RULE_NAME$S = "expect-expect";
711
+ const RULE_NAME$T = "expect-expect";
712
712
  function matchesAssertFunctionName(nodeName, patterns) {
713
713
  return patterns.some(
714
714
  (p) => new RegExp(
@@ -722,7 +722,7 @@ function matchesAssertFunctionName(nodeName, patterns) {
722
722
  );
723
723
  }
724
724
  const expectExpect = createEslintRule({
725
- name: RULE_NAME$S,
725
+ name: RULE_NAME$T,
726
726
  meta: {
727
727
  type: "suggestion",
728
728
  docs: {
@@ -798,7 +798,7 @@ const expectExpect = createEslintRule({
798
798
  }
799
799
  });
800
800
 
801
- const RULE_NAME$R = "consistent-test-it";
801
+ const RULE_NAME$S = "consistent-test-it";
802
802
  const buildFixer = (callee, nodeName, preferredTestKeyword) => (fixer) => [
803
803
  fixer.replaceText(
804
804
  callee.type === AST_NODE_TYPES.MemberExpression ? callee.object : callee,
@@ -816,7 +816,7 @@ function getOppositeTestKeyword(test) {
816
816
  return TestCaseName.test;
817
817
  }
818
818
  const consistentTestIt = createEslintRule({
819
- name: RULE_NAME$R,
819
+ name: RULE_NAME$S,
820
820
  meta: {
821
821
  type: "suggestion",
822
822
  fixable: "code",
@@ -914,7 +914,7 @@ const consistentTestIt = createEslintRule({
914
914
  }
915
915
  });
916
916
 
917
- const RULE_NAME$Q = "prefer-to-be";
917
+ const RULE_NAME$R = "prefer-to-be";
918
918
  const isNullLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === null;
919
919
  const isNullEqualityMatcher = (expectFnCall) => isNullLiteral(getFirstMatcherArg(expectFnCall));
920
920
  const isFirstArgumentIdentifier = (expectFnCall, name) => isIdentifier(getFirstMatcherArg(expectFnCall), name);
@@ -950,7 +950,7 @@ const reportPreferToBe = (context, whatToBe, expectFnCall, func, modifierNode) =
950
950
  });
951
951
  };
952
952
  const preferToBe = createEslintRule({
953
- name: RULE_NAME$Q,
953
+ name: RULE_NAME$R,
954
954
  meta: {
955
955
  type: "suggestion",
956
956
  docs: {
@@ -1002,9 +1002,9 @@ const preferToBe = createEslintRule({
1002
1002
  }
1003
1003
  });
1004
1004
 
1005
- const RULE_NAME$P = "no-hooks";
1005
+ const RULE_NAME$Q = "no-hooks";
1006
1006
  const noHooks = createEslintRule({
1007
- name: RULE_NAME$P,
1007
+ name: RULE_NAME$Q,
1008
1008
  meta: {
1009
1009
  type: "suggestion",
1010
1010
  docs: {
@@ -1043,9 +1043,9 @@ const noHooks = createEslintRule({
1043
1043
  }
1044
1044
  });
1045
1045
 
1046
- const RULE_NAME$O = "no-restricted-vi-methods";
1046
+ const RULE_NAME$P = "no-restricted-vi-methods";
1047
1047
  const noRestrictedViMethods = createEslintRule({
1048
- name: RULE_NAME$O,
1048
+ name: RULE_NAME$P,
1049
1049
  meta: {
1050
1050
  type: "suggestion",
1051
1051
  docs: {
@@ -1085,11 +1085,11 @@ const noRestrictedViMethods = createEslintRule({
1085
1085
  }
1086
1086
  });
1087
1087
 
1088
- const RULE_NAME$N = "consistent-test-filename";
1088
+ const RULE_NAME$O = "consistent-test-filename";
1089
1089
  const defaultPattern = /.*\.test\.[tj]sx?$/;
1090
1090
  const defaultTestsPattern = /.*\.(test|spec)\.[tj]sx?$/;
1091
1091
  const consistentTestFilename = createEslintRule({
1092
- name: RULE_NAME$N,
1092
+ name: RULE_NAME$O,
1093
1093
  meta: {
1094
1094
  type: "problem",
1095
1095
  docs: {
@@ -1144,9 +1144,9 @@ const consistentTestFilename = createEslintRule({
1144
1144
  }
1145
1145
  });
1146
1146
 
1147
- const RULE_NAME$M = "max-expects";
1147
+ const RULE_NAME$N = "max-expects";
1148
1148
  const maxExpect = createEslintRule({
1149
- name: RULE_NAME$M,
1149
+ name: RULE_NAME$N,
1150
1150
  meta: {
1151
1151
  docs: {
1152
1152
  requiresTypeChecking: false,
@@ -1202,9 +1202,9 @@ const maxExpect = createEslintRule({
1202
1202
  }
1203
1203
  });
1204
1204
 
1205
- const RULE_NAME$L = "no-alias-methods";
1205
+ const RULE_NAME$M = "no-alias-methods";
1206
1206
  const noAliasMethod = createEslintRule({
1207
- name: RULE_NAME$L,
1207
+ name: RULE_NAME$M,
1208
1208
  meta: {
1209
1209
  docs: {
1210
1210
  description: "disallow alias methods",
@@ -1254,12 +1254,12 @@ const noAliasMethod = createEslintRule({
1254
1254
  }
1255
1255
  });
1256
1256
 
1257
- const RULE_NAME$K = "no-commented-out-tests";
1257
+ const RULE_NAME$L = "no-commented-out-tests";
1258
1258
  function hasTests(node) {
1259
1259
  return /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu.test(node.value);
1260
1260
  }
1261
1261
  const noCommentedOutTests = createEslintRule({
1262
- name: RULE_NAME$K,
1262
+ name: RULE_NAME$L,
1263
1263
  meta: {
1264
1264
  docs: {
1265
1265
  description: "disallow commented out tests",
@@ -1289,10 +1289,10 @@ const noCommentedOutTests = createEslintRule({
1289
1289
  }
1290
1290
  });
1291
1291
 
1292
- const RULE_NAME$J = "no-conditional-expect";
1292
+ const RULE_NAME$K = "no-conditional-expect";
1293
1293
  const isCatchCall = (node) => node.callee.type === AST_NODE_TYPES.MemberExpression && isSupportedAccessor(node.callee.property, "catch");
1294
1294
  const noConditionalExpect = createEslintRule({
1295
- name: RULE_NAME$J,
1295
+ name: RULE_NAME$K,
1296
1296
  meta: {
1297
1297
  type: "problem",
1298
1298
  docs: {
@@ -1358,9 +1358,9 @@ const noConditionalExpect = createEslintRule({
1358
1358
  }
1359
1359
  });
1360
1360
 
1361
- const RULE_NAME$I = "no-import-node-test";
1361
+ const RULE_NAME$J = "no-import-node-test";
1362
1362
  const noImportNodeTest = createEslintRule({
1363
- name: RULE_NAME$I,
1363
+ name: RULE_NAME$J,
1364
1364
  meta: {
1365
1365
  docs: {
1366
1366
  description: "disallow importing `node:test`",
@@ -1392,9 +1392,9 @@ const noImportNodeTest = createEslintRule({
1392
1392
  }
1393
1393
  });
1394
1394
 
1395
- const RULE_NAME$H = "no-conditional-in-test";
1395
+ const RULE_NAME$I = "no-conditional-in-test";
1396
1396
  const noConditionalInTest = createEslintRule({
1397
- name: RULE_NAME$H,
1397
+ name: RULE_NAME$I,
1398
1398
  meta: {
1399
1399
  docs: {
1400
1400
  description: "disallow conditional tests",
@@ -1422,9 +1422,9 @@ const noConditionalInTest = createEslintRule({
1422
1422
  }
1423
1423
  });
1424
1424
 
1425
- const RULE_NAME$G = "no-disabled-tests";
1425
+ const RULE_NAME$H = "no-disabled-tests";
1426
1426
  const noDisabledTests = createEslintRule({
1427
- name: RULE_NAME$G,
1427
+ name: RULE_NAME$H,
1428
1428
  meta: {
1429
1429
  type: "suggestion",
1430
1430
  docs: {
@@ -1493,7 +1493,7 @@ const noDisabledTests = createEslintRule({
1493
1493
  }
1494
1494
  });
1495
1495
 
1496
- const RULE_NAME$F = "no-done-callback";
1496
+ const RULE_NAME$G = "no-done-callback";
1497
1497
  const findCallbackArg = (node, isVitestEach, context) => {
1498
1498
  if (isVitestEach)
1499
1499
  return node.arguments[1];
@@ -1505,7 +1505,7 @@ const findCallbackArg = (node, isVitestEach, context) => {
1505
1505
  return null;
1506
1506
  };
1507
1507
  const noDoneCallback = createEslintRule({
1508
- name: RULE_NAME$F,
1508
+ name: RULE_NAME$G,
1509
1509
  meta: {
1510
1510
  type: "suggestion",
1511
1511
  docs: {
@@ -1605,9 +1605,9 @@ const noDoneCallback = createEslintRule({
1605
1605
  }
1606
1606
  });
1607
1607
 
1608
- const RULE_NAME$E = "no-duplicate-hooks";
1608
+ const RULE_NAME$F = "no-duplicate-hooks";
1609
1609
  const noDuplicateHooks = createEslintRule({
1610
- name: RULE_NAME$E,
1610
+ name: RULE_NAME$F,
1611
1611
  meta: {
1612
1612
  docs: {
1613
1613
  recommended: false,
@@ -1650,7 +1650,7 @@ const noDuplicateHooks = createEslintRule({
1650
1650
  }
1651
1651
  });
1652
1652
 
1653
- const RULE_NAME$D = "no-large-snapshots";
1653
+ const RULE_NAME$E = "no-large-snapshots";
1654
1654
  const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnapshots = {} }) => {
1655
1655
  const startLine = node.loc.start.line;
1656
1656
  const endLine = node.loc.end.line;
@@ -1683,7 +1683,7 @@ const reportOnViolation = (context, node, { maxSize: lineLimit = 50, allowedSnap
1683
1683
  }
1684
1684
  };
1685
1685
  const noLargeSnapshots = createEslintRule({
1686
- name: RULE_NAME$D,
1686
+ name: RULE_NAME$E,
1687
1687
  meta: {
1688
1688
  docs: {
1689
1689
  description: "disallow large snapshots",
@@ -1741,9 +1741,9 @@ const noLargeSnapshots = createEslintRule({
1741
1741
  }
1742
1742
  });
1743
1743
 
1744
- const RULE_NAME$C = "no-interpolation-in-snapshots";
1744
+ const RULE_NAME$D = "no-interpolation-in-snapshots";
1745
1745
  const nonInterpolationInSnapShots = createEslintRule({
1746
- name: RULE_NAME$C,
1746
+ name: RULE_NAME$D,
1747
1747
  meta: {
1748
1748
  type: "problem",
1749
1749
  docs: {
@@ -1784,9 +1784,9 @@ const nonInterpolationInSnapShots = createEslintRule({
1784
1784
  const mocksDirName = "__mocks__";
1785
1785
  const isMockPath = (path) => path.split(posix.sep).includes(mocksDirName);
1786
1786
  const isMockImportLiteral = (expression) => isStringNode(expression) && isMockPath(getStringValue(expression));
1787
- const RULE_NAME$B = "no-mocks-import";
1787
+ const RULE_NAME$C = "no-mocks-import";
1788
1788
  const noMocksImport = createEslintRule({
1789
- name: RULE_NAME$B,
1789
+ name: RULE_NAME$C,
1790
1790
  meta: {
1791
1791
  type: "problem",
1792
1792
  docs: {
@@ -1814,14 +1814,14 @@ const noMocksImport = createEslintRule({
1814
1814
  }
1815
1815
  });
1816
1816
 
1817
- const RULE_NAME$A = "no-restricted-matchers";
1817
+ const RULE_NAME$B = "no-restricted-matchers";
1818
1818
  const isChainRestricted = (chain, restriction) => {
1819
1819
  if (ModifierName.hasOwnProperty(restriction) || restriction.endsWith(".not"))
1820
1820
  return chain.startsWith(restriction);
1821
1821
  return chain === restriction;
1822
1822
  };
1823
1823
  const noRestrictedMatchers = createEslintRule({
1824
- name: RULE_NAME$A,
1824
+ name: RULE_NAME$B,
1825
1825
  meta: {
1826
1826
  docs: {
1827
1827
  description: "disallow the use of certain matchers",
@@ -1867,7 +1867,7 @@ const noRestrictedMatchers = createEslintRule({
1867
1867
  }
1868
1868
  });
1869
1869
 
1870
- const RULE_NAME$z = "no-standalone-expect";
1870
+ const RULE_NAME$A = "no-standalone-expect";
1871
1871
  const getBlockType = (statement, context) => {
1872
1872
  const func = statement.parent;
1873
1873
  if (!func)
@@ -1884,7 +1884,7 @@ const getBlockType = (statement, context) => {
1884
1884
  return null;
1885
1885
  };
1886
1886
  const noStandaloneExpect = createEslintRule({
1887
- name: RULE_NAME$z,
1887
+ name: RULE_NAME$A,
1888
1888
  meta: {
1889
1889
  docs: {
1890
1890
  description: "disallow using `expect` outside of `it` or `test` blocks",
@@ -1957,9 +1957,9 @@ const noStandaloneExpect = createEslintRule({
1957
1957
  }
1958
1958
  });
1959
1959
 
1960
- const RULE_NAME$y = "no-test-prefixes";
1960
+ const RULE_NAME$z = "no-test-prefixes";
1961
1961
  const noTestPrefixes = createEslintRule({
1962
- name: RULE_NAME$y,
1962
+ name: RULE_NAME$z,
1963
1963
  meta: {
1964
1964
  docs: {
1965
1965
  description: "disallow using `test` as a prefix",
@@ -1998,7 +1998,7 @@ const noTestPrefixes = createEslintRule({
1998
1998
  }
1999
1999
  });
2000
2000
 
2001
- const RULE_NAME$x = "no-test-return-statement";
2001
+ const RULE_NAME$y = "no-test-return-statement";
2002
2002
  const getBody = (args) => {
2003
2003
  const [, secondArg] = args;
2004
2004
  if (secondArg && isFunction(secondArg) && secondArg.body.type === AST_NODE_TYPES.BlockStatement)
@@ -2006,7 +2006,7 @@ const getBody = (args) => {
2006
2006
  return [];
2007
2007
  };
2008
2008
  const noTestReturnStatement = createEslintRule({
2009
- name: RULE_NAME$x,
2009
+ name: RULE_NAME$y,
2010
2010
  meta: {
2011
2011
  type: "problem",
2012
2012
  docs: {
@@ -2044,9 +2044,9 @@ const noTestReturnStatement = createEslintRule({
2044
2044
  }
2045
2045
  });
2046
2046
 
2047
- const RULE_NAME$w = "prefer-called-with";
2047
+ const RULE_NAME$x = "prefer-called-with";
2048
2048
  const preferCalledWith = createEslintRule({
2049
- name: RULE_NAME$w,
2049
+ name: RULE_NAME$x,
2050
2050
  meta: {
2051
2051
  docs: {
2052
2052
  description: "enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`",
@@ -2085,7 +2085,7 @@ const preferCalledWith = createEslintRule({
2085
2085
  }
2086
2086
  });
2087
2087
 
2088
- const RULE_NAME$v = "valid-title";
2088
+ const RULE_NAME$w = "valid-title";
2089
2089
  const trimFXPrefix = (word) => ["f", "x"].includes(word.charAt(0)) ? word.substring(1) : word;
2090
2090
  const quoteStringValue = (node) => node.type === AST_NODE_TYPES.TemplateLiteral ? `\`${node.quasis[0].value.raw}\`` : node.raw;
2091
2091
  const MatcherAndMessageSchema = {
@@ -2135,7 +2135,7 @@ const doesBinaryExpressionContainStringNode = (binaryExp) => {
2135
2135
  return isStringNode(binaryExp.left);
2136
2136
  };
2137
2137
  const validTitle = createEslintRule({
2138
- name: RULE_NAME$v,
2138
+ name: RULE_NAME$w,
2139
2139
  meta: {
2140
2140
  docs: {
2141
2141
  description: "enforce valid titles",
@@ -2315,7 +2315,7 @@ const validTitle = createEslintRule({
2315
2315
  }
2316
2316
  });
2317
2317
 
2318
- const RULE_NAME$u = "valid-expect";
2318
+ const RULE_NAME$v = "valid-expect";
2319
2319
  const defaultAsyncMatchers = ["toReject", "toResolve"];
2320
2320
  const getPromiseCallExpressionNode = (node) => {
2321
2321
  if (node.type === AST_NODE_TYPES.ArrayExpression && node.parent && node.parent.type === AST_NODE_TYPES.CallExpression)
@@ -2345,7 +2345,7 @@ const isAcceptableReturnNode = (node, allowReturn) => {
2345
2345
  ].includes(node.type);
2346
2346
  };
2347
2347
  const validExpect = createEslintRule({
2348
- name: RULE_NAME$u,
2348
+ name: RULE_NAME$v,
2349
2349
  meta: {
2350
2350
  docs: {
2351
2351
  description: "enforce valid `expect()` usage",
@@ -2519,9 +2519,9 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
2519
2519
  const isInstanceOfBinaryExpression = (node, className) => node.type === AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
2520
2520
  const hasOnlyOneArgument = (call) => call.arguments.length === 1;
2521
2521
 
2522
- const RULE_NAME$t = "prefer-to-be-object";
2522
+ const RULE_NAME$u = "prefer-to-be-object";
2523
2523
  const preferToBeObject = createEslintRule({
2524
- name: RULE_NAME$t,
2524
+ name: RULE_NAME$u,
2525
2525
  meta: {
2526
2526
  type: "suggestion",
2527
2527
  docs: {
@@ -2575,7 +2575,7 @@ const preferToBeObject = createEslintRule({
2575
2575
  if (vitestFnCall.args.length) {
2576
2576
  const [matcherArg] = vitestFnCall.args;
2577
2577
  fixes.push(fixer.remove(matcherArg));
2578
- invertCondition = matcherArg.type === AST_NODE_TYPES.Literal && followTypeAssertionChain(matcherArg).value === false;
2578
+ invertCondition = matcherArg.type === AST_NODE_TYPES.Literal && followTypeAssertionChain$1(matcherArg).value === false;
2579
2579
  }
2580
2580
  if (invertCondition) {
2581
2581
  const notModifier = vitestFnCall.modifiers.find((node2) => getAccessorValue(node2) === "not");
@@ -2594,10 +2594,10 @@ const preferToBeObject = createEslintRule({
2594
2594
  }
2595
2595
  });
2596
2596
 
2597
- const RULE_NAME$s = "prefer-to-be-truthy";
2597
+ const RULE_NAME$t = "prefer-to-be-truthy";
2598
2598
  const isTrueLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === true;
2599
2599
  const preferToBeTruthy = createEslintRule({
2600
- name: RULE_NAME$s,
2600
+ name: RULE_NAME$t,
2601
2601
  meta: {
2602
2602
  type: "suggestion",
2603
2603
  docs: {
@@ -2632,10 +2632,10 @@ const preferToBeTruthy = createEslintRule({
2632
2632
  }
2633
2633
  });
2634
2634
 
2635
- const RULE_NAME$r = "prefer-to-be-falsy";
2635
+ const RULE_NAME$s = "prefer-to-be-falsy";
2636
2636
  const isFalseLiteral = (node) => node.type === AST_NODE_TYPES.Literal && node.value === false;
2637
2637
  const preferToBeFalsy = createEslintRule({
2638
- name: RULE_NAME$r,
2638
+ name: RULE_NAME$s,
2639
2639
  meta: {
2640
2640
  type: "suggestion",
2641
2641
  docs: {
@@ -2670,9 +2670,9 @@ const preferToBeFalsy = createEslintRule({
2670
2670
  }
2671
2671
  });
2672
2672
 
2673
- const RULE_NAME$q = "prefer-to-have-length";
2673
+ const RULE_NAME$r = "prefer-to-have-length";
2674
2674
  const preferToHaveLength = createEslintRule({
2675
- name: RULE_NAME$q,
2675
+ name: RULE_NAME$r,
2676
2676
  meta: {
2677
2677
  type: "suggestion",
2678
2678
  docs: {
@@ -2720,9 +2720,9 @@ const preferToHaveLength = createEslintRule({
2720
2720
  }
2721
2721
  });
2722
2722
 
2723
- const RULE_NAME$p = "prefer-equality-matcher";
2723
+ const RULE_NAME$q = "prefer-equality-matcher";
2724
2724
  const preferEqualityMatcher = createEslintRule({
2725
- name: RULE_NAME$p,
2725
+ name: RULE_NAME$q,
2726
2726
  meta: {
2727
2727
  type: "suggestion",
2728
2728
  docs: {
@@ -2794,9 +2794,9 @@ const preferEqualityMatcher = createEslintRule({
2794
2794
  }
2795
2795
  });
2796
2796
 
2797
- const RULE_NAME$o = "prefer-strict-equal";
2797
+ const RULE_NAME$p = "prefer-strict-equal";
2798
2798
  const preferStrictEqual = createEslintRule({
2799
- name: RULE_NAME$o,
2799
+ name: RULE_NAME$p,
2800
2800
  meta: {
2801
2801
  type: "suggestion",
2802
2802
  docs: {
@@ -2837,9 +2837,9 @@ const preferStrictEqual = createEslintRule({
2837
2837
  }
2838
2838
  });
2839
2839
 
2840
- const RULE_NAME$n = "prefer-expect-resolves";
2840
+ const RULE_NAME$o = "prefer-expect-resolves";
2841
2841
  const preferExpectResolves = createEslintRule({
2842
- name: RULE_NAME$n,
2842
+ name: RULE_NAME$o,
2843
2843
  meta: {
2844
2844
  type: "suggestion",
2845
2845
  docs: {
@@ -2882,9 +2882,9 @@ const preferExpectResolves = createEslintRule({
2882
2882
  })
2883
2883
  });
2884
2884
 
2885
- const RULE_NAME$m = "prefer-each";
2885
+ const RULE_NAME$n = "prefer-each";
2886
2886
  const preferEach = createEslintRule({
2887
- name: RULE_NAME$m,
2887
+ name: RULE_NAME$n,
2888
2888
  meta: {
2889
2889
  type: "suggestion",
2890
2890
  docs: {
@@ -2943,9 +2943,9 @@ const preferEach = createEslintRule({
2943
2943
  }
2944
2944
  });
2945
2945
 
2946
- const RULE_NAME$l = "prefer-hooks-on-top";
2946
+ const RULE_NAME$m = "prefer-hooks-on-top";
2947
2947
  const preferHooksOnTop = createEslintRule({
2948
- name: RULE_NAME$l,
2948
+ name: RULE_NAME$m,
2949
2949
  meta: {
2950
2950
  type: "suggestion",
2951
2951
  docs: {
@@ -2979,10 +2979,10 @@ const preferHooksOnTop = createEslintRule({
2979
2979
  }
2980
2980
  });
2981
2981
 
2982
- const RULE_NAME$k = "prefer-hooks-in-order";
2982
+ const RULE_NAME$l = "prefer-hooks-in-order";
2983
2983
  const HooksOrder = ["beforeAll", "beforeEach", "afterEach", "afterAll"];
2984
2984
  const preferHooksInOrder = createEslintRule({
2985
- name: RULE_NAME$k,
2985
+ name: RULE_NAME$l,
2986
2986
  meta: {
2987
2987
  type: "suggestion",
2988
2988
  docs: {
@@ -3037,7 +3037,7 @@ const preferHooksInOrder = createEslintRule({
3037
3037
  }
3038
3038
  });
3039
3039
 
3040
- const RULE_NAME$j = "prefer-mock-promise-shorthand";
3040
+ const RULE_NAME$k = "prefer-mock-promise-shorthand";
3041
3041
  const withOnce = (name, addOnce) => {
3042
3042
  return `${name}${addOnce ? "Once" : ""}`;
3043
3043
  };
@@ -3049,7 +3049,7 @@ const findSingleReturnArgumentNode = (fnNode) => {
3049
3049
  return null;
3050
3050
  };
3051
3051
  const preferMockPromiseShorthand = createEslintRule({
3052
- name: RULE_NAME$j,
3052
+ name: RULE_NAME$k,
3053
3053
  meta: {
3054
3054
  type: "suggestion",
3055
3055
  docs: {
@@ -3110,6 +3110,99 @@ const preferMockPromiseShorthand = createEslintRule({
3110
3110
  }
3111
3111
  });
3112
3112
 
3113
+ const require = createRequire(import.meta.url);
3114
+ const eslintRequire = createRequire(require.resolve("eslint"));
3115
+ eslintRequire.resolve("espree");
3116
+ const STATEMENT_LIST_PARENTS = /* @__PURE__ */ new Set([
3117
+ AST_NODE_TYPES.Program,
3118
+ AST_NODE_TYPES.BlockStatement,
3119
+ AST_NODE_TYPES.SwitchCase,
3120
+ AST_NODE_TYPES.SwitchStatement
3121
+ ]);
3122
+ const isValidParent = (parentType) => {
3123
+ return STATEMENT_LIST_PARENTS.has(parentType);
3124
+ };
3125
+ const isTokenASemicolon = (token) => token.value === ";" && token.type === AST_TOKEN_TYPES.Punctuator;
3126
+ const getActualLastToken = (sourceCode, node) => {
3127
+ const semiToken = sourceCode.getLastToken(node);
3128
+ const prevToken = sourceCode.getTokenBefore(semiToken);
3129
+ const nextToken = sourceCode.getTokenAfter(semiToken);
3130
+ const isSemicolonLessStyle = Boolean(
3131
+ prevToken && nextToken && prevToken.range[0] >= node.range[0] && isTokenASemicolon(semiToken) && semiToken.loc.start.line !== prevToken.loc.end.line && semiToken.loc.end.line === nextToken.loc.start.line
3132
+ );
3133
+ return isSemicolonLessStyle ? prevToken : semiToken;
3134
+ };
3135
+ const getPaddingLineSequences = (prevNode, nextNode, sourceCode) => {
3136
+ const pairs = [];
3137
+ const includeComments = true;
3138
+ let prevToken = getActualLastToken(sourceCode, prevNode);
3139
+ if (nextNode.loc.start.line - prevNode.loc.end.line >= 2) {
3140
+ do {
3141
+ const token = sourceCode.getTokenAfter(prevToken, { includeComments });
3142
+ if (token.loc.start.line - prevToken.loc.end.line >= 2) {
3143
+ pairs.push([prevToken, token]);
3144
+ }
3145
+ prevToken = token;
3146
+ } while (prevToken.range[0] < nextNode.range[0]);
3147
+ }
3148
+ return pairs;
3149
+ };
3150
+ const areTokensOnSameLine = (left, right) => left.loc.end.line === right.loc.start.line;
3151
+ const isTypeCastExpression = (node) => node.type === AST_NODE_TYPES.TSAsExpression || node.type === AST_NODE_TYPES.TSTypeAssertion;
3152
+ const followTypeAssertionChain = (expression) => isTypeCastExpression(expression) ? followTypeAssertionChain(expression.expression) : expression;
3153
+
3154
+ const RULE_NAME$j = "prefer-vi-mocked";
3155
+ const mockTypes = ["Mock", "MockedFunction", "MockedClass", "MockedObject"];
3156
+ const preferViMocked = createEslintRule({
3157
+ name: RULE_NAME$j,
3158
+ meta: {
3159
+ type: "suggestion",
3160
+ docs: {
3161
+ description: "Prefer `vi.mocked()` over `fn as Mock`",
3162
+ requiresTypeChecking: true,
3163
+ recommended: false
3164
+ },
3165
+ fixable: "code",
3166
+ messages: {
3167
+ useViMocked: "Prefer `vi.mocked()`"
3168
+ },
3169
+ schema: []
3170
+ },
3171
+ defaultOptions: [],
3172
+ create(context) {
3173
+ function check(node) {
3174
+ const { typeAnnotation } = node;
3175
+ if (typeAnnotation.type !== AST_NODE_TYPES.TSTypeReference)
3176
+ return;
3177
+ const { typeName } = typeAnnotation;
3178
+ if (typeName.type !== AST_NODE_TYPES.Identifier)
3179
+ return;
3180
+ if (!mockTypes.includes(typeName.name))
3181
+ return;
3182
+ const fnName = context.sourceCode.text.slice(
3183
+ ...followTypeAssertionChain(node.expression).range
3184
+ );
3185
+ context.report({
3186
+ node,
3187
+ messageId: "useViMocked",
3188
+ fix(fixer) {
3189
+ return fixer.replaceText(node, `vi.mocked(${fnName})`);
3190
+ }
3191
+ });
3192
+ }
3193
+ return {
3194
+ TSAsExpression(node) {
3195
+ if (node.parent.type === AST_NODE_TYPES.TSAsExpression)
3196
+ return;
3197
+ check(node);
3198
+ },
3199
+ TSTypeAssertion(node) {
3200
+ check(node);
3201
+ }
3202
+ };
3203
+ }
3204
+ });
3205
+
3113
3206
  const RULE_NAME$i = "prefer-snapshot-hint";
3114
3207
  const snapshotMatchers = ["toMatchSnapshot", "toThrowErrorMatchingSnapshot"];
3115
3208
  const snapshotMatcherNames = snapshotMatchers;
@@ -4009,45 +4102,6 @@ const preferExpectAssertions = createEslintRule({
4009
4102
  }
4010
4103
  });
4011
4104
 
4012
- const require = createRequire(import.meta.url);
4013
- const eslintRequire = createRequire(require.resolve("eslint"));
4014
- eslintRequire.resolve("espree");
4015
- const STATEMENT_LIST_PARENTS = /* @__PURE__ */ new Set([
4016
- AST_NODE_TYPES.Program,
4017
- AST_NODE_TYPES.BlockStatement,
4018
- AST_NODE_TYPES.SwitchCase,
4019
- AST_NODE_TYPES.SwitchStatement
4020
- ]);
4021
- const isValidParent = (parentType) => {
4022
- return STATEMENT_LIST_PARENTS.has(parentType);
4023
- };
4024
- const isTokenASemicolon = (token) => token.value === ";" && token.type === AST_TOKEN_TYPES.Punctuator;
4025
- const getActualLastToken = (sourceCode, node) => {
4026
- const semiToken = sourceCode.getLastToken(node);
4027
- const prevToken = sourceCode.getTokenBefore(semiToken);
4028
- const nextToken = sourceCode.getTokenAfter(semiToken);
4029
- const isSemicolonLessStyle = Boolean(
4030
- prevToken && nextToken && prevToken.range[0] >= node.range[0] && isTokenASemicolon(semiToken) && semiToken.loc.start.line !== prevToken.loc.end.line && semiToken.loc.end.line === nextToken.loc.start.line
4031
- );
4032
- return isSemicolonLessStyle ? prevToken : semiToken;
4033
- };
4034
- const getPaddingLineSequences = (prevNode, nextNode, sourceCode) => {
4035
- const pairs = [];
4036
- const includeComments = true;
4037
- let prevToken = getActualLastToken(sourceCode, prevNode);
4038
- if (nextNode.loc.start.line - prevNode.loc.end.line >= 2) {
4039
- do {
4040
- const token = sourceCode.getTokenAfter(prevToken, { includeComments });
4041
- if (token.loc.start.line - prevToken.loc.end.line >= 2) {
4042
- pairs.push([prevToken, token]);
4043
- }
4044
- prevToken = token;
4045
- } while (prevToken.range[0] < nextNode.range[0]);
4046
- }
4047
- return pairs;
4048
- };
4049
- const areTokensOnSameLine = (left, right) => left.loc.end.line === right.loc.start.line;
4050
-
4051
4105
  var PaddingType = /* @__PURE__ */ ((PaddingType2) => {
4052
4106
  PaddingType2[PaddingType2["Any"] = 0] = "Any";
4053
4107
  PaddingType2[PaddingType2["Always"] = 1] = "Always";
@@ -4412,17 +4466,18 @@ const createConfigLegacy = (rules) => ({
4412
4466
  }, {})
4413
4467
  });
4414
4468
  const allRules = {
4469
+ [RULE_NAME$Y]: "warn",
4415
4470
  [RULE_NAME$X]: "warn",
4416
- [RULE_NAME$W]: "warn",
4471
+ [RULE_NAME$V]: "warn",
4417
4472
  [RULE_NAME$U]: "warn",
4418
- [RULE_NAME$T]: "warn",
4419
- [RULE_NAME$R]: "warn",
4473
+ [RULE_NAME$S]: "warn",
4474
+ [RULE_NAME$Q]: "warn",
4420
4475
  [RULE_NAME$P]: "warn",
4421
4476
  [RULE_NAME$O]: "warn",
4422
4477
  [RULE_NAME$N]: "warn",
4423
4478
  [RULE_NAME$M]: "warn",
4424
- [RULE_NAME$L]: "warn",
4425
- [RULE_NAME$J]: "warn",
4479
+ [RULE_NAME$K]: "warn",
4480
+ [RULE_NAME$I]: "warn",
4426
4481
  [RULE_NAME$H]: "warn",
4427
4482
  [RULE_NAME$G]: "warn",
4428
4483
  [RULE_NAME$F]: "warn",
@@ -4434,10 +4489,10 @@ const allRules = {
4434
4489
  [RULE_NAME$z]: "warn",
4435
4490
  [RULE_NAME$y]: "warn",
4436
4491
  [RULE_NAME$x]: "warn",
4437
- [RULE_NAME$w]: "warn",
4438
- [RULE_NAME$r]: "warn",
4439
- [RULE_NAME$t]: "warn",
4440
4492
  [RULE_NAME$s]: "warn",
4493
+ [RULE_NAME$u]: "warn",
4494
+ [RULE_NAME$t]: "warn",
4495
+ [RULE_NAME$r]: "warn",
4441
4496
  [RULE_NAME$q]: "warn",
4442
4497
  [RULE_NAME$p]: "warn",
4443
4498
  [RULE_NAME$o]: "warn",
@@ -4455,7 +4510,7 @@ const allRules = {
4455
4510
  [RULE_NAME$a]: "warn",
4456
4511
  [RULE_NAME$9]: "warn",
4457
4512
  [RULE_NAME$8]: "warn",
4458
- [RULE_NAME$Q]: "warn",
4513
+ [RULE_NAME$R]: "warn",
4459
4514
  [RULE_NAME$7]: "warn",
4460
4515
  [RULE_NAME$6]: "warn",
4461
4516
  [RULE_NAME]: "warn",
@@ -4466,14 +4521,14 @@ const allRules = {
4466
4521
  [RULE_NAME$1]: "warn"
4467
4522
  };
4468
4523
  const recommended = {
4469
- [RULE_NAME$S]: "error",
4470
- [RULE_NAME$V]: "error",
4471
- [RULE_NAME$K]: "error",
4524
+ [RULE_NAME$T]: "error",
4525
+ [RULE_NAME$W]: "error",
4526
+ [RULE_NAME$L]: "error",
4527
+ [RULE_NAME$w]: "error",
4472
4528
  [RULE_NAME$v]: "error",
4473
- [RULE_NAME$u]: "error",
4474
4529
  [RULE_NAME$h]: "error",
4475
4530
  [RULE_NAME$d]: "error",
4476
- [RULE_NAME$I]: "error"
4531
+ [RULE_NAME$J]: "error"
4477
4532
  };
4478
4533
  const plugin = {
4479
4534
  meta: {
@@ -4481,48 +4536,49 @@ const plugin = {
4481
4536
  version
4482
4537
  },
4483
4538
  rules: {
4484
- [RULE_NAME$X]: lowerCaseTitle,
4485
- [RULE_NAME$W]: maxNestedDescribe,
4486
- [RULE_NAME$V]: noIdenticalTitle,
4487
- [RULE_NAME$U]: noFocusedTests,
4488
- [RULE_NAME$T]: noConditionalTest,
4489
- [RULE_NAME$S]: expectExpect,
4490
- [RULE_NAME$R]: consistentTestIt,
4491
- [RULE_NAME$Q]: preferToBe,
4492
- [RULE_NAME$P]: noHooks,
4493
- [RULE_NAME$O]: noRestrictedViMethods,
4494
- [RULE_NAME$N]: consistentTestFilename,
4495
- [RULE_NAME$M]: maxExpect,
4496
- [RULE_NAME$L]: noAliasMethod,
4497
- [RULE_NAME$K]: noCommentedOutTests,
4498
- [RULE_NAME$J]: noConditionalExpect,
4499
- [RULE_NAME$H]: noConditionalInTest,
4500
- [RULE_NAME$G]: noDisabledTests,
4501
- [RULE_NAME$F]: noDoneCallback,
4502
- [RULE_NAME$E]: noDuplicateHooks,
4503
- [RULE_NAME$D]: noLargeSnapshots,
4504
- [RULE_NAME$C]: nonInterpolationInSnapShots,
4505
- [RULE_NAME$B]: noMocksImport,
4506
- [RULE_NAME$A]: noRestrictedMatchers,
4507
- [RULE_NAME$z]: noStandaloneExpect,
4508
- [RULE_NAME$y]: noTestPrefixes,
4509
- [RULE_NAME$x]: noTestReturnStatement,
4510
- [RULE_NAME$I]: noImportNodeTest,
4511
- [RULE_NAME$w]: preferCalledWith,
4512
- [RULE_NAME$v]: validTitle,
4513
- [RULE_NAME$u]: validExpect,
4514
- [RULE_NAME$r]: preferToBeFalsy,
4515
- [RULE_NAME$t]: preferToBeObject,
4516
- [RULE_NAME$s]: preferToBeTruthy,
4517
- [RULE_NAME$q]: preferToHaveLength,
4518
- [RULE_NAME$p]: preferEqualityMatcher,
4519
- [RULE_NAME$o]: preferStrictEqual,
4520
- [RULE_NAME$n]: preferExpectResolves,
4521
- [RULE_NAME$m]: preferEach,
4522
- [RULE_NAME$l]: preferHooksOnTop,
4523
- [RULE_NAME$k]: preferHooksInOrder,
4539
+ [RULE_NAME$Y]: lowerCaseTitle,
4540
+ [RULE_NAME$X]: maxNestedDescribe,
4541
+ [RULE_NAME$W]: noIdenticalTitle,
4542
+ [RULE_NAME$V]: noFocusedTests,
4543
+ [RULE_NAME$U]: noConditionalTest,
4544
+ [RULE_NAME$T]: expectExpect,
4545
+ [RULE_NAME$S]: consistentTestIt,
4546
+ [RULE_NAME$R]: preferToBe,
4547
+ [RULE_NAME$Q]: noHooks,
4548
+ [RULE_NAME$P]: noRestrictedViMethods,
4549
+ [RULE_NAME$O]: consistentTestFilename,
4550
+ [RULE_NAME$N]: maxExpect,
4551
+ [RULE_NAME$M]: noAliasMethod,
4552
+ [RULE_NAME$L]: noCommentedOutTests,
4553
+ [RULE_NAME$K]: noConditionalExpect,
4554
+ [RULE_NAME$I]: noConditionalInTest,
4555
+ [RULE_NAME$H]: noDisabledTests,
4556
+ [RULE_NAME$G]: noDoneCallback,
4557
+ [RULE_NAME$F]: noDuplicateHooks,
4558
+ [RULE_NAME$E]: noLargeSnapshots,
4559
+ [RULE_NAME$D]: nonInterpolationInSnapShots,
4560
+ [RULE_NAME$C]: noMocksImport,
4561
+ [RULE_NAME$B]: noRestrictedMatchers,
4562
+ [RULE_NAME$A]: noStandaloneExpect,
4563
+ [RULE_NAME$z]: noTestPrefixes,
4564
+ [RULE_NAME$y]: noTestReturnStatement,
4565
+ [RULE_NAME$J]: noImportNodeTest,
4566
+ [RULE_NAME$x]: preferCalledWith,
4567
+ [RULE_NAME$w]: validTitle,
4568
+ [RULE_NAME$v]: validExpect,
4569
+ [RULE_NAME$s]: preferToBeFalsy,
4570
+ [RULE_NAME$u]: preferToBeObject,
4571
+ [RULE_NAME$t]: preferToBeTruthy,
4572
+ [RULE_NAME$r]: preferToHaveLength,
4573
+ [RULE_NAME$q]: preferEqualityMatcher,
4574
+ [RULE_NAME$p]: preferStrictEqual,
4575
+ [RULE_NAME$o]: preferExpectResolves,
4576
+ [RULE_NAME$n]: preferEach,
4577
+ [RULE_NAME$m]: preferHooksOnTop,
4578
+ [RULE_NAME$l]: preferHooksInOrder,
4524
4579
  [RULE_NAME$d]: requireLocalTestContextForConcurrentSnapshots,
4525
- [RULE_NAME$j]: preferMockPromiseShorthand,
4580
+ [RULE_NAME$k]: preferMockPromiseShorthand,
4581
+ [RULE_NAME$j]: preferViMocked,
4526
4582
  [RULE_NAME$i]: preferSnapshotHint,
4527
4583
  [RULE_NAME$h]: validDescribeCallback,
4528
4584
  [RULE_NAME$g]: requireTopLevelDescribe,