-
-
Notifications
You must be signed in to change notification settings - Fork 794
fix: correctly place await after comment #8169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 93c4193 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
d0fc7cb to
93c4193
Compare
CodSpeed Performance ReportMerging #8169 will not alter performanceComparing Summary
Footnotes
|
WalkthroughThis pull request fixes a bug in the Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
crates/biome_js_analyze/src/lint/nursery/no_floating_promises.rs (1)
290-305: Await + trivia handling forUnhandledPromiselooks correctUsing
trim_comments_and_trivia()for the wrapped expression plusreplace_node_transfer_triviafor the replacement should keep leading comments/whitespace on the whole statement while ensuring theawaitis inserted immediately before the expression, not the comment. That matches the intended behaviour for issue #7999.If you find you need the same treatment elsewhere, it might be worth considering
replace_node_transfer_triviain other rule actions for consistency, but it’s not required for this fix.crates/biome_rowan/src/ast/mod.rs (1)
279-287: Clarifytrim_comments_and_triviasemantics in the doc commentThe implementation strips leading/trailing trivia on the node’s boundary (first/last tokens), which is exactly what the rule needs. The phrase “all trivia” could be read more broadly though — maybe reword to something like “all leading and trailing trivia (including comments) from this node” and briefly contrast it with
trim_triviato make the intent unmistakable to future callers.crates/biome_rowan/src/ast/batch.rs (1)
224-253:replace_node_transfer_triviabehaviour looks good; consider tightening API/usageThe trivia merging logic (prev + next leading, prev + next trailing) is a sensible analogue to
replace_token_transfer_trivia, and suits the noFloatingPromises use-case.The only nit is the
Option<()>return: in the current caller it’s ignored, so a theoreticalNonewould silently yield an “empty” mutation. Either treating the missing-token case as unreachable and returning()here, or having call sites propagate theOptionwith?, would make the failure mode more explicit.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.changeset/balanced-bananas-balloon.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_floating_promises.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js.snap.new(1 hunks)crates/biome_rowan/src/ast/batch.rs(1 hunks)crates/biome_rowan/src/ast/mod.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.
Applied to files:
.changeset/balanced-bananas-balloon.md
🧬 Code graph analysis (1)
crates/biome_rowan/src/ast/batch.rs (1)
crates/biome_rowan/src/syntax/token.rs (1)
trailing_trivia(492-494)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_package)
- GitHub Check: Documentation
- GitHub Check: End-to-end tests
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Validate rules documentation
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Check Dependencies
- GitHub Check: autofix
- GitHub Check: Bench (biome_tailwind_parser)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: lint
- GitHub Check: Bench (biome_module_graph)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Parser conformance
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_parser)
🔇 Additional comments (3)
crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js (1)
6-10: Nice focused regression testThe
issue7999case cleanly captures the “comment + floating promise in async function” scenario, and lines up with the new snapshot. Good addition.crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js.snap.new (1)
1-75: Snapshot accurately reflects the new behaviourThe diagnostics and the unsafe fix snippet look spot on: only the async-function call is marked fixable, and the suggested edit inserts
awaitafter the leading comment with indentation preserved..changeset/balanced-bananas-balloon.md (1)
1-5: Clear, user-facing summaryNice concise changeset: it names the rule, the behaviour change, and links the original issue. Nothing to tweak here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js (1)
6-10: LGTM! Test case correctly exercises the fix.The test case properly validates the issue where a leading comment preceded the floating promise. The auto-fix should now place
awaitafter the comment rather than before it.Consider adding test cases for edge cases such as block comments (
/* comment */) or multiple leading comments, though this focused test is sufficient for the reported issue.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (5)
.changeset/balanced-bananas-balloon.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_floating_promises.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noFloatingPromises/invalid.js(1 hunks)crates/biome_rowan/src/ast/batch.rs(1 hunks)crates/biome_rowan/src/ast/mod.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- crates/biome_js_analyze/src/lint/nursery/no_floating_promises.rs
- .changeset/balanced-bananas-balloon.md
- crates/biome_rowan/src/ast/mod.rs
- crates/biome_rowan/src/ast/batch.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Test Node.js API
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Check Dependencies
- GitHub Check: Bench (biome_tailwind_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: autofix
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_module_graph)
- GitHub Check: Validate rules documentation
- GitHub Check: Bench (biome_package)
- GitHub Check: Parser conformance
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
Summary
Fixed #7999: Correctly place
awaitafter leading comment in auto-fix action fromnoFloatingPromisesrule.Test Plan
Test case included.
Docs
N/A