Skip to content

fix(useAwait): treat yield* as async operation in async generators#8978

Merged
ematipico merged 1 commit intobiomejs:mainfrom
FrankFMY:fix/use-await-yield-star
Feb 6, 2026
Merged

fix(useAwait): treat yield* as async operation in async generators#8978
ematipico merged 1 commit intobiomejs:mainfrom
FrankFMY:fix/use-await-yield-star

Conversation

@FrankFMY
Copy link
Contributor

@FrankFMY FrankFMY commented Feb 5, 2026

Summary

Fixes #8645.

yield* in an async generator function delegates to an AsyncIterable, which requires the async modifier. The useAwait rule was incorrectly flagging these functions as missing await.

This PR adds yield* (i.e. JsYieldExpression with a star_token) to the set of expressions recognized as async operations by the MissingAwaitVisitor, alongside await and for await...of.

Changes

  • use_await.rs: Added a check for JsYieldExpression with star_token() in the visitor's WalkEvent::Enter branch
  • valid.js: Added test cases for async function* with yield*
  • invalid.js: Added test case for async function* with plain yield (should still be flagged)
  • Updated snapshots

Test plan

  • cargo test -p biome_js_analyze -- use_await — all 4 tests pass
  • Valid: async function* yieldStarAsyncIterable() { yield* otherAsyncGenerator(); } — no diagnostic
  • Invalid: async function* yieldWithoutStar() { yield 1; } — correctly flagged

yield* in an async generator delegates to an AsyncIterable, which
requires the async modifier. The useAwait rule now recognizes yield*
as an async operation and no longer incorrectly reports these functions.

Fixes biomejs#8645
@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 3f3e4e7

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

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

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

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Feb 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Walkthrough

This pull request fixes the useAwait linter rule to correctly handle async generator functions that use yield* delegation. Previously, the rule would incorrectly flag async generators using yield* as not requiring the async modifier. The fix introduces detection for yield* expressions with async iterables and includes test cases to validate both invalid patterns (regular yield without star) and valid patterns (async generators properly delegating via yield*).

Suggested labels

A-Linter, L-JavaScript, A-Diagnostic

Suggested reviewers

  • Conaclos
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing the useAwait rule to recognize yield* as an async operation in async generators.
Description check ✅ Passed The description is well-detailed and clearly related to the changeset, explaining the problem, solution, and test results for the yield* delegation fix.
Linked Issues check ✅ Passed The PR fully addresses issue #8645 by implementing detection of yield* as an async operation in the useAwait rule, preventing false positives when delegating to async iterables.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the useAwait rule for yield* expressions; no unrelated modifications are present.

✏️ 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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 6, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing FrankFMY:fix/use-await-yield-star (3f3e4e7) with main (51c158e)1

Summary

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks2

Footnotes

  1. No successful run was found on main (5a341b2) during the generation of this report, so 51c158e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 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.

@ematipico
Copy link
Member

Another AI PR not disclosed...

@ematipico ematipico merged commit cc7a478 into biomejs:main Feb 6, 2026
18 checks passed
@github-actions github-actions bot mentioned this pull request Feb 5, 2026
@FrankFMY
Copy link
Contributor Author

FrankFMY commented Feb 6, 2026

Hey, fair point — I used Claude Code as an assistant while working on this. I should have disclosed it per your contributing guidelines, my apologies. I'll make sure to include AI disclosure in future PRs.

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.

🐛 Linter errors and suggests removing async when doing so would break a yield* call

3 participants