@@ -35,13 +35,9 @@ function isPropAccess(node) {
35
35
( node . computed === true && node . property . type === 'Literal' && _ . isString ( node . property . value ) ) ;
36
36
}
37
37
38
- function isMemberExpOfArg ( node , argName ) {
39
- return argName && _ . get ( node , 'type' ) === 'MemberExpression' && _ . get ( node , 'object.name' ) === argName && isPropAccess ( node ) ;
40
- }
41
-
42
- function isNestedMemberExpOfArg ( node , argName , maxPropertyPathLength ) {
38
+ function isMemberExpOfArg ( node , argName , maxPropertyPathLength ) {
43
39
if ( maxPropertyPathLength > 0 && argName && node && node . object && node . type === 'MemberExpression' && isPropAccess ( node ) ) {
44
- return node . object . name === argName || isNestedMemberExpOfArg ( node . object , argName , maxPropertyPathLength - 1 ) ;
40
+ return node . object . name === argName || isMemberExpOfArg ( node . object , argName , maxPropertyPathLength - 1 ) ;
45
41
}
46
42
return false ;
47
43
}
@@ -62,25 +58,25 @@ function isObjectOfMethodCall(node) {
62
58
return _ . get ( node , 'parent.object' ) === node && _ . get ( node , 'parent.parent.type' ) === 'CallExpression' ;
63
59
}
64
60
65
- function isBinaryExpWithParamMember ( operator , maxPropertyPathLength , exp , paramName ) {
61
+ function isBinaryExpWithParamMember ( operator , exp , paramName , maxPropertyPathLength ) {
66
62
return exp && exp . type === 'BinaryExpression' && exp . operator === operator &&
67
- ( isNestedMemberExpOfArg ( exp . left , paramName , maxPropertyPathLength ) || isNestedMemberExpOfArg ( exp . right , paramName , maxPropertyPathLength ) ) ;
63
+ ( isMemberExpOfArg ( exp . left , paramName , maxPropertyPathLength ) || isMemberExpOfArg ( exp . right , paramName , maxPropertyPathLength ) ) ;
68
64
}
69
65
70
66
function isConjunctionOfEqEqEqToParamMember ( exp , paramName , maxPropertyPathLength ) {
71
67
if ( exp && exp . type === 'LogicalExpression' && exp . operator === '&&' ) {
72
68
return isConjunctionOfEqEqEqToParamMember ( exp . left , paramName , maxPropertyPathLength ) &&
73
69
isConjunctionOfEqEqEqToParamMember ( exp . right , paramName , maxPropertyPathLength ) ;
74
70
}
75
- return isBinaryExpWithParamMember ( '===' , maxPropertyPathLength , exp , paramName ) ;
71
+ return isBinaryExpWithParamMember ( '===' , exp , paramName , maxPropertyPathLength ) ;
76
72
}
77
73
78
74
function isNegationExpression ( exp ) {
79
75
return exp && exp . type === 'UnaryExpression' && exp . operator === '!' ;
80
76
}
81
77
82
- function isNegationOfParamMember ( exp , firstParamName ) {
83
- return isNegationExpression ( exp ) && isMemberExpOfArg ( exp . argument , firstParamName ) ;
78
+ function isNegationOfParamMember ( exp , firstParamName , maxPropertyPathLength ) {
79
+ return isNegationExpression ( exp ) && isMemberExpOfArg ( exp . argument , firstParamName , maxPropertyPathLength ) ;
84
80
}
85
81
86
82
function isIdentifierOfParam ( exp , paramName ) {
@@ -139,7 +135,7 @@ module.exports = {
139
135
hasOnlyOneStatement : hasOnlyOneStatement ,
140
136
isObjectOfMethodCall : isObjectOfMethodCall ,
141
137
isEqEqEqToParamMember : isBinaryExpWithParamMember . bind ( null , '===' ) ,
142
- isNotEqEqToParamMember : isBinaryExpWithParamMember . bind ( null , '!==' , 1 ) ,
138
+ isNotEqEqToParamMember : isBinaryExpWithParamMember . bind ( null , '!==' ) ,
143
139
isNegationOfParamMember : isNegationOfParamMember ,
144
140
isIdentifierOfParam : isIdentifierOfParam ,
145
141
isNegationExpression : isNegationExpression ,
0 commit comments