Skip to content

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Dec 12, 2025

Fixes #16637

Copilot AI review requested due to automatic review settings December 12, 2025 00:29
@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-bug Category - Bug labels Dec 12, 2025
Copy link
Member Author

leaysgur commented Dec 12, 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 changed the title fix(oxfmt): Remove jsonc parser override for tsconfig.json fix(oxfmt): Remove jsonc parser override for (j|t)sconfig(.*)?.json Dec 12, 2025
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 attempts to remove special-case handling for tsconfig.json and jsconfig.json files, which were previously explicitly mapped to use the "jsonc" parser. The intent appears to be simplifying the code by relying on generic extension-based parsing logic instead.

Key changes:

  • Removed special handling that forced tsconfig.*.json and jsconfig.*.json files to use the "jsonc" parser
  • Removed corresponding test cases for tsconfig/jsconfig files
  • Updated a comment to remove the specific tsconfig.json example

However, this change introduces a critical bug that will cause tsconfig.json files to be formatted incorrectly.

Reviewed changes

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

File Description
apps/oxfmt/src/core/support.rs Removes special handling for tsconfig/jsconfig files and their test cases; files will now use generic JSON parser based on .json extension
apps/oxfmt/src/core/format.rs Updates comment to remove tsconfig.json example and generalize the explanation
Comments suppressed due to low confidence (1)

apps/oxfmt/src/core/support.rs:85

  • Removing the special handling for tsconfig.json and jsconfig.json files will cause them to be formatted with the "json" parser instead of "jsonc". This is incorrect because these files commonly contain JSONC features like comments and trailing commas, which are not valid in standard JSON.

The test fixture at test/fixtures/external_formatter/tsconfig.dummy.json demonstrates this - it contains a comment // Allow comments! and trailing commas, which are valid JSONC syntax. With this change, tsconfig.json files will be parsed with the "json" parser (matching on the .json extension at lines 81-85), which will fail to handle these JSONC features correctly.

TypeScript's official documentation explicitly allows comments and trailing commas in tsconfig.json files, making them JSONC files rather than strict JSON files.

    if JSON_FILENAMES.contains(file_name) {
        return Some(FormatFileStrategy::ExternalFormatter { path, parser_name: "json" });
    }
    if let Some(ext) = extension
        && JSON_EXTENSIONS.contains(ext)
    {
        return Some(FormatFileStrategy::ExternalFormatter { path, parser_name: "json" });
    }

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

@leaysgur leaysgur force-pushed the 12-12-fix_oxfmt_remove_jsonc_parser_override_for_tsconfig.json branch 2 times, most recently from e095eac to 1323c0e Compare December 12, 2025 00:55
@leaysgur leaysgur requested a review from Dunqing December 12, 2025 01:28
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 12, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 12, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-12-fix_oxfmt_remove_jsonc_parser_override_for_tsconfig.json branch from 1323c0e to 2577814 Compare December 12, 2025 05:30
@graphite-app graphite-app bot merged commit 2577814 into main Dec 12, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 12-12-fix_oxfmt_remove_jsonc_parser_override_for_tsconfig.json branch December 12, 2025 05:37
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 12, 2025
@Miodec
Copy link

Miodec commented Dec 12, 2025

Does this close #16637, seems like it remained open?

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-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oxfmt: tsconfig.json files are handled differently to other json files.

4 participants