{"record":{"id":"8fbdc3ff7d7bcbf2","repo":"oxc-project/oxc","slug":"use-prop-name-op-and-rhs-when-checking-pro","errorCode":null,"errorMessage":"Use `.{prop_name} {op_and_rhs}` when checking {prop_name} is not zero.","messagePattern":"Use `\\.(.+?) (.+?)` when checking (.+?) is not zero\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/explicit_length_check.rs","lineNumber":23,"sourceCode":"use oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse oxc_syntax::operator::{BinaryOperator, LogicalOperator};\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    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}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/explicit_length_check.rs#L5-L41","documentation":"Raised by unicorn/explicit-length-check when code tests truthiness of a length property (if (arr.length)) instead of explicitly comparing against zero. Truthiness checks are less clear and can hide intent.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/explicit_length_check.rs:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Write the explicit comparison: if (arr.length > 0) (or the operator form suggested by the diagnostic).","Configure the rule's mode (greater-than, not-equal, equal) to the project convention."],"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"}