{"record":{"id":"de8924528ba1fffb","repo":"oxc-project/oxc","slug":"the-literal-is-not-a-valid-dependency-because-it-n","errorCode":null,"errorMessage":"The literal is not a valid dependency because it never changes.","messagePattern":"The literal is not a valid dependency because it never changes\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":141,"sourceCode":"\nfn unnecessary_dependency_diagnostic(hook_name: &str, dep_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"React Hook {hook_name} has unnecessary dependency: {dep_name}\"))\n        .with_label(span)\n        .with_help(\"Either include it or remove the dependency array.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn dependency_array_not_array_literal_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies.\"\n    ))\n    .with_label(span)\n    .with_help(\"Use an array literal as the second argument.\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn literal_in_dependency_array_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"The literal is not a valid dependency because it never changes.\")\n        .with_label(span)\n        .with_help(\"Remove the literal from the array.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn duplicate_dependency_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"This dependency is specified more than once in the dependency array.\")\n        .with_label(span)\n        .with_help(\"Remove the duplicate dependency from the array.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn complex_expression_in_dependency_array_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} has a complex expression in the dependency array.\",\n    ))\n    .with_label(span)\n    .with_help(\"Extract the expression to a separate variable so it can be statically checked.\")","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L123-L159","documentation":"Raised by react/exhaustive-deps when a literal (string, number, boolean) appears in a dependency array. Literals never change, so listing them as dependencies is meaningless and hides real dependencies.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the literal from the dependency array.","Replace it with the reactive value the literal was meant to represent."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1f902a69625cd14e6d8dc58feca94da099d2d251","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}