Search code examples
eslinttslint

Is there a TSLint/ESLint rule to prevent (boolean === true) type of comparisons?


Is there a TSLint/ESLint rule to prevent unnecessary boolean comparison like:

if (result === false) {
  // do something
} 

Solution

  • TSLint supports rule no-boolean-literal-compare which does just this.

    "no-boolean-literal-compare": true in the rules array will enable this feature.

    Documentation link: https://palantir.github.io/tslint/rules/no-boolean-literal-compare/