Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Sep 18, 2025

Copy from oxfmt

let ret = Parser::new(&allocator, &source_text, source_type)
.with_options(ParseOptions {
parse_regular_expression: false,
// Enable all syntax features
allow_v8_intrinsics: true,
allow_return_outside_function: true,
// `oxc_formatter` expects this to be false
preserve_parens: false,
})
.parse();

Copilot AI review requested due to automatic review settings September 18, 2025 13:59
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 ensures consistent parser options configuration across all formatter usage examples and tests by standardizing the ParseOptions struct initialization. The changes make the parser configuration explicit and consistent rather than relying on default values that might vary.

  • Replaces ParseOptions::default() with explicit option values
  • Adds explicit flags for parse_regular_expression, allow_v8_intrinsics, and allow_return_outside_function
  • Includes helpful comments explaining the formatter's expectations

Reviewed Changes

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

File Description
tasks/prettier_conformance/src/lib.rs Updates parser options to use explicit configuration instead of defaults
tasks/benchmark/benches/formatter.rs Standardizes parser options with explicit values for consistency
crates/oxc_formatter/examples/formatter.rs Aligns example code with consistent parser option configuration

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

@github-actions github-actions bot added A-formatter Area - Formatter C-enhancement Category - New feature or request labels Sep 18, 2025
Copy link
Member Author

Dunqing commented Sep 18, 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 18, 2025

CodSpeed Instrumentation Performance Report

Merging #13884 will not alter performance

Comparing 09-17-feat_formatter_keep_parse_options_consistent_for_all_formatter_usages (2cead8b) with main (91c88e2)1

Summary

✅ 37 untouched

Footnotes

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

Copy link
Member

@leaysgur leaysgur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will add Formatter::parser_options() one day?

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Sep 18, 2025
Copy link
Member

leaysgur commented Sep 18, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 09-17-feat_formatter_keep_parse_options_consistent_for_all_formatter_usages branch from 24069bc to 2cead8b Compare September 18, 2025 23:18
@graphite-app graphite-app bot merged commit 2cead8b into main Sep 18, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 09-17-feat_formatter_keep_parse_options_consistent_for_all_formatter_usages branch September 18, 2025 23:24
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 18, 2025
@Dunqing
Copy link
Member Author

Dunqing commented Sep 19, 2025

We will add Formatter::parser_options() one day?

Yes, It should be. Maybe we should expose a parse method or accept a file path to format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants