Nucleus handler tools › Docs › Checks

A comparison with -0

Infono-compare-neg-zeroA general JavaScript mistake (ESLint's no-compare-neg-zero) · Worth knowing: it works, with a catch.

Why it matters

x === -0 is also true for 0. Use 1 / x === -Infinity if you really need to tell them apart.

Example

✗ Wrong

var x = 0;
if (x === -0) {
}

✓ Right

var x = 0;
if (x === 0) {
}

How to fix it

Compare with 0, or use 1 / x === -Infinity if the sign matters.

Turn it off, or change how it shows

Each check can be shown as an error, warning, info or hint, or turned off. VS Code: "splitscreenme.lint.rules": { "no-compare-neg-zero": "off" } in your settings. Notepad++: Plugins › Nucleus Co-op handlers › Settings. Command line: ncdev lint --rule no-compare-neg-zero=off. Other editors: the lint.rules setting of ncdev lsp.

Is this right? Tell us what's wrong
Stuck, or not sure? Ask other handler authors: Discordr/nucleuscoop