Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

strict-boolean-expressions should ignore RHS of && and || #4158

Closed
dobesv opened this issue Sep 8, 2018 · 3 comments
Closed

strict-boolean-expressions should ignore RHS of && and || #4158

dobesv opened this issue Sep 8, 2018 · 3 comments

Comments

@dobesv
Copy link
Contributor

dobesv commented Sep 8, 2018

Idiomatic JavaScript / TypeScript typically treat || or && operators such that only the left operand is considered a "boolean expression" whereas the RHS might be any value that would be used as a result.

Currently an expression like process.env.PORT || 8080 gives an error with strict-boolean-expressions because it rejects the RHS for being "always truthy". This is a common enough pattern it should be accomodated by this rule.

This has already been discussed to some degree in #3279 but it doesn't have its own issue tracking it and I'm not sure what it's status is at this point.

I suggest an option to enable checking of the rhs of these operations, default would be not to check.

@JoshuaKGoldberg
Copy link
Contributor

Duplicate of #3279. Still accepting PRs! 😊

@dobesv
Copy link
Contributor Author

dobesv commented Nov 5, 2018

I did create a PR for this one, didn't I?

@JoshuaKGoldberg
Copy link
Contributor

Ha, yes (thanks for that, by the way!). Just closing duplicate issues to keep our issue count down.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants