Skip to content

feat(oxfmt): Add insertFinalNewline option#17251

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-22-feat_oxfmt_add_insertfinalenewline_option
Dec 22, 2025
Merged

feat(oxfmt): Add insertFinalNewline option#17251
graphite-app[bot] merged 1 commit intomainfrom
12-22-feat_oxfmt_add_insertfinalenewline_option

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Dec 22, 2025

Fixes #15066 and closes #16757

  • Added insertFinalNewline: bool option
    • true by default = The same behavior with current oxc_formatter and Prettier
  • Also respect insert_final_newline in .editorconfig
    • Like others, .oxfmtrc takes precedence

@leaysgur leaysgur requested a review from Dunqing as a code owner December 22, 2025 05:25
@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-enhancement Category - New feature or request labels Dec 22, 2025
Copy link
Member Author

leaysgur commented Dec 22, 2025


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.

@leaysgur leaysgur force-pushed the 12-22-fix_oxfmt_use_correct_root_dir_with_ignore_and_overrides_for_nested_cwd branch from e00d403 to fde61bb Compare December 22, 2025 05:28
@leaysgur leaysgur force-pushed the 12-22-feat_oxfmt_add_insertfinalenewline_option branch from bfd0a24 to f442c33 Compare December 22, 2025 05:28
@leaysgur leaysgur changed the title feat(oxfmt): Add insertFinaleNewline option feat(oxfmt): Add insertFinaleNewline option Dec 22, 2025
@leaysgur leaysgur changed the title feat(oxfmt): Add insertFinaleNewline option feat(oxfmt): Add insertFinalNewline option Dec 22, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 22, 2025

CodSpeed Performance Report

Merging #17251 will not alter performance

Comparing 12-22-feat_oxfmt_add_insertfinalenewline_option (ee42a8b) with main (ab43454)1

Summary

✅ 38 untouched
⏩ 7 skipped2

Footnotes

  1. No successful run was found on 12-22-fix_oxfmt_use_correct_root_dir_with_ignore_and_overrides_for_nested_cwd (fde61bb) during the generation of this report, so main (ab43454) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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

@leaysgur leaysgur force-pushed the 12-22-feat_oxfmt_add_insertfinalenewline_option branch from f442c33 to ee42a8b Compare December 22, 2025 05:34
@Dunqing
Copy link
Member

Dunqing commented Dec 22, 2025

Don't need to change the formatter for insertFinalNewLine: false?

@leaysgur
Copy link
Member Author

It's not necessary. Actually, it would be a problem if it were deleted. 😓

// NOTE: `insert_final_newline` relies on the fact that:
// - each formatter already ensures there is traliling newline
// - each formatter does not have an option to disable trailing newline
// So we can trim it here without allocating new string.
if !insert_final_newline {

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Dec 22, 2025
Copy link
Member

Dunqing commented Dec 22, 2025

Merge activity

Fixes #15066 and closes #16757

- Added `insertFinalNewline: bool` option
  - `true` by default = The same behavior with current `oxc_formatter` and Prettier
- Also respect `insert_final_newline` in `.editorconfig`
  - Like others, `.oxfmtrc` takes precedence
@graphite-app graphite-app bot force-pushed the 12-22-fix_oxfmt_use_correct_root_dir_with_ignore_and_overrides_for_nested_cwd branch from fde61bb to 7b810f4 Compare December 22, 2025 08:55
@graphite-app graphite-app bot force-pushed the 12-22-feat_oxfmt_add_insertfinalenewline_option branch from ee42a8b to 97a02d1 Compare December 22, 2025 08:56
Base automatically changed from 12-22-fix_oxfmt_use_correct_root_dir_with_ignore_and_overrides_for_nested_cwd to main December 22, 2025 09:01
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 22, 2025
@graphite-app graphite-app bot merged commit 97a02d1 into main Dec 22, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-22-feat_oxfmt_add_insertfinalenewline_option branch December 22, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oxfmt: Respect .editorconfig.insert_final_newline

3 participants