Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
stevensacks opened this issue Nov 20, 2024 · 2 comments
Open
2 tasks done

Comments

@stevensacks
Copy link

stevensacks commented Nov 20, 2024

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

@ljharb
Copy link
Member

ljharb commented Nov 21, 2024

Introspecting ternary expressions is not something that we do by default. I suppose we could, though.

@stevensacks stevensacks changed the title [Bug]: jsx-handler-names reports error with inline ternary conditional callbacks [Enhancement]: jsx-handler-names reports error with inline ternary conditional callbacks Nov 21, 2024
@stevensacks
Copy link
Author

I hope it's ok that I've changed the name to Enhancement. Since it's not technically a bug because it is not written to support this, it's a request for enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants