3 ms·
> Ideally this lint would ignore if (false) and if (true), even though these are still constant binary expressions, I don't think they are: binary expressions
by dragonwriter 3y ago
> Ideally this lint would ignore if (false) and if (true), even though these are still constant binary expressions,
I don't think they are: binary expressions affected are expressions constructed with binary logical or comparison operator (==, ===, &&, ||, ??).
true and false each aren't binary expressions, they are simple constant values, and the lint isn't for constant conditionals.
(The rule for that is no-constant-condition.)
- captbaritone 3y agoExactly right. And no-constant-expression is configurable to allow trivial constant expressions for exactly the reason the parent commenter raised.