Thanks for your work, I'm VERY interested in something that deals with formatting in my place =)
One thing that struck me upon trying it out tonight, though, was that it does not handle "siblings" consistently. That is, given a list of, say, { id, name } objects; if one of them has a name large enough to reach the line limit, then this object, and this object alone, will be printed over 4 lines, while its siblings will be printed on 1 line. The "exploded" one will have a trailing comma, too, while obviously the one-liners will not.
Original test.js:
const myList = [
{
id: 0,
name: 'Short',
},
{
id: 1,
name: 'Short Too',
},
{
id: 3,
name: 'Too Long For Your Line Width',
},
];
Result ($ prettier --bracket-spacing --trailing-comma --print-width 40 test.js):
const myList = [
{ id: 0, name: "Short" },
{ id: 1, name: "Short Too" },
{
id: 3,
name: "Too Long For Your Line Width",
},
];
I think that in this case, the original is the better code: it's consistent, easily readable and parsable, at the only cost of taking a lot of vertical space (scrolling is cheap, though).
EDIT: removed JSX example and reworded the issue as per @vramana's comment.
Thanks for your work, I'm VERY interested in something that deals with formatting in my place =)
One thing that struck me upon trying it out tonight, though, was that it does not handle "siblings" consistently. That is, given a list of, say, { id, name } objects; if one of them has a name large enough to reach the line limit, then this object, and this object alone, will be printed over 4 lines, while its siblings will be printed on 1 line. The "exploded" one will have a trailing comma, too, while obviously the one-liners will not.
Original
test.js:Result (
$ prettier --bracket-spacing --trailing-comma --print-width 40 test.js):I think that in this case, the original is the better code: it's consistent, easily readable and parsable, at the only cost of taking a lot of vertical space (scrolling is cheap, though).
EDIT: removed JSX example and reworded the issue as per @vramana's comment.