> 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-negated-condition

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


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

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

## Rule Details

Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead.

This rule disallows negated conditions in either of the following:

- `if` statements which have an `else` branch
- ternary expressions

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

```javascript
if (!a) {
  doSomething();
} else {
  doSomethingElse();
}

if (a != b) {
  doSomething();
} else {
  doSomethingElse();
}

if (a !== b) {
  doSomething();
} else {
  doSomethingElse();
}

!a ? c : b;
```

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

```javascript
if (!a) {
  doSomething();
}

if (!a) {
  doSomething();
} else if (b) {
  doSomething();
}

if (a != b) {
  doSomething();
}

a ? b : c;
```

## Original Documentation

- [ESLint: no-negated-condition](https://eslint.org/docs/latest/rules/no-negated-condition)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-negated-condition.js)
