Skip to content

Commit

Permalink
[Fix] jsx-handler-names: avoid a crash when an inline prop is not a…
Browse files Browse the repository at this point in the history
… MemberExpression

Fixes #2803.

Co-authored-by: Will Heslam <willheslam@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
willheslam and ljharb committed Sep 23, 2020
1 parent 0c412ef commit 67699eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

## Unreleased

### Fixed
* [`jsx-handler-names`]: avoid a crash when an inline prop is not a MemberExpression ([#2803][] @willheslam)

[#2803]: https://github.com/yannickcr/eslint-plugin-react/issues/2803

## [7.21.0] - 2020.09.22

### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jsx-handler-names.js
Expand Up @@ -109,7 +109,7 @@ module.exports = {
|| (
!checkLocal
&& (isInlineHandler(node)
? !node.value.expression.body.callee.object
? !node.value.expression.body.callee || !node.value.expression.body.callee.object
: !node.value.expression.object
)
)
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/jsx-handler-names.js
Expand Up @@ -70,6 +70,8 @@ ruleTester.run('jsx-handler-names', rule, {
options: [{
checkInlineFunction: true
}]
}, {
code: '<TestComponent onChange={() => 42} />'
}, {
code: '<TestComponent onChange={this.props.onFoo} />'
}, {
Expand Down

0 comments on commit 67699eb

Please sign in to comment.