Skip to content

linter: react/hook-use-state false positives for intentionally _unused getter or setter names #24952

Description

@justingrant

What version of Oxlint are you using?

1.73.0

What command did you run?

oxlint -c .oxclint.json

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "categories": {
    "correctness": "off"
  },
  "plugins": ["react"],
  "rules": {
    "react/hook-use-state": "error"
  }
}

What happened?

A common pattern is to have write-only (or, less commonly, read-only) use of the useState hook. This rule should allow common "this is intentionally unused" patterns like the underscore prefix. For example, I'd like the code below to not trigger this rule.

const Component2 = () => {
  const [_, id] = useState(1);
}
const Component1 = () => {
  const [id, _] = useState(1);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions