hook-use-state
Added in v0.9.1Configuration
rslint.config.ts
Require useState calls to be destructured into a value and matching setter
pair.
Rule Details
This rule ensures that a React useState call uses a symmetric
[value, setValue] destructure. Returning a useState result directly is
allowed.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
allowDestructuredState defaults to false. When enabled, the value part may
itself be destructured, provided the setter remains a simple binding.
Examples of correct code for this rule with
{ "allowDestructuredState": true }: