jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
8.86k stars 2.75k forks source link

`jsx-no-leaked-render` can work better if it checks the TS type of the left-side value #3761

Closed yusufkinatas closed 1 month ago

yusufkinatas commented 1 month ago

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.

image

I checked the codebase a bit, but could not find an easy way to get it right by checking the TS type. I think we need to somehow get to what IDE shows as variable type when hovered. Screenshot 2024-05-29 at 12 09 19

PS: This post originated from this comment. But I am sure if it makes sense to add new comments to a closed issue. So I opened this as a new one.

Related issue: https://github.com/jsx-eslint/eslint-plugin-react/issues/3719

AhmedBaset commented 1 month ago

Duplicate of #3754