Context matters, but this what I would do (and I always apply when landing in a project, own or client, that has no documented or enforced code style):
1/ always have pre-commit hooks running lint/fmt, and document how to implement them in a common fashion in the team,
2/ strive to follow the language conventions (and if not, have those divergences explicitly defined in the linter/formatter tool configuration), this helps the team to align with it,
3/ having a job server-side that blocks merging PRs that do not pass both of these steps.
But that doesn't help when you do "git rebase" and there's a large conflict which you have to resolve manually, caused by two people changing different lines, and one or both of those lines caused the formatting of the whole block to change. That's the source of my frustration.
1/ always have pre-commit hooks running lint/fmt, and document how to implement them in a common fashion in the team,
2/ strive to follow the language conventions (and if not, have those divergences explicitly defined in the linter/formatter tool configuration), this helps the team to align with it,
3/ having a job server-side that blocks merging PRs that do not pass both of these steps.