{"record":{"id":"aff75d5ab867e0fd","repo":"oxc-project/oxc","slug":"usestate-call-does-not-follow-the-thing-setthing","errorCode":null,"errorMessage":"useState call does not follow the [thing, setThing] naming convention","messagePattern":"useState call does not follow the \\[thing, setThing\\] naming convention","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/hook_use_state.rs","lineNumber":24,"sourceCode":"};\nuse oxc_ast::{AstKind, ast::BindingPattern};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nfn require_to_destruct(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"useState call is not destructured into value + setter pair\")\n        .with_help(\n            \"Destructure useState call into value + setter pair \\\n            follow the [thing, setThing] naming convention\",\n        )\n        .with_label(span)\n}\n\nfn follow_naming_convention(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"useState call does not follow the [thing, setThing] naming convention\")\n        .with_help(\"Follow the [thing, setThing] naming convention\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\nstruct HookUseStateConfig {\n    /// When true the rule will ignore the name of the destructured value.\n    allow_destructured_state: bool,\n}\n\n#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)]\npub struct HookUseState(HookUseStateConfig);\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Ensure destructuring and symmetric naming of useState hook value and setter variables.","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/hook_use_state.rs#L6-L42","documentation":"Raised by react/hook_use_state when useState is array-destructured but the setter name does not follow the `[thing, setThing]` convention (the second element should be `set` plus the PascalCase first element name). At the throw site the naming breaks the predictable setter convention the rule enforces, hurting readability and tooling heuristics. follow_naming_convention fires from run() after confirming destructuring occurred but before accepting the binding names.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/hook_use_state.rs:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the setter to setXxx matching the value name.","Adjust the destructured value name so the pair follows [thing, setThing]."],"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-14T00:17:10.932Z"}