no-extra-boolean-cast
NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-extra-boolean-cast"],
"exclude": ["no-extra-boolean-cast"]
}
}
}Disallows unnecessary boolean casts.
In certain contexts, such as if, while or for statements, expressions are
automatically coerced into a boolean. Therefore, techniques such as double
negation (!!foo) or casting (Boolean(foo)) are unnecessary and produce the
same result as without the negation or casting.
Invalid:
if (!!foo) {}
if (Boolean(foo)) {}
while (!!foo) {}
for (; Boolean(foo);) {}
Valid:
if (foo) {}
while (foo) {}
for (; foo;) {}