3 ms·
I agree with automating it, but I also have seen automated styles going too far, more often than not. Automated styling should be kept minimal, like checking n
by Seb-C 6y ago
I agree with automating it, but I also have seen automated styles going too far, more often than not.
Automated styling should be kept minimal, like checking names and indentation. Absolute rules does not work because then you cannot deviate from it even if it is appropriate in the right situation.
The standard JavaScript checkers nowadays are ridiculously strict and forces me to spend time writing a less readable code. For example yesterday my code was invalid because I did not write properties of an object alphabetically. So I had to convert this:
{
host: ,
port: ,
key: ,
username: ,
password: ,
}
Into this mess:
{
host: ,
key: ,
password: ,
port: ,
username: ,
}
With tslint I cannot even execute my code if the formatting is invalid. So if I write a console.log or forget to add a space between the slash and the code I commented, the compilation crashes.
- heavenlyblue 6y agoMaybe that should not be an object then, but a URL or just several objects.
- Seb-C 6y agoThis is a very common pattern for a lot of third party packages. And it is just an example to show that there are perfectly legitimate cases that are more readable when not alphabetically sorted.
- ericmcer 6y agoIt is consistent though, do you have a better generic system for grouping object keys than alphabetization? It’s pretty handy to approach a codebase knowing that it has enforced this convention.
- Seb-C 6y agoMy point is that having rules on this kind of detail is more harmful than beneficial, so there should not be one in the first place.
- wool_gather 6y agoThe point is that it's not generic: there is meaning conveyed by the grouping that can't be expressed as an easy script (which is why there's a human writing the code in the first place).