Skip to content

fix(linter/vitest): Optimize hoisted_apis_on_top rule to only check first member#20068

Open
sidharthv96 wants to merge 1 commit intooxc-project:mainfrom
sidharthv96:sidv/fix_hoisted
Open

fix(linter/vitest): Optimize hoisted_apis_on_top rule to only check first member#20068
sidharthv96 wants to merge 1 commit intooxc-project:mainfrom
sidharthv96:sidv/fix_hoisted

Conversation

@sidharthv96
Copy link

Fixes the vitest/hoisted_apis_on_top to check only if the first member is a hoisted api.
This removes false positives like vi.mocked(something).mock... being flagged as hoisted.

Rule introduced in #17658

@sidharthv96 sidharthv96 requested a review from camc314 as a code owner March 6, 2026 11:21
Copilot AI review requested due to automatic review settings March 6, 2026 11:21
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Mar 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the vitest/hoisted_apis_on_top linter rule to avoid false positives by only treating a call as “hoisted” when the first member in the vi.* chain is a hoisted API (e.g., mock, hoisted, unmock), matching Vitest’s intended behavior.

Changes:

  • Change hoisted-API detection from “any member in the chain” to “only the first member”.
  • Add regression tests ensuring vi.mocked(...).mock.calls... chains are not flagged.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 6, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1


Comparing sidharthv96:sidv/fix_hoisted (85c7159) with main (3874ae1)

Open in CodSpeed

Footnotes

  1. 52 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.

@camc314 camc314 self-assigned this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants