{"record":{"id":"55c56fe875a13e25","repo":"oxc-project/oxc","slug":"do-not-use-null-literals","errorCode":null,"errorMessage":"Do not use `null` literals","messagePattern":"Do not use `null` literals","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_null.rs","lineNumber":25,"sourceCode":"};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::operator::BinaryOperator;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\nuse serde_json::Value;\n\nuse crate::{\n    AstNode,\n    ast_util::{is_method_call, iter_outer_expressions},\n    context::LintContext,\n    fixer::{RuleFix, RuleFixer},\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_null_diagnostic(null: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not use `null` literals\").with_label(null)\n}\n\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoNull {\n    /// When set to `true`, the rule will also check strict equality/inequality comparisons (`===` and `!==`) against `null`.\n    check_strict_equality: bool,\n    /// When set to `true`, disallow the use of `null` as a direct function call or constructor argument.\n    check_arguments: bool,\n}\n\nimpl Default for NoNull {\n    fn default() -> Self {\n        Self { check_strict_equality: false, check_arguments: true }\n    }\n}\n\ndeclare_oxc_lint!(","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_null.rs#L7-L43","documentation":"Raised by unicorn/no-null when a `null` literal is used in code the rule flags (variable declarators, binary expressions, etc.) and no allowed exception applies. The rule promotes `undefined` over `null`; the faulting input is the null literal at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_null.rs:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use `undefined` instead of `null` as the absent value","Allow specific comparisons or declarations via the rule's configuration if a genuine null case exists","Refactor APIs to return `undefined` or option objects rather than null sentinels"],"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"}