Skip to content

formatter: diff with prettier on formatting broken package.json #19073

@brc-dd

Description

@brc-dd

Input

In package.json:

{
  foo: "bar",
}

Config

{}

Oxfmt output

oxfmt version: 0.28.0

  × Failed to sort package.json: /Users/brc-dd/foo/package.json
  │ key must be a string at line 2 column 3
Error occurred when checking code style in the above files.

It works for JSON files named other than package.json.

Oxfmt playground link

No response

Prettier output

prettier version: 3.8.1

{
  "foo": "bar"
}

Prettier playground link

No response

Additional notes

Run the binary directly using node_modules/.bin/oxfmt package.json; running pnpm oxfmt package.json won't work.

Although these malformed package.json files won't typically exist when running oxfmt from the CLI, extra trailing commas or unquoted values are quite common while editing them in an IDE and prettier's extension formats them correctly.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions