Skip to content

Commit 67699eb

Browse files
willheslamljharb
andcommitted
[Fix] jsx-handler-names: avoid a crash when an inline prop is not a MemberExpression
Fixes #2803. Co-authored-by: Will Heslam <[email protected]> Co-authored-by: Jordan Harband <[email protected]>
1 parent 0c412ef commit 67699eb

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
55

66
## Unreleased
77

8+
### Fixed
9+
* [`jsx-handler-names`]: avoid a crash when an inline prop is not a MemberExpression ([#2803][] @willheslam)
10+
11+
[#2803]: https://github.com/yannickcr/eslint-plugin-react/issues/2803
12+
813
## [7.21.0] - 2020.09.22
914

1015
### Added

lib/rules/jsx-handler-names.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
|| (
110110
!checkLocal
111111
&& (isInlineHandler(node)
112-
? !node.value.expression.body.callee.object
112+
? !node.value.expression.body.callee || !node.value.expression.body.callee.object
113113
: !node.value.expression.object
114114
)
115115
)

tests/lib/rules/jsx-handler-names.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ ruleTester.run('jsx-handler-names', rule, {
7070
options: [{
7171
checkInlineFunction: true
7272
}]
73+
}, {
74+
code: '<TestComponent onChange={() => 42} />'
7375
}, {
7476
code: '<TestComponent onChange={this.props.onFoo} />'
7577
}, {

0 commit comments

Comments
 (0)