fix(formatter): handle member chain for the call's parent is a chain expression#15237
Conversation
CodSpeed Performance ReportMerging #15237 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in member chain formatting by properly handling ChainExpression nodes in parent checks. The fix enables the formatter to correctly handle method chains with optional chaining expressions.
- Refactored code to use a
matchexpression for better readability and exhaustiveness checking - Introduced a new
without_chain_expression()helper method to skip ChainExpression wrapper nodes - Removed an unused intermediate variable (
parent) in theMemberChain::newmethod
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tasks/prettier_conformance/snapshots/prettier.js.snap.md | Updated compatibility score showing one previously failing test now passes |
| crates/oxc_formatter/src/utils/member_chain/mod.rs | Fixed bug by calling without_chain_expression() on parent, refactored if-else to match expression, removed unused variable |
| crates/oxc_formatter/src/ast_nodes/impls/ast_nodes.rs | Added new helper method to recursively skip ChainExpression wrapper nodes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c9c0c63 to
53f09b5
Compare
Merge activity
|
…expression (#15237) This is an error-prone situation because Biome didn't have a ChainExpression. However, we have to handle it on a case-by-case basis.
53f09b5 to
a7289e7
Compare
## [0.10.0] - 2025-11-04 ### 🚀 Features - 505252c formatter: Wrap parenthesis for AssignmentExpression that is a key of `PropertyDefinition` (#15243) (Dunqing) - 880b259 formatter: Align import-like formatting the same as Prettier (#15238) (Dunqing) - b77f254 oxfmt,formatter: Support `embeddedLanguageFormatting` option (#15216) (leaysgur) - 898d6fe oxfmt: Add embedded language formatting with Prettier integration (#14820) (Boshen) - e77a48e formatter: Detect code removal feature (#15059) (leaysgur) ### 🐛 Bug Fixes - daacf85 oxfmt: Release build fails (#15262) (Dunqing) - f5d0348 oxfmt: Sync `dependencies` with `npm/oxfmt` and `apps/oxfmt` (#15261) (leaysgur) - 46793d7 formatter: Correct printing comments for `LabeledStatement` (#15260) (Dunqing) - 831ae99 formatter: Multiple comments in `LogicalExpression` and `TSIntersectionType` (#15253) (Dunqing) - 5fa9b1e formatter: Should not indent `BinaryLikeExpression` when it is an argument of `Boolean` (#15250) (Dunqing) - 99e520f formatter: Handle chain expression for `JSXExpressionContainer` (#15242) (Dunqing) - a600bf5 formatter: Correct printing comments for `TaggedTemplateExpression` (#15241) (Dunqing) - a7289e7 formatter: Handle member chain for the call's parent is a chain expression (#15237) (Dunqing) ### 🚜 Refactor - 36ae721 formatter: Simplify the use of `indent` with `soft_line_break_or_space` (#15254) (Dunqing) - cdd8e2f formatter/sort-imports: Split sort_imports modules (#15189) (leaysgur) - 27b4f36 diagnostic: Remove `path` from sender (#15130) (camc314) - 85fb8e8 formatter/sort-imports: Pass options to is_ignored() (#15181) (leaysgur) ### 🧪 Testing - 9d5b34b formatter/sort-imports: Refactor sort_imports tests (#15188) (leaysgur) Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>

This is an error-prone situation because Biome didn't have a ChainExpression. However, we have to handle it on a case-by-case basis.