Posted by MaxLeiter 6 days ago
There's nothing special about whitespace (unless you write python).
Capitalization and a bunch of other stuff in your coding convention document are usually just signs that you have poor tooling and lack of skill.
Give me a PR that satisfies the requirements and the appropriate test cases and i'll happily rewrite it to spaces only indented with curly braces on newlines and etc... as I see fit.
The hard part is the first two tasks, you can train an intern to do the third
e.g. if the formatter is really shifting stuff around, your code might be too nested - if you have a compiler, let it take the strain.
But formatting still doesn't matter. Outside of whitespace-dependent languages, formatting is a subjective thing -- it's a people concern, not a computer concern. I can store my JavaScript as AST if I want to.
<span>foo</span>
vs: <span>
foo
</span>
A. not everyone on your team is using prettier
B. not everyone is using the same config/agrees on what it should be
I can write code that (IMHO) is substantially better than any formatter. But I've realized that there is no way to make other people on a team have the same opinions and skill as me, so I accept automatic code formatters.
Leave code format up to the primary owner of the file. It is pretty rare that code has more than one person that does 95% of the edits on a file so let them own the formatting. In the rare case where there are shared files with shared edits then it is ok to mandate some sort of enforced format but those are so rare that it generally isn't worth discussing. The proposed approach here ignores all the messy non-standard stuff that happens because of the margins or the rules that are very hard to build in when codifying personal coding style.
Let me have my messy desk and I'll let you have yours.