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

Rule Suggestion: disallow explicit boolean comparisons #1910

Closed
ChrisMBarr opened this issue Dec 20, 2016 · 0 comments
Closed

Rule Suggestion: disallow explicit boolean comparisons #1910

ChrisMBarr opened this issue Dec 20, 2016 · 0 comments

Comments

@ChrisMBarr
Copy link
Contributor

Novice programmers might have something like this

let foo = true;
// other code...

if (foo === true) {
  //do something...
}

or maybe

if (foo !== false) {
  //do something...
}

(I have seen both of these in real code!)

When foo is a boolean, this is unnecessary and could result in a linting violation. However if foo can be something else like foo: true | number | null then these explicit checks should be allowed.

perhaps this could be added as an option to the existing strict-boolean-expressions rule?

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

No branches or pull requests

2 participants