# no-negated-condition

Rule `unicorn/no-negated-condition`. Disallow negated conditions.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 12M weekly downloads of presets that enable it
- Trend: +40.1% last quarter
- Rank: #763 by reach, #959 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-negated-condition` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-negated-condition.md) |
| Oxlint | `unicorn/no-negated-condition` | no | safe | plugin `unicorn`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-negated-condition.html) |
| Biome | `style/noNegationElse` | no | safe | group style, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/no-negation-else/) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = !a && !b ? x : y;
```

```js
const foo = a != null && b != null ? x : y;
```

```js
if (!a || !b) {
  x();
} else {
  y();
}
```

### Correct: the rule accepts this

```js
const foo = a || b ? y : x;
```

```js
const foo = a == null || b == null ? y : x;
```

```js
if (a && b) {
  y();
} else {
  x();
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-negated-condition": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/no-negated-condition": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "noNegationElse": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [eslint/no-negated-condition](https://lintradar.dev/rules/eslint/no-negated-condition.md): Disallow negated conditions
- [vue/no-negated-condition](https://lintradar.dev/rules/vue/no-negated-condition.md): Disallow negated conditions in `<template>`
- [unicorn/filename-case](https://lintradar.dev/rules/unicorn/filename-case.md): Enforce a case style for filenames and directory names.
- [unicorn/no-negation-in-equality-check](https://lintradar.dev/rules/unicorn/no-negation-in-equality-check.md): Disallow negated expression in equality check.
- [unicorn/consistent-existence-index-check](https://lintradar.dev/rules/unicorn/consistent-existence-index-check.md): Enforce consistent style for element existence checks with `indexOf()`, `lastIndexOf()`, `findIndex()`, and `findLastIndex()`.
- [unicorn/no-static-only-class](https://lintradar.dev/rules/unicorn/no-static-only-class.md): Disallow classes that only have static members.

---

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