From efd3da3dee8d7d0ad71da877cbb28c00f8fbeaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Fri, 16 Oct 2020 22:55:57 +0200 Subject: [PATCH] [Fix] `jsx-handler-names`: Skip inline handlers when checkInlineFunction=false Fixes #2832 --- CHANGELOG.md | 2 ++ lib/rules/jsx-handler-names.js | 1 + tests/lib/rules/jsx-handler-names.js | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f28f2a308f..8b55101fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/rules/jsx-handler-names.js b/lib/rules/jsx-handler-names.js index e813ea66ef..ec181a2104 100644 --- a/lib/rules/jsx-handler-names.js +++ b/lib/rules/jsx-handler-names.js @@ -106,6 +106,7 @@ module.exports = { if ( !node.value || !node.value.expression + || (!checkInlineFunction && isInlineHandler(node)) || ( !checkLocal && (isInlineHandler(node) diff --git a/tests/lib/rules/jsx-handler-names.js b/tests/lib/rules/jsx-handler-names.js index eb65e50389..7625c142dd 100644 --- a/tests/lib/rules/jsx-handler-names.js +++ b/tests/lib/rules/jsx-handler-names.js @@ -59,6 +59,11 @@ ruleTester.run('jsx-handler-names', rule, { options: [{ checkLocalVariables: false }] + }, { + code: ' window.alert(event.target.value)} />', + options: [{ + checkInlineFunction: false + }] }, { code: ' handleChange()} />', options: [{