jsx-eslint/eslint-plugin-react

[Enhancement]: jsx-handler-names reports error with inline ternary conditional callbacks

Open

#3.855 geöffnet am 20. Nov. 2024

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.797 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (8.630 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

Conditionally applying callback functions with inline ternary statements violates the rule, even when the condition will satisfy the rule.

<MyComponent
  onClick={isClickDisabled ? undefined : handleClick}
/>
ESLint: Handler function for onClickNext prop key must be a camelCase name beginning with 'handle' only(react/ jsx-handler-names)

Expected Behavior

If there is an inline ternary condition and it returns the properly named function, it should pass.

eslint-plugin-react version

v7.37.2

eslint version

v8.57.0

node version

v20.17.0

Contributor Guide