Skip to content

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Oct 23, 2025

As far as I can remember, doc() function was only added for the sort-imports example.

Now that we made format() as pub, there is no reason to use it.

Copilot AI review requested due to automatic review settings October 23, 2025 08:25
@leaysgur leaysgur requested a review from Dunqing as a code owner October 23, 2025 08:25
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 removes a redundant public API method doc() from the Formatter struct and refactors the example code to use the more flexible format() method directly. This simplifies the API surface by eliminating an unnecessary convenience method.

Key changes:

  • Removed the Formatter::doc() method which was a thin wrapper around format() and into_document()
  • Updated the sort_imports example to call format() directly and access the document/code through the returned Formatted struct

Reviewed Changes

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

File Description
crates/oxc_formatter/src/lib.rs Removed the redundant doc() public method from the Formatter implementation
crates/oxc_formatter/examples/sort_imports.rs Refactored to use format() directly instead of the removed doc() and build() methods
Comments suppressed due to low confidence (1)

crates/oxc_formatter/src/lib.rs:1

  • Corrected spelling of 'redundunt' to 'redundant' in the PR title (this affects the commit message context).
#![allow(

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Oct 23, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 23, 2025

CodSpeed Performance Report

Merging #14915 will not alter performance

Comparing 10-23-refactor_formatter_remove_redundunt_public_api (597c9e8) with main (ff2dbc3)1

Summary

✅ 33 untouched
⏩ 4 skipped2

Footnotes

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

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

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Oct 27, 2025
Copy link
Member Author

leaysgur commented Oct 27, 2025

Merge activity

  • Oct 27, 4:21 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 27, 4:21 AM UTC: leaysgur added this pull request to the Graphite merge queue.
  • Oct 27, 4:29 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Conformance').
  • Oct 27, 9:21 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Oct 27, 9:25 AM UTC: leaysgur added this pull request to the Graphite merge queue.
  • Oct 27, 9:26 AM UTC: Merged by the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Oct 27, 2025
As far as I can remember, `doc()` function was only added for the sort-imports example.

Now that we made `format()` as `pub`, there is no reason to use it.
@graphite-app graphite-app bot force-pushed the 10-23-refactor_formatter_remove_redundunt_public_api branch from d356392 to f7cfacc Compare October 27, 2025 04:22
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 27, 2025
@leaysgur leaysgur force-pushed the 10-23-refactor_formatter_remove_redundunt_public_api branch from 716bad4 to c6e8749 Compare October 27, 2025 05:16
leaysgur added a commit that referenced this pull request Oct 27, 2025
As far as I can remember, `doc()` function was only added for the sort-imports example.

Now that we made `format()` as `pub`, there is no reason to use it.
As far as I can remember, `doc()` function was only added for the sort-imports example.

Now that we made `format()` as `pub`, there is no reason to use it.
@leaysgur leaysgur force-pushed the 10-23-refactor_formatter_remove_redundunt_public_api branch from c6e8749 to 597c9e8 Compare October 27, 2025 09:19
@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Oct 27, 2025
@graphite-app graphite-app bot merged commit 597c9e8 into main Oct 27, 2025
27 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 27, 2025
@graphite-app graphite-app bot deleted the 10-23-refactor_formatter_remove_redundunt_public_api branch October 27, 2025 09:26
@Boshen Boshen mentioned this pull request Oct 30, 2025
leaysgur added a commit that referenced this pull request Oct 30, 2025
## [0.9.0] - 2025-10-30

### 🚀 Features

- 8fe7e85 formatter: Support printing Formatter IR (#14855) (Dunqing)

### 🐛 Bug Fixes

- a6b6ef8 formatter: Correct calculating layout for
`TSNonNullExpression` in `StaticMemberExpression` (#15065) (Dunqing)
- 99bd995 formatter: Print parenthesis for sequence expression in
`ReturnStatement` and `ExpressionStatement` (#15062) (Dunqing)
- f3fb998 formatter: Correct printing comments for `TSAsExpression`
(#15061) (Dunqing)
- 1e4a018 formatter: Correct checking of the short argument for
`CallArguments` (#15055) (Dunqing)
- c0dfd9b formatter: Print comments before fat arrow as-is for
`ArrowFunctionExpression` (#15050) (Dunqing)
- 206b519 formatter: Should hug parameter with `TSMappedType` type
annotation (#15049) (Dunqing)
- e48c604 formatter: Incorrect formatting of a function with `this`
parameter (#15031) (Dunqing)
- a9f0c45 formatter: Decorators and class method on the same line
shouldn't be broken by a leading comment of the method (#15029)
(Dunqing)
- 43d74e4 formatter: Handle `<CRLF>` for `SourceText` (#15016)
(leaysgur)
- 34fab40 formatter: Correct calculating layout for `ChainExpression` in
`StaticMemberExpression` (#14986) (Dunqing)
- 68dc101 formatter: Should not break when the parent of root of
`StaticMemberExpression` is used as the `Argument` of `NewExpression`
(#14985) (Dunqing)
- 071b739 formatter: Align the short argument handling for
UnaryExpression with Prettier (#14984) (Dunqing)
- 3940f3a formatter: `BestFitting` doesn't exactly matches the
`conditinalGroup` behavior in Prettier (#14983) (Dunqing)
- 4a84e44 formatter: Align the logic of printing type parameters,
parameters, and return type for functions with Prettier (#14942)
(Dunqing)
- 68c1f2a formatter: Non-nested static member expressions will never
break (#14929) (Dunqing)
- 42adc47 formatter: Check whether a type alias is complex when its
right hand side never break (#14928) (Dunqing)
- e501f13 formatter: Should not add a trailing comma for long curried
calls when `trailingComma` is es5 (#14913) (Dunqing)

### 🚜 Refactor

- 7d64291 formatter: Simplify printing ClassElement with a semicolon
(#15030) (Dunqing)
- 5de99c2 formatter: Export unified way to get_parse_options (#15027)
(leaysgur)
- f6f22e2 formatter: Clean up unneeded implementations for printing
comments (#14935) (Dunqing)
- 7a2b9d1 formatter: Improve printing trailing comments (#14934)
(Dunqing)
- ba10caa formatter: Align printing trailing comments with Prettier
(#14927) (Dunqing)
- 597c9e8 formatter: Remove redundunt public API (#14915) (leaysgur)

### ⚡ Performance

- 467b3a1 formatter: Optimize grouping logic for call arguments (#15033)
(Dunqing)

Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
@Boshen Boshen mentioned this pull request Oct 30, 2025
graphite-app bot pushed a commit that referenced this pull request Oct 30, 2025
## [0.9.0] - 2025-10-30

### 🚀 Features

- 8fe7e85 formatter: Support printing Formatter IR (#14855) (Dunqing)

### 🐛 Bug Fixes

- a6b6ef8 formatter: Correct calculating layout for `TSNonNullExpression` in `StaticMemberExpression` (#15065) (Dunqing)
- 99bd995 formatter: Print parenthesis for sequence expression in `ReturnStatement` and `ExpressionStatement` (#15062) (Dunqing)
- f3fb998 formatter: Correct printing comments for `TSAsExpression` (#15061) (Dunqing)
- 1e4a018 formatter: Correct checking of the short argument for `CallArguments` (#15055) (Dunqing)
- c0dfd9b formatter: Print comments before fat arrow as-is for `ArrowFunctionExpression` (#15050) (Dunqing)
- 206b519 formatter: Should hug parameter with `TSMappedType` type annotation (#15049) (Dunqing)
- e48c604 formatter: Incorrect formatting of a function with `this` parameter (#15031) (Dunqing)
- a9f0c45 formatter: Decorators and class method on the same line shouldn't be broken by a leading comment of the method (#15029) (Dunqing)
- 43d74e4 formatter: Handle `<CRLF>` for `SourceText` (#15016) (leaysgur)
- 34fab40 formatter: Correct calculating layout for `ChainExpression` in `StaticMemberExpression` (#14986) (Dunqing)
- 68dc101 formatter: Should not break when the parent of root of `StaticMemberExpression` is used as the `Argument` of `NewExpression` (#14985) (Dunqing)
- 071b739 formatter: Align the short argument handling for UnaryExpression with Prettier (#14984) (Dunqing)
- 3940f3a formatter: `BestFitting` doesn't exactly matches the `conditinalGroup` behavior in Prettier (#14983) (Dunqing)
- 4a84e44 formatter: Align the logic of printing type parameters, parameters, and return type for functions with Prettier (#14942) (Dunqing)
- 68c1f2a formatter: Non-nested static member expressions will never break (#14929) (Dunqing)
- 42adc47 formatter: Check whether a type alias is complex when its right hand side never break (#14928) (Dunqing)
- e501f13 formatter: Should not add a trailing comma for long curried calls when `trailingComma` is es5 (#14913) (Dunqing)

### 🚜 Refactor

- 7d64291 formatter: Simplify printing ClassElement with a semicolon (#15030) (Dunqing)
- 5de99c2 formatter: Export unified way to get_parse_options (#15027) (leaysgur)
- f6f22e2 formatter: Clean up unneeded implementations for printing comments (#14935) (Dunqing)
- 7a2b9d1 formatter: Improve printing trailing comments (#14934) (Dunqing)
- ba10caa formatter: Align printing trailing comments with Prettier (#14927) (Dunqing)
- 597c9e8 formatter: Remove redundunt public API (#14915) (leaysgur)

### ⚡ Performance

- 467b3a1 formatter: Optimize grouping logic for call arguments (#15033) (Dunqing)

### 💼 Other

- aceff66 oxfmt: V0.9.0 (#15088) (Boshen)
@Boshen Boshen mentioned this pull request Oct 30, 2025
graphite-app bot pushed a commit that referenced this pull request Oct 30, 2025
## [0.9.0] - 2025-10-30

### 🚀 Features

- 8fe7e85 formatter: Support printing Formatter IR (#14855) (Dunqing)

### 🐛 Bug Fixes

- a6b6ef8 formatter: Correct calculating layout for `TSNonNullExpression` in `StaticMemberExpression` (#15065) (Dunqing)
- 99bd995 formatter: Print parenthesis for sequence expression in `ReturnStatement` and `ExpressionStatement` (#15062) (Dunqing)
- f3fb998 formatter: Correct printing comments for `TSAsExpression` (#15061) (Dunqing)
- 1e4a018 formatter: Correct checking of the short argument for `CallArguments` (#15055) (Dunqing)
- c0dfd9b formatter: Print comments before fat arrow as-is for `ArrowFunctionExpression` (#15050) (Dunqing)
- 206b519 formatter: Should hug parameter with `TSMappedType` type annotation (#15049) (Dunqing)
- e48c604 formatter: Incorrect formatting of a function with `this` parameter (#15031) (Dunqing)
- a9f0c45 formatter: Decorators and class method on the same line shouldn't be broken by a leading comment of the method (#15029) (Dunqing)
- 43d74e4 formatter: Handle `<CRLF>` for `SourceText` (#15016) (leaysgur)
- 34fab40 formatter: Correct calculating layout for `ChainExpression` in `StaticMemberExpression` (#14986) (Dunqing)
- 68dc101 formatter: Should not break when the parent of root of `StaticMemberExpression` is used as the `Argument` of `NewExpression` (#14985) (Dunqing)
- 071b739 formatter: Align the short argument handling for UnaryExpression with Prettier (#14984) (Dunqing)
- 3940f3a formatter: `BestFitting` doesn't exactly matches the `conditinalGroup` behavior in Prettier (#14983) (Dunqing)
- 4a84e44 formatter: Align the logic of printing type parameters, parameters, and return type for functions with Prettier (#14942) (Dunqing)
- 68c1f2a formatter: Non-nested static member expressions will never break (#14929) (Dunqing)
- 42adc47 formatter: Check whether a type alias is complex when its right hand side never break (#14928) (Dunqing)
- e501f13 formatter: Should not add a trailing comma for long curried calls when `trailingComma` is es5 (#14913) (Dunqing)

### 🚜 Refactor

- 7d64291 formatter: Simplify printing ClassElement with a semicolon (#15030) (Dunqing)
- 5de99c2 formatter: Export unified way to get_parse_options (#15027) (leaysgur)
- f6f22e2 formatter: Clean up unneeded implementations for printing comments (#14935) (Dunqing)
- 7a2b9d1 formatter: Improve printing trailing comments (#14934) (Dunqing)
- ba10caa formatter: Align printing trailing comments with Prettier (#14927) (Dunqing)
- 597c9e8 formatter: Remove redundunt public API (#14915) (leaysgur)

### ⚡ Performance

- 467b3a1 formatter: Optimize grouping logic for call arguments (#15033) (Dunqing)

### 💼 Other

- 6368793 oxfmt: V0.9.0 (#15091) (Boshen)
- aceff66 oxfmt: V0.9.0 (#15088) (Boshen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants