3 ms·
Wouldn't having the autoformatter run as a pre-commit hook alleviate this issue? (This is assuming you had already cleaned up all of the currently checked in co
by SOLAR_FIELDS 6y ago
Wouldn't having the autoformatter run as a pre-commit hook alleviate this issue? (This is assuming you had already cleaned up all of the currently checked in code with said autoformatter)
- est31 6y agoMost autoformatters are under active development, and updates to them often causes changes in their behaviour. So you have to have all devs agree on the precise version of the formatter used, and even then you still need to do regular commits that contain nothing but a run of the newest version of the formatter on the codebase, which sadly destroys long term git blame.
- cheez 6y agothis is a solved problem, pin your packages.
- est31 6y agoBut you still have to update them every now and then otherwise you can't use new features of your language. Which gives you the issue of breakages again.
- waheoo 6y agoI dont think people want to hear that there are still problems with autoformatting text. Anyway, my point still stands, drop rules about line length and rules that care about inter line break positions and most of these problems go away.
- cheez 6y agoSure. Most large teams do this on a 6 month basis or when it is needed to implement something. Again, a solved problem.
- zetafunction 6y agoChromium has a presubmit that enforces that code is autoformatted. However, it only enforces this for changed lines, and in practice, it works pretty well.
- waheoo 6y agoPrettier specifically annoys me to no end with this problem. If youre adding more attributes to a jsx component later and know it you might format to multiline early. It decides to undo your work and slow you down, because some arbitrary line length. Similarly, if you go over that line length, on something you want single line for readability of structure, it just straight up does what it wants. Im 100% on the auto format train but it has to go the gofmt route and only apply rules that are actually important and incredibly uncontroversial.
- crooked-v 6y ago> It decides to undo your work What you're missing here is that you're supposed to be using it all along, all the time. Format on save. Format on commit. Format on server pipelines. Format all the time. It can never 'undo' anything if it's what's providing the formatting in the first place.
- waheoo 6y agoThats what im talking about. If you add text to a line, and it goes over a length, it will reformat a jsx element into about 5 lines instead of 1. Similarly, when you add more than it needs because you want consistency, or know youll add more, and the formatter runs, often it undoes your work.
- libria 6y agoIt's tunable. Pick a line length you all agree on and when it reformats after that, that's what you asked for. If the rule never works for you, turn that one off. If the rule is what you want 99% of the time but it made this one line look dumb, mark that one block #ignore and let the team decide in CR if that was the right call.
- earthboundkid 6y agoIf you really want 5 lines, add a dummy // in there and will be forced to use 5 instead of 1. Dirty hack, but it works.