Skip to content

Commit

Permalink
[Fix] jsx-handler-names: Skip inline handlers when checkInlineFunct…
Browse files Browse the repository at this point in the history
…ion=false

Fixes #2832
  • Loading branch information
onigoetz authored and ljharb committed Oct 16, 2020
1 parent aeff5ea commit efd3da3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

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

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

## [7.21.4] - 2020.10.09
Expand Down
1 change: 1 addition & 0 deletions lib/rules/jsx-handler-names.js
Expand Up @@ -106,6 +106,7 @@ module.exports = {
if (
!node.value
|| !node.value.expression
|| (!checkInlineFunction && isInlineHandler(node))
|| (
!checkLocal
&& (isInlineHandler(node)
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/jsx-handler-names.js
Expand Up @@ -59,6 +59,11 @@ ruleTester.run('jsx-handler-names', rule, {
options: [{
checkLocalVariables: false
}]
}, {
code: '<TestComponent onChange={event => window.alert(event.target.value)} />',
options: [{
checkInlineFunction: false
}]
}, {
code: '<TestComponent onChange={() => handleChange()} />',
options: [{
Expand Down

0 comments on commit efd3da3

Please sign in to comment.