-
Notifications
You must be signed in to change notification settings - Fork 889
New rule to only allow boolean statements in logical expressions #253
Comments
the "unless expr is a boolean" might be troublesome since we don't use the typing annotations from the compiler yet. we'll need to investigate that. |
I think the new TS APIs have support for type information about nodes. This should be doable. |
blocked on #680 |
See microsoft/TypeScript#9702 as well, although as far as I can tell they haven't decided to implement this yet. This shouldn't be too hard to do now on our end! |
I would really like this to help with not coercing promise-like types to booleans, but I think it would be really nice if we could explicitly enable certain types (strings, numbers) for coercion. |
Would it be able to pick up things such as |
yes, that check should probably be incorporated into this lint rule. |
This would be really handy and catch so many bugs. |
fixed via #1820 |
Disallow if (expr) unless expr is a boolean.
So no if (obj)... rather if (obj != null)
The text was updated successfully, but these errors were encountered: