oxc-project/oxc · error · OxcDiagnostic
useState call does not follow the [thing, setThing] naming c
Error message
useState call does not follow the [thing, setThing] naming convention
What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/react/hook_use_state.rs:24
};
use oxc_ast::{AstKind, ast::BindingPattern};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
fn require_to_destruct(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("useState call is not destructured into value + setter pair")
.with_help(
"Destructure useState call into value + setter pair \
follow the [thing, setThing] naming convention",
)
.with_label(span)
}
fn follow_naming_convention(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("useState call does not follow the [thing, setThing] naming convention")
.with_help("Follow the [thing, setThing] naming convention")
.with_label(span)
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
struct HookUseStateConfig {
/// When true the rule will ignore the name of the destructured value.
allow_destructured_state: bool,
}
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)]
pub struct HookUseState(HookUseStateConfig);
declare_oxc_lint!(
/// ### What it does
///
/// Ensure destructuring and symmetric naming of useState hook value and setter variables.View on GitHub (pinned to e1e7af627c)
Solutions
- Rename the setter to setXxx matching the value name.
- Adjust the destructured value name so the pair follows [thing, setThing].
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/hook_use_state.rs:24 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/aff75d5ab867e0fd.
Report an issue: GitHub.