Skip to content

fix(linter): allow underscore-prefixed useState bindings - #25022

Open
Baltsat wants to merge 1 commit into
oxc-project:mainfrom
Baltsat:codex/fix-hook-use-state-underscore
Open

fix(linter): allow underscore-prefixed useState bindings#25022
Baltsat wants to merge 1 commit into
oxc-project:mainfrom
Baltsat:codex/fix-hook-use-state-underscore

Conversation

@Baltsat

@Baltsat Baltsat commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • treat an underscore-prefixed useState getter or setter as intentionally unused
  • skip the pair-name convention when either binding is intentionally unused
  • cover both exact _ placeholders and descriptive _unused... names on both tuple positions

Fixes #24952.

Proof

  • exact unpatched base reproduced all four false positives
  • focused react/hook-use-state rule test passed
  • cargo test -p oxc_linter: 1,175 passed, 0 failed, 1 ignored, plus integration tests and doctests
  • linter crate lint passed
  • formatting check passed
  • linter code generation completed without changing generated files
  • production-only revert made the four new cases fail; restoring the final tree returned the focused test to green
  • git diff --check passed

AI assistance: I used Codex during implementation and test iteration. I reviewed the final one-file diff, the rule behavior, and the complete proof above before submission.

AI-Assisted: Codex

User-Request: sustain proven OSS contribution velocity | codex:oss-maintainer-campaign
Signed-off-by: Konstantin Baltsat <baltsat2002@mail.ru>
@Baltsat
Baltsat requested a review from camc314 as a code owner July 28, 2026 13:24
Copilot AI review requested due to automatic review settings July 28, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@baevm

baevm commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

See also: #24952 (comment)

@Baltsat

Baltsat commented Jul 28, 2026

Copy link
Copy Markdown
Author

Yes — both upstream rules currently report these forms. This patch intentionally implements the narrower behavior requested in #24952: only an explicitly _-prefixed tuple binding is treated as an intentional placeholder; omitted or otherwise mismatched pairs remain errors.

So the project-level choice is whether Oxlint wants strict upstream parity here. If it does, #24952 is already expected behavior and this change should not land. If Oxlint wants to recognize the conventional explicit-unused marker, this patch keeps that divergence limited to the two requested positions and locks it with focused cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants