-
-
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
report &&
in prop
#3719
Comments
i agree, this should be valid (altho |
One more thing is frustrating to me.
Why the plugin requires ternary all the time even when no potential unexpected result? Could we use the TypeScrypt parser to only report the potential errors? |
@A7med3bdulBaset specifically because a |
I understand well I know |
I agree that neither of those should be prevented when the type is known. |
Thanks @akulsr0 for working on this |
@ljharb, should I create an issue for this? |
@AhmedBaset if, with the latest unreleased code, you still have an issue, please do file one. |
|
More specifically, it should only complain if the left side is a known type and is not a number. This should also be an option, I'd think, because TS isn't actually "type safety" and folks may not want to rely on it. |
hmm. then, worth be an issue? |
Yes. |
Done in #3754 |
Seems like this issue is closed, but I think the code can be improved for checking if left side is boolean or not. Currently, the implementation only looks if the variable is assigned to a boolean in it's current scope. So it is not working if I am using a TS-typed component prop. I think this can be improved by actually checking TS-type of the variable on the left-side. Here is an example demonstrating the pain-point. I checked the codebase a bit, but could not find an easy way to get it right by checking the TS type. |
Is there an existing issue for this?
Description Overview
Imagine you have a prop (e.g.
isOpen
), you want to set the value asfirstCondition === true && anotherCondition === true
. Currently the plugin report wrongly this kind of code which should be valid.Expected Behavior
I expect to not throw
eslint-plugin-react version
7.34.1
eslint version
8.57.0
node version
18
The text was updated successfully, but these errors were encountered: