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

chore: add lint rule for conditional jsx rendering strict boolean checks #10516

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

pskelin
Copy link
Contributor

@pskelin pskelin commented Jan 10, 2025

when using conditional rendering in JSX, array length has to be treated more carefully
when ar = []

// this will render `0`
{{ ar.length && <div>content</div> }}

correct usage is to use a boolean

// this will render ``
{{ ar.length > 0 && <div>content</div> }}

There are more complicated cases however where a getter from the component is used with more logical expressions and types, so this change is adding an eslint rule and fixes other problematic spots.

FIXES: #10509

@pskelin pskelin merged commit eb44feb into main Jan 10, 2025
10 checks passed
@pskelin pskelin deleted the jsx-conditional-lint branch January 10, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants