4 ms·
What should Prettier should do in this case? I think we can all agree there should be a line length limit, it has to enforce it eventually. You could say “it’s
by atom_arranger 3y ago
What should Prettier should do in this case?
I think we can all agree there should be a line length limit, it has to enforce it eventually. You could say “it’s just a couple more characters” until the line is 200 characters long.
Semantic diff is maybe the solution.
- nicoburns 3y agoIt should put more weight on the length that the author has original authored it as. So between "always break" and "always expand" there should be an area of "leave it however it already is".
- zeroonetwothree 3y agoPrettier needs to be consistent regardless of the original input. Otherwise it won’t really work well.
- nicoburns 3y agoI don't think it does. Plenty of code formatters are not completely, and work just fine.
- pigeonhole123 3y agoIt can safely ignore the line length, gofmt does this and I've never heard anyone complain about it. The VSCode formatter also doesn't touch line breaks and it works fine. Last time I looked into it, the only reason I can't turn it off is that Prettier works off an AST that doesn't keep the line breaks that the user put into the code at all, and it "rebuilds" the whole code from this AST. The problem is not the diff per se, the real problem is that I can't find a configuration of Prettier where I can have long lines where it makes sense and short ones where that makes sense.