{"record":{"id":"b19458680811aa11","repo":"oxc-project/oxc","slug":"unexpected-negated-condition","errorCode":null,"errorMessage":"Unexpected negated condition.","messagePattern":"Unexpected negated condition\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/shared/eslint_unicorn/no_negated_condition.rs","lineNumber":21,"sourceCode":"    ast::{ConditionalExpression, Expression, IfStatement, Statement},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::{\n    identifier::is_identifier_part,\n    line_terminator::is_line_terminator,\n    operator::{BinaryOperator, UnaryOperator},\n};\n\nuse crate::{\n    AstNode,\n    ast_util::could_be_asi_hazard,\n    context::LintContext,\n    fixer::{RuleFix, RuleFixer},\n};\n\nfn no_negated_condition_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected negated condition.\")\n        .with_help(\"Remove the negation operator and switch the consequent and alternate branches.\")\n        .with_label(span)\n}\n\npub const DOCUMENTATION: &str = r\"### What it does\n\nDisallow negated conditions.\n\n### Why is this bad?\n\nNegated conditions are more difficult to understand. Code can be made more readable by inverting the condition.\n\n### Examples\n\nExamples of **incorrect** code for this rule:\n```javascript\nif (!a) {\n\tdoSomethingC();","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/eslint_unicorn/no_negated_condition.rs#L3-L39","documentation":"Raised by no-negated-condition (eslint/unicorn shared) when an if/else or conditional expression tests a negated condition with both branches present. Inverting the condition makes the happy path more readable.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/shared/eslint_unicorn/no_negated_condition.rs:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the negation operator and swap the if/else branches.","If there is no else branch, keep the negation (the rule only fires when both branches exist)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}