{"record":{"id":"534e44c5ecac555a","repo":"oxc-project/oxc","slug":"use-prop-name-op-and-rhs-when-checking-pro-534e44","errorCode":null,"errorMessage":"Use `.{prop_name} {op_and_rhs}` when checking {prop_name} is zero.","messagePattern":"Use `\\.(.+?) (.+?)` when checking (.+?) is zero\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/explicit_length_check.rs","lineNumber":34,"sourceCode":"    utils::{\n        expression_uses_optional_chain, get_boolean_ancestor, is_boolean_call, is_boolean_node,\n        pad_fix_with_token_boundary,\n    },\n};\n\nfn non_zero(span: Span, prop_name: &str, op_and_rhs: &str, help: Option<String>) -> OxcDiagnostic {\n    let mut d = OxcDiagnostic::warn(format!(\n        \"Use `.{prop_name} {op_and_rhs}` when checking {prop_name} is not zero.\"\n    ))\n    .with_label(span);\n    if let Some(x) = help {\n        d = d.with_help(x);\n    }\n    d\n}\n\nfn zero(span: Span, prop_name: &str, op_and_rhs: &str, help: Option<String>) -> OxcDiagnostic {\n    let mut d = OxcDiagnostic::warn(format!(\n        \"Use `.{prop_name} {op_and_rhs}` when checking {prop_name} is zero.\"\n    ));\n    if let Some(x) = help {\n        d = d.with_help(x);\n    }\n    d.with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"kebab-case\")]\nenum NonZero {\n    /// Enforces non-zero to be checked with `foo.length > 0`.\n    #[default]\n    GreaterThan,\n    /// Enforces non-zero to be checked with `foo.length !== 0`.\n    NotEqual,\n}\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/explicit_length_check.rs#L16-L52","documentation":"Raised by unicorn/explicit-length-check when code checks a non-zero length via a non-explicit comparison while checking for the empty case, e.g. if (arr.length === 0) else-branches should use the explicit non-zero form.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/explicit_length_check.rs:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the explicit comparison form suggested in the message, e.g. arr.length !== 0 or arr.length > 0.","Align the comparison operator with the configured rule mode."],"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"}