Skip to content

Commit 7862c66

Browse files
committed
Fix jsx-no-bind crash on arrow functions (fixes #854)
1 parent 6a94967 commit 7862c66

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/util/Components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ function componentRule(rule, context) {
275275
* @param {ASTNode} ASTnode The AST node being checked
276276
*/
277277
findReturnStatement: function(node) {
278-
if (!node.value || !node.value.body) {
278+
if (!node.value || !node.value.body || !node.value.body.body) {
279279
return false;
280280
}
281281
var i = node.value.body.body.length - 1;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ ruleTester.run('jsx-no-bind', rule, {
167167
errors: [{message: 'JSX props should not use .bind()'}],
168168
parser: 'babel-eslint'
169169
},
170+
{
171+
code: [
172+
'const foo = {',
173+
' render: ({onClick}) => (',
174+
' <div onClick={onClick.bind(this)}>Hello</div>',
175+
' )',
176+
'};'
177+
].join('\n'),
178+
errors: [{message: 'JSX props should not use .bind()'}],
179+
parser: 'babel-eslint'
180+
},
170181
{
171182
code: [
172183
'const foo = {',

0 commit comments

Comments
 (0)