Skip to content

Commit e016332

Browse files
committed
Refactor isThisSetStateCallback function so it doesnt duplicate code
1 parent d1a477d commit e016332

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/rules/no-this-state-props.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ module.exports = {
3535

3636
function isThisSetStateCallback (node) {
3737
if ( node.parent && node.parent.type === 'CallExpression' ) {
38-
var callee = node.parent.callee;
38+
var parent = node.parent;
3939
var isMatching = (
40-
callee.type === 'MemberExpression' &&
41-
callee.object.type === 'ThisExpression' &&
42-
callee.property.name === 'setState' &&
43-
node.parent.arguments[1] === node
40+
isThisSetState(parent) &&
41+
parent.arguments &&
42+
parent.arguments.length > 1 &&
43+
parent.arguments[1] === node
4444
)
4545
return isMatching
4646
}

0 commit comments

Comments
 (0)