> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-compare-neg-zero

[Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14)
## Configuration

| Preset                   | Configured Value |
| ------------------------ | ---------------- |
| ✅ js.configs.recommended | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-compare-neg-zero': 'error',
    },
  },
]);
```

## Rule Details

Disallows comparing against `-0` using equality and relational operators (`==`, `===`, `!=`, `!==`, `>`, `>=`, `<`, `<=`). Comparing directly to `-0` does not work as intended because `+0 === -0` is `true`. To check whether a value is `-0`, use `Object.is(x, -0)` instead.

Examples of **incorrect** code for this rule:

```javascript
if (x === -0) {
}

if (x == -0) {
}

if (x > -0) {
}

if (x !== -0) {
}
```

Examples of **correct** code for this rule:

```javascript
if (x === 0) {
}

if (Object.is(x, -0)) {
}

if (x > 0) {
}
```

## Original Documentation

- [ESLint: no-compare-neg-zero](https://eslint.org/docs/latest/rules/no-compare-neg-zero)
- [Source code](https://github.com/eslint/eslint/blob/v9.39.1/lib/rules/no-compare-neg-zero.js)
