Hi,
I'm running into a formatting conflict when using sort-package-json alongside Biome, a formatter/linter/diagnostics tool similar to Prettier. I'm not sure which tool is responsible for resolving this, so I'm also opening a discussion in the other repo to gather insight (see biomejs/biome#5807).
Both tools work on package.json, but they apply different formatting rules to array values (e.g. workspaces).
What's happening
-
sort-package-json rewrites package.json like this:
"workspaces": [
"./packages/*"
]
-
Then, Biome formats it back to:
"workspaces": ["./packages/*"]
This results in an infinite diff loop when both tools are run in CI or locally with VS Code formatOnSave. Each tool undoes what the other did.
Repro repo:
👉 https://github.com/yoriiis/package-json-sort
The project has the npm run sort:packagejson and npm run biomd:check scripts (and VS Code workspace for the format on save).
Not sure where the fix should come from
Maybe:
sort-package-json could expose a config option to preserve original formatting or allow single-line arrays?
- Or maybe it could detect and respect Biome's formatting when rewriting the file?
- Or perhaps Biome should be the sole tool used for formatting + sorting?
Any insight or recommendation would be appreciated — thanks for maintaining this great tool!
Hi,
I'm running into a formatting conflict when using
sort-package-jsonalongside Biome, a formatter/linter/diagnostics tool similar to Prettier. I'm not sure which tool is responsible for resolving this, so I'm also opening a discussion in the other repo to gather insight (see biomejs/biome#5807).Both tools work on
package.json, but they apply different formatting rules to array values (e.g.workspaces).What's happening
sort-package-jsonrewritespackage.jsonlike this:Then, Biome formats it back to:
This results in an infinite diff loop when both tools are run in CI or locally with VS Code
formatOnSave. Each tool undoes what the other did.Repro repo:
👉 https://github.com/yoriiis/package-json-sort
The project has the
npm run sort:packagejsonandnpm run biomd:checkscripts (and VS Code workspace for the format on save).Not sure where the fix should come from
Maybe:
sort-package-jsoncould expose a config option to preserve original formatting or allow single-line arrays?Any insight or recommendation would be appreciated — thanks for maintaining this great tool!