Skip to content

feat(useHookAtTopLevel): add ignore option#8964

Merged
dyc3 merged 1 commit intonextfrom
dyc3/use-hook-at-top-level-ignore
Feb 4, 2026
Merged

feat(useHookAtTopLevel): add ignore option#8964
dyc3 merged 1 commit intonextfrom
dyc3/use-hook-at-top-level-ignore

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Feb 4, 2026

Summary

requested here: #7097 (comment)

Test Plan

snapshots

Docs

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

🦋 Changeset detected

Latest commit: e96b2f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-win32-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/wasm-web Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/backend-jsonrpc Patch
@biomejs/js-api Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dyc3 dyc3 added this to the Biome v2.4 milestone Feb 4, 2026
@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Feb 4, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 4, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing dyc3/use-hook-at-top-level-ignore (e96b2f5) with next (d11130b)

Summary

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1

Footnotes

  1. 95 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@dyc3 dyc3 force-pushed the dyc3/use-hook-at-top-level-ignore branch from e8501bb to fc3e73f Compare February 4, 2026 12:53
@dyc3 dyc3 marked this pull request as ready for review February 4, 2026 12:54
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Walkthrough

This PR introduces an ignore configuration option to the useHookAtTopLevel linter rule. The option allows specifying a list of function names that should be excluded from hook-at-top-level analysis, even if they follow the use* naming convention. The implementation adds an early exit in the lint rule when a hook name matches the ignore set, updates the options structure with a new optional ignore field, and includes comprehensive test coverage.

Possibly related PRs

Suggested reviewers

  • arendjr
  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding an ignore option to the useHookAtTopLevel linter rule.
Description check ✅ Passed The description relates to the changeset, referencing the feature request issue and providing test details, though it could be more detailed about the implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dyc3/use-hook-at-top-level-ignore

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Snapshots are incorrect

@dyc3 dyc3 force-pushed the dyc3/use-hook-at-top-level-ignore branch from fc3e73f to e96b2f5 Compare February 4, 2026 14:42
@dyc3 dyc3 requested a review from ematipico February 4, 2026 14:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@crates/biome_js_analyze/tests/specs/correctness/useHookAtTopLevel/invalid-ignoreOption.js`:
- Around line 1-9: The test file declares it should generate diagnostics but
contains Component3 which calls useIgnoredHook (an ignored hook), so it won't
produce a diagnostic and duplicates the valid-ignoreOption test; either remove
the Component3 function block (lines defining function Component3 and its body)
from this invalid file, or change the hook call to a non-ignored hook name
(e.g., replace useIgnoredHook with a non-ignored symbol like useFooHook) so that
Component3 actually triggers the intended diagnostic; locate the Component3
function and update or delete it accordingly.

Comment on lines +1 to +9
/* should generate diagnostics */

// Valid: ignored hook after early return
function Component3({ a }) {
if (a != 1) {
return;
}
useIgnoredHook();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Test case mismatch: Component3 shouldn't be in the invalid file.

The file header states "should generate diagnostics", but Component3 uses useIgnoredHook which is in the ignore list—so it won't produce a diagnostic. This appears to be a duplicate of the same test in valid-ignoreOption.js.

Consider removing lines 3-9, or if you intended to test something different here, update the hook name to a non-ignored one.

🤖 Prompt for AI Agents
In
`@crates/biome_js_analyze/tests/specs/correctness/useHookAtTopLevel/invalid-ignoreOption.js`
around lines 1 - 9, The test file declares it should generate diagnostics but
contains Component3 which calls useIgnoredHook (an ignored hook), so it won't
produce a diagnostic and duplicates the valid-ignoreOption test; either remove
the Component3 function block (lines defining function Component3 and its body)
from this invalid file, or change the hook call to a non-ignored hook name
(e.g., replace useIgnoredHook with a non-ignored symbol like useFooHook) so that
Component3 actually triggers the intended diagnostic; locate the Component3
function and update or delete it accordingly.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Easy peasy!

@dyc3 dyc3 merged commit 0353fa0 into next Feb 4, 2026
17 checks passed
@dyc3 dyc3 deleted the dyc3/use-hook-at-top-level-ignore branch February 4, 2026 16:03
@github-actions github-actions bot mentioned this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants