Skip to content

Commit 70d72dc

Browse files
committed
[jsx-no-bind] Ensure node is MemberExpression before checking property name
1 parent 8ac35f5 commit 70d72dc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/rules/jsx-no-bind.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = function(context) {
2121
if (
2222
!configuration.allowBind &&
2323
valueNode.type === 'CallExpression' &&
24+
valueNode.callee.type === 'MemberExpression' &&
2425
valueNode.callee.property.name === 'bind'
2526
) {
2627
context.report(node, 'JSX props should not use .bind()');

tests/lib/rules/jsx-no-bind.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ ruleTester.run('jsx-no-bind', rule, {
2929
code: '<div meaningOfLife={42}></div>',
3030
parser: 'babel-eslint'
3131
},
32+
{
33+
code: '<div onClick={getHandler()}></div>',
34+
parser: 'babel-eslint'
35+
},
3236

3337
// bind() explicitly allowed
3438
{

0 commit comments

Comments
 (0)