Skip to content

fix(format/js): fix comments in JavaScript member chains causing unnecessary line breaks#8916

Merged
ematipico merged 3 commits intobiomejs:mainfrom
ryan-m-walker:fix/fix-comments-causing-unnecessary-member-chain-line-breaks
Jan 30, 2026
Merged

fix(format/js): fix comments in JavaScript member chains causing unnecessary line breaks#8916
ematipico merged 3 commits intobiomejs:mainfrom
ryan-m-walker:fix/fix-comments-causing-unnecessary-member-chain-line-breaks

Conversation

@ryan-m-walker
Copy link
Copy Markdown
Contributor

Summary

closes #4013

MemberChainGroup::has_comments was incorrectly detecting comments on members that shouldn't trigger line breaks, causing member chains to break unnecessarily. This PR uses MemberChain::has_comments instead which correctly skips the root member and only triggers breaks for comments inside the chain, aligning the formatting with Prettier.

Test Plan

Snapshot tests added

Docs

n/a

AI Usage Disclosure

All code changes are done by me. Used Claude Code to do a quick review on the changes and generate a better changeset message

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: 03f56e6

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-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages labels Jan 30, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 30, 2026

Walkthrough

This pull request addresses issue #4013 by refactoring the member chain comment-checking logic. The change removes the has_comments method from MemberChainGroup and consolidates comment detection into a single call within groups_should_break. This simplification prevents unnecessary line breaks when comments are present in member chains. A new test file exercises various scenarios of chained calls with comments to verify the corrected formatting behaviour.

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main fix: addressing comments in JavaScript member chains causing unnecessary line breaks.
Description check ✅ Passed The description adequately explains the issue, the solution (using MemberChain::has_comments instead of MemberChainGroup::has_comments), and notes that tests were added.
Linked Issues check ✅ Passed The PR successfully addresses issue #4013 by fixing the comment detection logic to match Prettier's behaviour and aligning line-break behaviour accordingly.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the member chain comment handling: removal of the problematic method, consolidation of comment checks, and addition of test cases.

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

codspeed-hq Bot commented Jan 30, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing ryan-m-walker:fix/fix-comments-causing-unnecessary-member-chain-line-breaks (03f56e6) with main (21dba4a)

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.

Copy link
Copy Markdown
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.

Nice!!

@ematipico ematipico merged commit ea4bd04 into biomejs:main Jan 30, 2026
17 checks passed
@github-actions github-actions Bot mentioned this pull request Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📝 Formatting line-break is different from prettier

2 participants