@@ -32,8 +32,10 @@ function isAntonymMatcher(matcherNode, matcherArguments) {
32
32
}
33
33
34
34
function usesToBeOrToEqualWithNull ( matcherNode , matcherArguments ) {
35
- return ( matcherNode . name === "toBe" || matcherNode . name === "toEqual" ) &&
36
- matcherArguments [ 0 ] . value === null ;
35
+ return (
36
+ ( matcherNode . name === "toBe" || matcherNode . name === "toEqual" ) &&
37
+ matcherArguments [ 0 ] . value === null
38
+ ) ;
37
39
}
38
40
39
41
function usesToHaveLengthZero ( matcherNode , matcherArguments ) {
@@ -71,7 +73,7 @@ export const create = (context) => {
71
73
if ( ! queryNode || ( ! queryNode . name && ! queryNode . property ) ) return ;
72
74
73
75
// toHaveLength() is only invalid with 0 or 1
74
- if ( matcherNode . name === "toHaveLength" ) {
76
+ if ( matcherNode . name === "toHaveLength" && matcherArguments . length ) {
75
77
const lengthValue = getLengthValue ( matcherArguments ) ;
76
78
// isNotToHaveLengthZero represents .not.toHaveLength(0) which is a valid use of toHaveLength
77
79
const isNotToHaveLengthZero =
@@ -89,7 +91,10 @@ export const create = (context) => {
89
91
90
92
// toBe() or toEqual() are only invalid with null
91
93
if ( matcherNode . name === "toBe" || matcherNode . name === "toEqual" ) {
92
- if ( ! usesToBeOrToEqualWithNull ( matcherNode , matcherArguments ) ) {
94
+ if (
95
+ ! matcherArguments . length ||
96
+ ! usesToBeOrToEqualWithNull ( matcherNode , matcherArguments )
97
+ ) {
93
98
return ;
94
99
}
95
100
}
@@ -146,6 +151,10 @@ export const create = (context) => {
146
151
[ `CallExpression[callee.object.object.callee.name='expect'][callee.object.property.name='not'][callee.property.name=${ alternativeMatchers } ], CallExpression[callee.object.callee.name='expect'][callee.object.property.name='not'][callee.object.arguments.0.argument.callee.name=${ alternativeMatchers } ]` ] (
147
152
node
148
153
) {
154
+ if ( ! node . callee . object . object . arguments . length ) {
155
+ return ;
156
+ }
157
+
149
158
const arg = node . callee . object . object . arguments [ 0 ] ;
150
159
const queryNode =
151
160
arg . type === "AwaitExpression" ? arg . argument . callee : arg . callee ;
0 commit comments