This is a wiser design because the formatter can't know what the best layout is, and a formatter really ought to only format something where there's is an unequivocally, universally correct way of formatting something.
As an example, sometimes table-driven test are better written compactly, sometimes better verbosely. As a naive example:
for _, c := range []testcase{
{input: 1, expect: 10},
{input: 2, expect: 20},
{input: 3, expect: 30},
} {
assert.Equal(t, c.expect, someFuncToBeTested(c.input))
}
If the formatter starts splitting each testcase entry up over several lines, like so: {
input: 1,
expect: 10,
},
...then you potentially lose readability. In other cases, you have more complicated structs that might fit on one line, but deserve to be formatted across multiple lines.This is something Prettier doesn't always do correctly, and with Prettier, you don't have a choice. Opinionated is good when there is just one answer, but not when there's a range of possibly answers.