@vitest/eslint-plugin 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +17 -17
- package/dist/index.js +17 -17
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ let __typescript_eslint_scope_manager = require("@typescript-eslint/scope-manage
|
|
|
31
31
|
__typescript_eslint_scope_manager = __toESM(__typescript_eslint_scope_manager);
|
|
32
32
|
|
|
33
33
|
//#region package.json
|
|
34
|
-
var version = "1.4.
|
|
34
|
+
var version = "1.4.1";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/utils/index.ts
|
|
@@ -1650,9 +1650,9 @@ const determineVitestFnType = (name) => {
|
|
|
1650
1650
|
if (name === "expectTypeOf") return "expectTypeOf";
|
|
1651
1651
|
if (name === "vi") return "vi";
|
|
1652
1652
|
if (name === "vitest") return "vitest";
|
|
1653
|
-
if (
|
|
1654
|
-
if (
|
|
1655
|
-
if (
|
|
1653
|
+
if (Object.prototype.hasOwnProperty.call(DescribeAlias, name)) return "describe";
|
|
1654
|
+
if (Object.prototype.hasOwnProperty.call(TestCaseName, name)) return "test";
|
|
1655
|
+
if (Object.prototype.hasOwnProperty.call(HookName, name)) return "hook";
|
|
1656
1656
|
return "unknown";
|
|
1657
1657
|
};
|
|
1658
1658
|
const findModifiersAndMatcher = (members) => {
|
|
@@ -1665,7 +1665,7 @@ const findModifiersAndMatcher = (members) => {
|
|
|
1665
1665
|
};
|
|
1666
1666
|
const name = getAccessorValue(member);
|
|
1667
1667
|
if (modifiers.length === 0) {
|
|
1668
|
-
if (!
|
|
1668
|
+
if (!Object.prototype.hasOwnProperty.call(ModifierName, name)) return "modifier-unknown";
|
|
1669
1669
|
} else if (modifiers.length === 1) {
|
|
1670
1670
|
if (name !== ModifierName.not && name != ModifierName.have) return "modifier-unknown";
|
|
1671
1671
|
const firstModifier = getAccessorValue(modifiers[0]);
|
|
@@ -1776,7 +1776,7 @@ const resolvePossibleAliasedGlobal = (global, context) => {
|
|
|
1776
1776
|
return null;
|
|
1777
1777
|
};
|
|
1778
1778
|
const isAncestorTestCaseCall = ({ parent }) => {
|
|
1779
|
-
return parent?.type === __typescript_eslint_utils.AST_NODE_TYPES.CallExpression && parent.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier &&
|
|
1779
|
+
return parent?.type === __typescript_eslint_utils.AST_NODE_TYPES.CallExpression && parent.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && Object.prototype.hasOwnProperty.call(TestCaseName, parent.callee.name);
|
|
1780
1780
|
};
|
|
1781
1781
|
const resolveScope = (scope, identifier) => {
|
|
1782
1782
|
let currentScope = scope;
|
|
@@ -1790,7 +1790,7 @@ const resolveScope = (scope, identifier) => {
|
|
|
1790
1790
|
if ((property?.key.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier ? property.key : void 0)?.name === identifier) return "testContext";
|
|
1791
1791
|
}
|
|
1792
1792
|
/** if detect test function is created with `.extend()` */
|
|
1793
|
-
if (def.node.type === __typescript_eslint_utils.AST_NODE_TYPES.VariableDeclarator && def.node.id.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier &&
|
|
1793
|
+
if (def.node.type === __typescript_eslint_utils.AST_NODE_TYPES.VariableDeclarator && def.node.id.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier && Object.prototype.hasOwnProperty.call(TestCaseName, def.node.id.name) && def.node.init?.type === __typescript_eslint_utils.AST_NODE_TYPES.CallExpression && def.node.init.callee.type === __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression && isIdentifier(def.node.init.callee.property, "extend")) return "testContext";
|
|
1794
1794
|
const namedParam = isFunction(def.node) ? def.node.params.find((params) => params.type === __typescript_eslint_utils.AST_NODE_TYPES.Identifier) : void 0;
|
|
1795
1795
|
if (namedParam && isAncestorTestCaseCall(namedParam.parent)) return "testContext";
|
|
1796
1796
|
const importDetails = describePossibleImportDef(def);
|
|
@@ -3159,7 +3159,7 @@ var no_mocks_import_default = createEslintRule({
|
|
|
3159
3159
|
//#region src/rules/no-restricted-matchers.ts
|
|
3160
3160
|
const RULE_NAME$50 = "no-restricted-matchers";
|
|
3161
3161
|
const isChainRestricted = (chain, restriction) => {
|
|
3162
|
-
if (
|
|
3162
|
+
if (Object.prototype.hasOwnProperty.call(ModifierName, restriction) || restriction.endsWith(".not")) return chain.startsWith(restriction);
|
|
3163
3163
|
return chain === restriction;
|
|
3164
3164
|
};
|
|
3165
3165
|
var no_restricted_matchers_default = createEslintRule({
|
|
@@ -4031,7 +4031,7 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
|
|
|
4031
4031
|
if (["toBeTruthy", "toBeFalsy"].includes(matcherName)) return true;
|
|
4032
4032
|
if (expectFnCall.args.length !== 1) return false;
|
|
4033
4033
|
const arg = getFirstMatcherArg(expectFnCall);
|
|
4034
|
-
return
|
|
4034
|
+
return Object.prototype.hasOwnProperty.call(EqualityMatcher, matcherName) && isBooleanLiteral(arg);
|
|
4035
4035
|
};
|
|
4036
4036
|
const isInstanceOfBinaryExpression = (node, className) => node.type === __typescript_eslint_utils.AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
|
|
4037
4037
|
const hasOnlyOneArgument = (call) => call.arguments.length === 1;
|
|
@@ -4085,7 +4085,7 @@ var prefer_comparison_matcher_default = createEslintRule({
|
|
|
4085
4085
|
const { arguments: [comparison], range: [, expectCallEnd] } = expect;
|
|
4086
4086
|
const { matcher } = vitestFnCall;
|
|
4087
4087
|
const matcherArg = getFirstMatcherArg(vitestFnCall);
|
|
4088
|
-
if (comparison?.type !== __typescript_eslint_utils.AST_NODE_TYPES.BinaryExpression || isComparingToString(comparison) || !
|
|
4088
|
+
if (comparison?.type !== __typescript_eslint_utils.AST_NODE_TYPES.BinaryExpression || isComparingToString(comparison) || !Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || !isBooleanLiteral(matcherArg)) return;
|
|
4089
4089
|
const [modifier] = vitestFnCall.modifiers;
|
|
4090
4090
|
const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
|
|
4091
4091
|
const preferredMatcher = determineMatcher(comparison.operator, matcherArg.value === hasNot);
|
|
@@ -4243,7 +4243,7 @@ var prefer_equality_matcher_default = createEslintRule({
|
|
|
4243
4243
|
const { arguments: [comparison], range: [, expectCallEnd] } = expect;
|
|
4244
4244
|
const { matcher } = vitestFnCall;
|
|
4245
4245
|
const matcherArg = getFirstMatcherArg(vitestFnCall);
|
|
4246
|
-
if (comparison?.type !== __typescript_eslint_utils.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "===" && comparison.operator !== "!==" || !
|
|
4246
|
+
if (comparison?.type !== __typescript_eslint_utils.AST_NODE_TYPES.BinaryExpression || comparison.operator !== "===" && comparison.operator !== "!==" || !Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || !isBooleanLiteral(matcherArg)) return;
|
|
4247
4247
|
const matcherValue = matcherArg.value;
|
|
4248
4248
|
const [modifier] = vitestFnCall.modifiers;
|
|
4249
4249
|
const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
|
|
@@ -5116,7 +5116,7 @@ var prefer_to_be_falsy_default = createEslintRule({
|
|
|
5116
5116
|
return { CallExpression(node) {
|
|
5117
5117
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
5118
5118
|
if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf")) return;
|
|
5119
|
-
if (vitestFnCall.args.length === 1 && isFalseLiteral(getFirstMatcherArg(vitestFnCall)) &&
|
|
5119
|
+
if (vitestFnCall.args.length === 1 && isFalseLiteral(getFirstMatcherArg(vitestFnCall)) && Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(vitestFnCall.matcher))) context.report({
|
|
5120
5120
|
node: vitestFnCall.matcher,
|
|
5121
5121
|
messageId: "preferToBeFalsy",
|
|
5122
5122
|
fix: (fixer) => [fixer.replaceText(vitestFnCall.matcher, "toBeFalsy"), fixer.remove(vitestFnCall.args[0])]
|
|
@@ -5200,7 +5200,7 @@ var prefer_to_be_truthy_default = createEslintRule({
|
|
|
5200
5200
|
return { CallExpression(node) {
|
|
5201
5201
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
5202
5202
|
if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf")) return;
|
|
5203
|
-
if (vitestFnCall.args.length === 1 && isTrueLiteral(getFirstMatcherArg(vitestFnCall)) &&
|
|
5203
|
+
if (vitestFnCall.args.length === 1 && isTrueLiteral(getFirstMatcherArg(vitestFnCall)) && Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(vitestFnCall.matcher))) context.report({
|
|
5204
5204
|
node: vitestFnCall.matcher,
|
|
5205
5205
|
messageId: "preferToBeTruthy",
|
|
5206
5206
|
fix: (fixer) => [fixer.replaceText(vitestFnCall.matcher, "toBeTruthy"), fixer.remove(vitestFnCall.args[0])]
|
|
@@ -5264,7 +5264,7 @@ var prefer_to_be_default = createEslintRule({
|
|
|
5264
5264
|
reportPreferToBe(context, matcherName === "toBeDefined" ? "Undefined" : "Defined", vitestFnCall, node, notModifier);
|
|
5265
5265
|
return;
|
|
5266
5266
|
}
|
|
5267
|
-
if (!
|
|
5267
|
+
if (!Object.prototype.hasOwnProperty.call(EqualityMatcher, matcherName) || vitestFnCall.args.length === 0) return;
|
|
5268
5268
|
if (isNullEqualityMatcher(vitestFnCall)) {
|
|
5269
5269
|
reportPreferToBe(context, "Null", vitestFnCall, node);
|
|
5270
5270
|
return;
|
|
@@ -5308,7 +5308,7 @@ var prefer_to_contain_default = createEslintRule({
|
|
|
5308
5308
|
const { arguments: [includesCall], range: [, expectCallEnd] } = expect;
|
|
5309
5309
|
const { matcher } = vitestFnCall;
|
|
5310
5310
|
const matcherArg = getFirstMatcherArg(vitestFnCall);
|
|
5311
|
-
if (!includesCall || matcherArg.type === __typescript_eslint_utils.AST_NODE_TYPES.SpreadElement || !
|
|
5311
|
+
if (!includesCall || matcherArg.type === __typescript_eslint_utils.AST_NODE_TYPES.SpreadElement || !Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || !isBooleanLiteral(matcherArg) || !isFixableIncludesCallExpression(includesCall)) return;
|
|
5312
5312
|
const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
|
|
5313
5313
|
context.report({
|
|
5314
5314
|
fix(fixer) {
|
|
@@ -5351,7 +5351,7 @@ var prefer_to_have_length_default = createEslintRule({
|
|
|
5351
5351
|
if (expect?.type !== __typescript_eslint_utils.AST_NODE_TYPES.CallExpression) return;
|
|
5352
5352
|
const [argument] = expect.arguments;
|
|
5353
5353
|
const { matcher } = vitestFnCall;
|
|
5354
|
-
if (!
|
|
5354
|
+
if (!Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || argument?.type !== __typescript_eslint_utils.AST_NODE_TYPES.MemberExpression || !isSupportedAccessor(argument.property, "length")) return;
|
|
5355
5355
|
context.report({
|
|
5356
5356
|
node: matcher,
|
|
5357
5357
|
messageId: "preferToHaveLength",
|
|
@@ -6106,7 +6106,7 @@ var valid_expect_default = createEslintRule({
|
|
|
6106
6106
|
return;
|
|
6107
6107
|
}
|
|
6108
6108
|
if (vitestFnCall === "matcher-not-called") context.report({
|
|
6109
|
-
messageId: isSupportedAccessor(reportingNode) &&
|
|
6109
|
+
messageId: isSupportedAccessor(reportingNode) && Object.prototype.hasOwnProperty.call(ModifierName, getAccessorValue(reportingNode)) ? "matcherNotFound" : "matcherNotCalled",
|
|
6110
6110
|
node: reportingNode
|
|
6111
6111
|
});
|
|
6112
6112
|
if (vitestFnCall === "modifier-unknown") {
|
package/dist/index.js
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.4.
|
|
7
|
+
var version = "1.4.1";
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/utils/index.ts
|
|
@@ -1623,9 +1623,9 @@ const determineVitestFnType = (name) => {
|
|
|
1623
1623
|
if (name === "expectTypeOf") return "expectTypeOf";
|
|
1624
1624
|
if (name === "vi") return "vi";
|
|
1625
1625
|
if (name === "vitest") return "vitest";
|
|
1626
|
-
if (
|
|
1627
|
-
if (
|
|
1628
|
-
if (
|
|
1626
|
+
if (Object.prototype.hasOwnProperty.call(DescribeAlias, name)) return "describe";
|
|
1627
|
+
if (Object.prototype.hasOwnProperty.call(TestCaseName, name)) return "test";
|
|
1628
|
+
if (Object.prototype.hasOwnProperty.call(HookName, name)) return "hook";
|
|
1629
1629
|
return "unknown";
|
|
1630
1630
|
};
|
|
1631
1631
|
const findModifiersAndMatcher = (members) => {
|
|
@@ -1638,7 +1638,7 @@ const findModifiersAndMatcher = (members) => {
|
|
|
1638
1638
|
};
|
|
1639
1639
|
const name = getAccessorValue(member);
|
|
1640
1640
|
if (modifiers.length === 0) {
|
|
1641
|
-
if (!
|
|
1641
|
+
if (!Object.prototype.hasOwnProperty.call(ModifierName, name)) return "modifier-unknown";
|
|
1642
1642
|
} else if (modifiers.length === 1) {
|
|
1643
1643
|
if (name !== ModifierName.not && name != ModifierName.have) return "modifier-unknown";
|
|
1644
1644
|
const firstModifier = getAccessorValue(modifiers[0]);
|
|
@@ -1749,7 +1749,7 @@ const resolvePossibleAliasedGlobal = (global, context) => {
|
|
|
1749
1749
|
return null;
|
|
1750
1750
|
};
|
|
1751
1751
|
const isAncestorTestCaseCall = ({ parent }) => {
|
|
1752
|
-
return parent?.type === AST_NODE_TYPES.CallExpression && parent.callee.type === AST_NODE_TYPES.Identifier &&
|
|
1752
|
+
return parent?.type === AST_NODE_TYPES.CallExpression && parent.callee.type === AST_NODE_TYPES.Identifier && Object.prototype.hasOwnProperty.call(TestCaseName, parent.callee.name);
|
|
1753
1753
|
};
|
|
1754
1754
|
const resolveScope = (scope, identifier) => {
|
|
1755
1755
|
let currentScope = scope;
|
|
@@ -1763,7 +1763,7 @@ const resolveScope = (scope, identifier) => {
|
|
|
1763
1763
|
if ((property?.key.type === AST_NODE_TYPES.Identifier ? property.key : void 0)?.name === identifier) return "testContext";
|
|
1764
1764
|
}
|
|
1765
1765
|
/** if detect test function is created with `.extend()` */
|
|
1766
|
-
if (def.node.type === AST_NODE_TYPES.VariableDeclarator && def.node.id.type === AST_NODE_TYPES.Identifier &&
|
|
1766
|
+
if (def.node.type === AST_NODE_TYPES.VariableDeclarator && def.node.id.type === AST_NODE_TYPES.Identifier && Object.prototype.hasOwnProperty.call(TestCaseName, def.node.id.name) && def.node.init?.type === AST_NODE_TYPES.CallExpression && def.node.init.callee.type === AST_NODE_TYPES.MemberExpression && isIdentifier(def.node.init.callee.property, "extend")) return "testContext";
|
|
1767
1767
|
const namedParam = isFunction(def.node) ? def.node.params.find((params) => params.type === AST_NODE_TYPES.Identifier) : void 0;
|
|
1768
1768
|
if (namedParam && isAncestorTestCaseCall(namedParam.parent)) return "testContext";
|
|
1769
1769
|
const importDetails = describePossibleImportDef(def);
|
|
@@ -3132,7 +3132,7 @@ var no_mocks_import_default = createEslintRule({
|
|
|
3132
3132
|
//#region src/rules/no-restricted-matchers.ts
|
|
3133
3133
|
const RULE_NAME$50 = "no-restricted-matchers";
|
|
3134
3134
|
const isChainRestricted = (chain, restriction) => {
|
|
3135
|
-
if (
|
|
3135
|
+
if (Object.prototype.hasOwnProperty.call(ModifierName, restriction) || restriction.endsWith(".not")) return chain.startsWith(restriction);
|
|
3136
3136
|
return chain === restriction;
|
|
3137
3137
|
};
|
|
3138
3138
|
var no_restricted_matchers_default = createEslintRule({
|
|
@@ -4004,7 +4004,7 @@ const isBooleanEqualityMatcher = (expectFnCall) => {
|
|
|
4004
4004
|
if (["toBeTruthy", "toBeFalsy"].includes(matcherName)) return true;
|
|
4005
4005
|
if (expectFnCall.args.length !== 1) return false;
|
|
4006
4006
|
const arg = getFirstMatcherArg(expectFnCall);
|
|
4007
|
-
return
|
|
4007
|
+
return Object.prototype.hasOwnProperty.call(EqualityMatcher, matcherName) && isBooleanLiteral(arg);
|
|
4008
4008
|
};
|
|
4009
4009
|
const isInstanceOfBinaryExpression = (node, className) => node.type === AST_NODE_TYPES.BinaryExpression && node.operator === "instanceof" && isSupportedAccessor(node.right, className);
|
|
4010
4010
|
const hasOnlyOneArgument = (call) => call.arguments.length === 1;
|
|
@@ -4058,7 +4058,7 @@ var prefer_comparison_matcher_default = createEslintRule({
|
|
|
4058
4058
|
const { arguments: [comparison], range: [, expectCallEnd] } = expect;
|
|
4059
4059
|
const { matcher } = vitestFnCall;
|
|
4060
4060
|
const matcherArg = getFirstMatcherArg(vitestFnCall);
|
|
4061
|
-
if (comparison?.type !== AST_NODE_TYPES.BinaryExpression || isComparingToString(comparison) || !
|
|
4061
|
+
if (comparison?.type !== AST_NODE_TYPES.BinaryExpression || isComparingToString(comparison) || !Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || !isBooleanLiteral(matcherArg)) return;
|
|
4062
4062
|
const [modifier] = vitestFnCall.modifiers;
|
|
4063
4063
|
const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
|
|
4064
4064
|
const preferredMatcher = determineMatcher(comparison.operator, matcherArg.value === hasNot);
|
|
@@ -4216,7 +4216,7 @@ var prefer_equality_matcher_default = createEslintRule({
|
|
|
4216
4216
|
const { arguments: [comparison], range: [, expectCallEnd] } = expect;
|
|
4217
4217
|
const { matcher } = vitestFnCall;
|
|
4218
4218
|
const matcherArg = getFirstMatcherArg(vitestFnCall);
|
|
4219
|
-
if (comparison?.type !== AST_NODE_TYPES.BinaryExpression || comparison.operator !== "===" && comparison.operator !== "!==" || !
|
|
4219
|
+
if (comparison?.type !== AST_NODE_TYPES.BinaryExpression || comparison.operator !== "===" && comparison.operator !== "!==" || !Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || !isBooleanLiteral(matcherArg)) return;
|
|
4220
4220
|
const matcherValue = matcherArg.value;
|
|
4221
4221
|
const [modifier] = vitestFnCall.modifiers;
|
|
4222
4222
|
const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
|
|
@@ -5089,7 +5089,7 @@ var prefer_to_be_falsy_default = createEslintRule({
|
|
|
5089
5089
|
return { CallExpression(node) {
|
|
5090
5090
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
5091
5091
|
if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf")) return;
|
|
5092
|
-
if (vitestFnCall.args.length === 1 && isFalseLiteral(getFirstMatcherArg(vitestFnCall)) &&
|
|
5092
|
+
if (vitestFnCall.args.length === 1 && isFalseLiteral(getFirstMatcherArg(vitestFnCall)) && Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(vitestFnCall.matcher))) context.report({
|
|
5093
5093
|
node: vitestFnCall.matcher,
|
|
5094
5094
|
messageId: "preferToBeFalsy",
|
|
5095
5095
|
fix: (fixer) => [fixer.replaceText(vitestFnCall.matcher, "toBeFalsy"), fixer.remove(vitestFnCall.args[0])]
|
|
@@ -5173,7 +5173,7 @@ var prefer_to_be_truthy_default = createEslintRule({
|
|
|
5173
5173
|
return { CallExpression(node) {
|
|
5174
5174
|
const vitestFnCall = parseVitestFnCall(node, context);
|
|
5175
5175
|
if (!(vitestFnCall?.type === "expect" || vitestFnCall?.type === "expectTypeOf")) return;
|
|
5176
|
-
if (vitestFnCall.args.length === 1 && isTrueLiteral(getFirstMatcherArg(vitestFnCall)) &&
|
|
5176
|
+
if (vitestFnCall.args.length === 1 && isTrueLiteral(getFirstMatcherArg(vitestFnCall)) && Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(vitestFnCall.matcher))) context.report({
|
|
5177
5177
|
node: vitestFnCall.matcher,
|
|
5178
5178
|
messageId: "preferToBeTruthy",
|
|
5179
5179
|
fix: (fixer) => [fixer.replaceText(vitestFnCall.matcher, "toBeTruthy"), fixer.remove(vitestFnCall.args[0])]
|
|
@@ -5237,7 +5237,7 @@ var prefer_to_be_default = createEslintRule({
|
|
|
5237
5237
|
reportPreferToBe(context, matcherName === "toBeDefined" ? "Undefined" : "Defined", vitestFnCall, node, notModifier);
|
|
5238
5238
|
return;
|
|
5239
5239
|
}
|
|
5240
|
-
if (!
|
|
5240
|
+
if (!Object.prototype.hasOwnProperty.call(EqualityMatcher, matcherName) || vitestFnCall.args.length === 0) return;
|
|
5241
5241
|
if (isNullEqualityMatcher(vitestFnCall)) {
|
|
5242
5242
|
reportPreferToBe(context, "Null", vitestFnCall, node);
|
|
5243
5243
|
return;
|
|
@@ -5281,7 +5281,7 @@ var prefer_to_contain_default = createEslintRule({
|
|
|
5281
5281
|
const { arguments: [includesCall], range: [, expectCallEnd] } = expect;
|
|
5282
5282
|
const { matcher } = vitestFnCall;
|
|
5283
5283
|
const matcherArg = getFirstMatcherArg(vitestFnCall);
|
|
5284
|
-
if (!includesCall || matcherArg.type === AST_NODE_TYPES.SpreadElement || !
|
|
5284
|
+
if (!includesCall || matcherArg.type === AST_NODE_TYPES.SpreadElement || !Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || !isBooleanLiteral(matcherArg) || !isFixableIncludesCallExpression(includesCall)) return;
|
|
5285
5285
|
const hasNot = vitestFnCall.modifiers.some((nod) => getAccessorValue(nod) === "not");
|
|
5286
5286
|
context.report({
|
|
5287
5287
|
fix(fixer) {
|
|
@@ -5324,7 +5324,7 @@ var prefer_to_have_length_default = createEslintRule({
|
|
|
5324
5324
|
if (expect?.type !== AST_NODE_TYPES.CallExpression) return;
|
|
5325
5325
|
const [argument] = expect.arguments;
|
|
5326
5326
|
const { matcher } = vitestFnCall;
|
|
5327
|
-
if (!
|
|
5327
|
+
if (!Object.prototype.hasOwnProperty.call(EqualityMatcher, getAccessorValue(matcher)) || argument?.type !== AST_NODE_TYPES.MemberExpression || !isSupportedAccessor(argument.property, "length")) return;
|
|
5328
5328
|
context.report({
|
|
5329
5329
|
node: matcher,
|
|
5330
5330
|
messageId: "preferToHaveLength",
|
|
@@ -6079,7 +6079,7 @@ var valid_expect_default = createEslintRule({
|
|
|
6079
6079
|
return;
|
|
6080
6080
|
}
|
|
6081
6081
|
if (vitestFnCall === "matcher-not-called") context.report({
|
|
6082
|
-
messageId: isSupportedAccessor(reportingNode) &&
|
|
6082
|
+
messageId: isSupportedAccessor(reportingNode) && Object.prototype.hasOwnProperty.call(ModifierName, getAccessorValue(reportingNode)) ? "matcherNotFound" : "matcherNotCalled",
|
|
6083
6083
|
node: reportingNode
|
|
6084
6084
|
});
|
|
6085
6085
|
if (vitestFnCall === "modifier-unknown") {
|