fix-mismatches
results in formatting changes in package.json
#241
Labels
fix-mismatches
results in formatting changes in package.json
#241
Description
We started using Biome for our formatter, and noticed that it formats our
package.json
files slightly differently thanprettier-plugin-packagejson
. Technically, Biome is more correct, but it is indeed different.Because
fix-mismatches
output agrees with Prettier (not Biome), it creates a large diff for all of ourpackage.json
files in our monorepo, even when there are no mismatches to fix. While this isn't a showstopper, it's slightly inconvenient, making diffs hard to read when there really is a mismatch to fix.Suggested Solution
I'm not sure of the current implementation that's causing this but I'd figure it has to do with
JSON.parse
somewhere in the path. I've seen this produce reformatting before in other tools.An AST-based approach with something like
jsonc-parser
could help here, allowing edits to specific nodes of the AST so that formatting for other parts of the file can be preserved. If my memory serves me correctly,jsonc-parser
is slower thanJSON.parse
due to its higher specificity, but I would hope those performance impacts are negligible given what we can reasonably expect for the sizes of users'package.json
s.Help Needed
I'm aware there's a Rust rewrite going on but I'm not sure of the status of it, nor if a fix on the current implementation would be welcome with the rewrite ongoing.
The text was updated successfully, but these errors were encountered: