# no-negated-condition 📝 Disallow negated conditions. 💼 This rule is enabled in the following [configs](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config): ✅ `recommended`, ☑️ `unopinionated`. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition. This is an improved version of the [`no-negated-condition`](https://eslint.org/docs/latest/rules/no-negated-condition) ESLint rule that makes it automatically fixable. [ESLint did not want to make it fixable.](https://github.com/eslint/eslint/issues/14792) ## Replacement for ESLint `no-negated-condition` This rule replaces ESLint's built-in `no-negated-condition` rule, which Unicorn presets disable when this rule is enabled. ## Examples ```js // ❌ if (!a) { doSomethingC(); } else { doSomethingB(); } // ✅ if (a) { doSomethingB(); } else { doSomethingC(); } ``` ```js // ❌ if (a !== b) { doSomethingC(); } else { doSomethingB(); } // ✅ if (a === b) { doSomethingB(); } else { doSomethingC(); } ``` ```js // ❌ !a ? c : b // ✅ a ? b : c ``` ```js // ❌ if (a != b) { doSomethingC(); } else { doSomethingB(); } // ✅ if (a == b) { doSomethingB(); } else { doSomethingC(); } ``` ```js // ✅ if (!a) { doSomething(); } ``` ```js // ✅ if (!a) { doSomething(); } else if (b) { doSomethingElse(); } ``` ```js // ✅ if (a != b) { doSomething(); } ```