it's very common to have a lint/format step that make sure all files are well-formatted in Pull request.
If you value a clean commit history, then simply reformat as part of the code change. With autoformatting on save (e.g. through prettier), that's a complete non-issue anyways.
in other language, formatters are pretty damn fast. never heard anyone complain about gofmt or cargo fmt