no-compare-neg-zero
eslint
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"no-compare-neg-zero": "error",
},
},
];if (x === -0) {
// doSomething()...
}if (x === 0) {
// doSomething()...
}if (Object.is(x, -0)) {
// doSomething()...
}Examples from the ESLint documentation.
no-compare-neg-zero
eslint
export default [
{
rules: {
"no-compare-neg-zero": "error",
},
},
];no-compare-neg-zero
eslint plugin · correctness
{
"rules": {
"no-compare-neg-zero": "error"
}
}suspicious/noCompareNegZero
suspicious · since 1.0.0
{
"linter": {
"rules": {
"suspicious": {
"noCompareNegZero": "error"
}
}
}
}Disallow using an async function as a Promise executor
Disallow characters which are made with multiple code points in character class syntax
Disallow negating the left operand of relational operators
Disallow control flow statements in finally blocks
Disallow irregular whitespace
Disallow unnecessary catch clauses