# no-inverted-boolean-check

Rule `sonarjs/no-inverted-boolean-check`. Boolean checks should not be inverted

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1293 by reach, #594 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-inverted-boolean-check` | yes | suggestion | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-1940/) |

## Code examples

### Incorrect: the rule reports this

```js
if (!(a === 2)) { ... }  // Noncompliant
```

### Correct: the rule accepts this

```js
if (a !== 2) { ... }
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-inverted-boolean-check": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-invariant-returns](https://lintradar.dev/rules/sonarjs/no-invariant-returns.md): Function returns should not be invariant
- [sonarjs/no-labels](https://lintradar.dev/rules/sonarjs/no-labels.md): Labels should not be used
- [sonarjs/no-invalid-regexp](https://lintradar.dev/rules/sonarjs/no-invalid-regexp.md): Regular expressions should be syntactically valid
- [sonarjs/no-literal-call](https://lintradar.dev/rules/sonarjs/no-literal-call.md): Literals should not be used as functions
- [sonarjs/no-interpolation-in-inline-snapshots](https://lintradar.dev/rules/sonarjs/no-interpolation-in-inline-snapshots.md): Inline snapshots should not contain interpolations
- [sonarjs/no-mime-sniff](https://lintradar.dev/rules/sonarjs/no-mime-sniff.md): Browsers should not be allowed to perform MIME type sniffing

---

Web page: https://lintradar.dev/rules/sonarjs/no-inverted-boolean-check. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
