no-compare-neg-zero
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-compare-neg-zero"],
"exclude": ["no-compare-neg-zero"]
}
}
}Disallows comparing against negative zero (-0).
Comparing a value directly against negative may not work as expected as it will
also pass for non-negative zero (i.e. 0 and +0). Explicit comparison with
negative zero can be performed using Object.is.
Invalid:
if (x === -0) {}
Valid:
if (x === 0) {}
if (Object.is(x, -0)) {}