3 ms·
I use prettier religiously. Works on js, typescript, jsx, css, json, html, sass, yaml and a whole bunch of others. The vscode prettier plugin brings format on
by nojvek 7y ago
I use prettier religiously. Works on js, typescript, jsx, css, json, html, sass, yaml and a whole bunch of others.
The vscode prettier plugin brings format on save and it makes coding a joy.
I think what prettier does is much simpler than dart. It tries to put things on a single line if it’s within line length, if it can’t then it uses multi line where each item is in its own line with ending bracket at same indentation level. For arrays, functions, object definitions, jsx etc. I’ve written some automated code generators that output pretty code and that’s how I tend to approach it too. You either get compact or expanded version and that happens recursively. There is some backtracking but there’s early exits when compact strategy exceeds line length so it’s pretty fast.
After reading the blog article it put me off that starting and closing brackets were not at same indent level. I know lispers do this but I’m not used to it so it hurts my brain.
One of my interview questions is to pretty print json files to a certain line length.