no-constant-condition
Last updated: Jan 16, 2025
NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"tags": ["recommended"]
}
}Enable full set using the Deno CLI:
deno lint --tags=recommended
Disallows the use of a constant expression in conditional test.
Using a constant expression in a conditional test is often either a mistake or a temporary situation introduced during development and is not ready for production.
Invalid:
if (true) {}
if (2) {}
do {} while (x = 2); // infinite loop
Valid:
if (x) {}
if (x === 0) {}
do {} while (x === 2);