{"record":{"id":"0023ce5bc22ad24c","repo":"oxc-project/oxc","slug":"expected-expected-and-instead-saw-actual","errorCode":null,"errorMessage":"Expected {expected} and instead saw {actual}","messagePattern":"Expected (.+?) and instead saw (.+?)","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/eqeqeq.rs","lineNumber":20,"sourceCode":"    AstKind,\n    ast::{BinaryExpression, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::operator::{BinaryOperator, UnaryOperator};\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    fixer::{RuleFix, RuleFixer},\n    rule::{Rule, TupleRuleConfig},\n};\n\nfn eqeqeq_diagnostic(actual: &str, expected: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Expected {expected} and instead saw {actual}\"))\n        .with_help(format!(\"Prefer {expected} operator\"))\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default)]\npub struct Eqeqeq(CompareType, EqeqeqOptions);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct EqeqeqOptions {\n    /// Configuration for whether to allow/disallow comparisons against `null`,\n    /// e.g. `foo == null` or `foo != null`\n    null: NullType,\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"kebab-case\")]","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/eqeqeq.rs#L2-L38","documentation":"Oxlint's port of the ESLint rule eqeqeq: equality comparisons must use `===`/`!==` unless an option carves out an exception. The message interpolates both operators (\"Expected '===' and instead saw '=='\") and the help suggests the strict operator. The rule config is a tuple — Eqeqeq(CompareType, EqeqeqOptions) at crates/oxc_linter/src/rules/eslint/eqeqeq.rs:17 — where CompareType selects `always` (default) or `smart`, and the options object has a `null` field controlling comparisons against null. The rule imports RuleFixer, so `--fix` rewrites the operator automatically.","triggerScenarios":"Any `==`/`!=` comparison under `always`; under `smart`, null comparisons and some literal-to-literal checks are permitted; a stricter `null` setting reports even `x == null`.","commonSituations":"Checking null-or-undefined with `x == null`; comparing user input against '' or 0 where coercion was assumed; migrating an ESLint config that relied on the deprecated \"allow-null\" value.","solutions":["Change `==` to `===` (and `!=` to `!==`) — the strict form is almost always the intended semantics.","For null-and-undefined checks write `x === null || x === undefined`, or run with `smart` so `x == null` stays allowed.","Run oxlint with `--fix` to auto-rewrite the operators.","Normalize operand types first (e.g. Number(value)) so strict equality compares like with like."],"exampleFix":"// before\nif (value == null) {\n  return;\n}\n\n// after\nif (value === null || value === undefined) {\n  return;\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — allow the idiomatic null check while forcing === elsewhere\n{\n  \"rules\": {\n    \"eqeqeq\": [\"warn\", \"smart\"]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type `===` by habit; reserve `== null` for the smart/null-allow configuration.","Run oxlint with `--fix` once after adopting the rule to clear the backlog.","Normalize types (Number(), String()) before comparing so strict equality behaves as intended."],"tags":["eslint","oxlint","equality","strict-equality","autofix"],"backgroundTag":"loose-equality-comparison","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"}