-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: jsx-no-leaked-render causes code to be incorrect by removing parentheses #3698
Comments
You say you’re using v18 of eslint-plugin-react, but that looks more like a react version - what version of the plugin are you using? |
When I said 'any,' I meant that it doesn't matter which value the second variable takes; it can be either true or false. This won't have an impact on the condition when the first value is false and the third one is true. Sorry for the confusion. eslint-plugin-react is v7.32.2 🤦♂️ |
That version should indeed have the fix. If the bug is indeed reproducible, then it needs a fix asap. |
I'm not sure if it matters; this condition is passed as a prop to the element (below is original condition):
I am reproducing this error in a few places, this is not the only one. |
what settings are you using in the rule? with |
Hey, just to check whether I understood correctly: eslint is fixing the mentioned conditional for you as you attached in the comment above? It is changing from As for settings, the settings I am using are: |
yes, that's correct, and no, && doesn't have precedence over || - it's identical precedence. |
However, that does change the semantics:
which makes it a seriously bad bug. |
Judging by the MDN docs, && has precedence over ||. Also, looking at the screenshot from the console, it seems that && has precedence. Regarding the bug, do you happen to know when we can expect this bug to be fixed? |
As you can see with It will be fixed when I have time to look into it, or when someone sends a PR. |
@ljharb Is this change live yet? How can I update to use the fixed rule? |
No, it’s not released yet. |
It's included in v7.34.1. |
Is there an existing issue for this?
Description Overview
I'm encountering an issue with a code transformation performed by the jsx-no-leaked-renderer.
Original condition:
connection && (hasError || hasErrorUpdate)
.Converted condition:
(!!connection && hasError) || hasErrorUpdate
.These conditions are not identical and produce different results for various inputs. For example, it will return different values for false, any, and true (respectively). In the first case it will return false, in the second it will return true.
Despite a reported issue and a pull request aimed at fixing this problem over a year ago, I'm still experiencing the same issue.
Am I missing something, or this is a bug?
Expected Behavior
I want to preserve original condition, or if it is converted, to be identical as original.
eslint-plugin-react version
v18.2.0
eslint version
v8.43.0
node version
v18.17.1
The text was updated successfully, but these errors were encountered: