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

jsx-no-leaked-render causes code to be incorrect by removing parentheses #3498

Closed
tcl333 opened this issue Nov 29, 2022 · 2 comments · Fixed by #3502
Closed

jsx-no-leaked-render causes code to be incorrect by removing parentheses #3498

tcl333 opened this issue Nov 29, 2022 · 2 comments · Fixed by #3502

Comments

@tcl333
Copy link

tcl333 commented Nov 29, 2022

// maybeObject: object | undefined
// isFoo: boolean
{maybeObject && (isFoo ? <Aaa /> : <Bbb />)}

// autofixes to:
{!!maybeObject && isFoo ? <Aaa /> : <Bbb />}

This has an entirely different meaning. My original code was hiding everything if maybeObject was undefined. The new code will display <Bbb /> instead.

To show how absurd this is, in other spot in my codebase, the else condition of the ternary was also maybeObject. This meant that my new code had a runtime error.

@ljharb
Copy link
Member

ljharb commented Nov 29, 2022

I agree; this is changing the semantics, which is unacceptable. The parens should be retained.

@akulsr0
Copy link
Contributor

akulsr0 commented Dec 15, 2022

@ljharb I have made a PR for it's fix, can you pls check once?

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

Successfully merging a pull request may close this issue.

3 participants