{"record":{"id":"e7db54198166849c","repo":"oxc-project/oxc","slug":"negated-expression-is-not-allowed-in-equality-chec","errorCode":null,"errorMessage":"Negated expression is not allowed in equality check.","messagePattern":"Negated expression is not allowed in equality check\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_negation_in_equality_check.rs","lineNumber":15,"sourceCode":"use oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::identifier::is_identifier_start;\nuse oxc_syntax::operator::{BinaryOperator, UnaryOperator};\n\nuse crate::{AstNode, ast_util, context::LintContext, rule::Rule};\n\nfn no_negation_in_equality_check_diagnostic(\n    span: Span,\n    current_operator: BinaryOperator,\n    suggested_operator: BinaryOperator,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Negated expression is not allowed in equality check.\")\n        .with_help(format!(\n            \"Remove the negation operator and use '{}' instead of '{}'.\",\n            suggested_operator.as_str(),\n            current_operator.as_str()\n        ))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoNegationInEqualityCheck;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow negated expressions on the left of (in)equality checks.\n    ///\n    /// ### Why is this bad?\n    ///","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_negation_in_equality_check.rs#L1-L33","documentation":"Raised by unicorn/no-negation-in-equality-check when one operand of an equality/inequality comparison (==, !=, ===, !==) is a negation (`!x`). The helper receives the current and suggested operators to build advice (e.g. swap === for !==); the faulting input is the negated operand comparison at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_negation_in_equality_check.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop the negation and use the opposite operator: `!a === b` → `a !== b`","Move the negation outside the whole comparison if it applies to the result: `!(a === b)`","Restructure the boolean expression so no operand is negated"],"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-14T05:17:10.506Z"}