Skip to content

Commit efd3da3

Browse files
onigoetzljharb
authored andcommitted
[Fix] jsx-handler-names: Skip inline handlers when checkInlineFunction=false
Fixes #2832
1 parent aeff5ea commit efd3da3

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
77

88
### Fixed
99
* [`jsx-indent-props`]: Apply indentation when using brackets ([#2826][] @Moong0122)
10+
* [`jsx-handler-names`]: Skip inline handlers when checkInlineFunction=false ([#2833][] @onigoetz)
1011

12+
[#2833]: https://github.com/yannickcr/eslint-plugin-react/issues/2833
1113
[#2826]: https://github.com/yannickcr/eslint-plugin-react/issues/2826
1214

1315
## [7.21.4] - 2020.10.09

lib/rules/jsx-handler-names.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ module.exports = {
106106
if (
107107
!node.value
108108
|| !node.value.expression
109+
|| (!checkInlineFunction && isInlineHandler(node))
109110
|| (
110111
!checkLocal
111112
&& (isInlineHandler(node)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ ruleTester.run('jsx-handler-names', rule, {
5959
options: [{
6060
checkLocalVariables: false
6161
}]
62+
}, {
63+
code: '<TestComponent onChange={event => window.alert(event.target.value)} />',
64+
options: [{
65+
checkInlineFunction: false
66+
}]
6267
}, {
6368
code: '<TestComponent onChange={() => handleChange()} />',
6469
options: [{

0 commit comments

Comments
 (0)