Skip to content

Comments

fix(formatter): use soft indent for empty objects in JSX spread attributes#18063

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/formatter-jsx-spread-dangling-comments
Jan 16, 2026
Merged

fix(formatter): use soft indent for empty objects in JSX spread attributes#18063
graphite-app[bot] merged 1 commit intomainfrom
fix/formatter-jsx-spread-dangling-comments

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Jan 16, 2026

Summary

  • Fix jsx/ignore/spread.js Prettier conformance test
  • Empty objects with dangling comments inside JSX spread attributes now stay on one line if they fit
  • For example, <div {...{/* comment */}} /> remains on one line, while var a = {/* comment */} still expands

Test plan

  • cargo run -p oxc_prettier_conformance -- --filter "jsx/ignore/spread.js" passes
  • cargo run -p oxc_prettier_conformance -- --filter "js/comments/dangling.js" still passes (no regression)
  • cargo test -p oxc_formatter passes
  • JS compatibility: 737/761 → 738/761 (+1)
  • TS compatibility: 579/607 → 580/607 (+1)

🤖 Generated with Claude Code

@Boshen Boshen requested a review from Dunqing as a code owner January 16, 2026 07:20
Copilot AI review requested due to automatic review settings January 16, 2026 07:20
@github-actions github-actions bot added A-formatter Area - Formatter C-bug Category - Bug labels Jan 16, 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

This PR fixes formatting of empty objects with dangling comments inside JSX spread attributes and JSX spread children. The change ensures that constructs like <div {...{/* comment */}} /> remain on one line if they fit, while maintaining the existing behavior of expanding empty objects with comments in other contexts (e.g., var a = {/* comment */} still expands to multiple lines).

Changes:

  • Added is_inside_jsx_spread() method to detect when an object is inside a JSX spread attribute or JSX spread child
  • Updated empty object formatting logic to use soft indent instead of block indent for JSX spread contexts
  • Fixed one failing Prettier conformance test (jsx/ignore/spread.js)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/oxc_formatter/src/print/object_like.rs Added is_inside_jsx_spread() method and conditional formatting logic for empty objects with dangling comments
tasks/prettier_conformance/snapshots/prettier.js.snap.md Updated JS compatibility score from 737/761 to 738/761, removed jsx/ignore/spread.js from failed tests
tasks/prettier_conformance/snapshots/prettier.ts.snap.md Updated TS compatibility score from 579/607 to 580/607, removed jsx/ignore/spread.js from failed tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Boshen Boshen force-pushed the fix/formatter-jsx-spread-dangling-comments branch from e466376 to d43e945 Compare January 16, 2026 09:39
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 16, 2026

Merging this PR will not alter performance

✅ 38 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing fix/formatter-jsx-spread-dangling-comments (d43e945) with main (fd2c792)

Open in CodSpeed

Footnotes

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

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Copy link
Member Author

Boshen commented Jan 16, 2026

Merge activity

…butes (#18063)

## Summary

- Fix `jsx/ignore/spread.js` Prettier conformance test
- Empty objects with dangling comments inside JSX spread attributes now stay on one line if they fit
- For example, `<div {...{/* comment */}} />` remains on one line, while `var a = {/* comment */}` still expands

## Test plan

- [x] `cargo run -p oxc_prettier_conformance -- --filter "jsx/ignore/spread.js"` passes
- [x] `cargo run -p oxc_prettier_conformance -- --filter "js/comments/dangling.js"` still passes (no regression)
- [x] `cargo test -p oxc_formatter` passes
- [x] JS compatibility: 737/761 → 738/761 (+1)
- [x] TS compatibility: 579/607 → 580/607 (+1)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app bot force-pushed the fix/formatter-jsx-spread-dangling-comments branch from d43e945 to 9b902b6 Compare January 16, 2026 10:17
@graphite-app graphite-app bot merged commit 9b902b6 into main Jan 16, 2026
21 checks passed
@graphite-app graphite-app bot deleted the fix/formatter-jsx-spread-dangling-comments branch January 16, 2026 10:23
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants