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

[new] add jsx-no-length-truthiness rule #2077

Closed

Conversation

krawaller
Copy link

After managing to introduce code like this into the code base of two different clients (in spite of regularly teaching React courses that include a warning against exactly this)...

arr.length && <List items={arr} /> // will render 0 when empty

...I thought it was high time to prevent myself from getting a third strike. Hence this added rule!

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While a rule to prevent this footgun might be useful, one that specifically focuses on length imo isn’t broad enough to be useful.

See #2073 as well (and generally it’s better to discuss new things on an issue before writing a PR; I’d hate you to feel like any work was in vain).

@krawaller
Copy link
Author

Doh, apologies, managed to completely miss that issue. Will continue discussion there!

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

Successfully merging this pull request may close these issues.

None yet

2 participants