One of the most contentious decisions in Prettier and the reason I personally no longer use it for any projects, was its forcing the removal of breaks before else blocks: prettier/prettier#840
To illustrate two issues with this, consider the following code:
// comment for if block
if (cond1) {
doFoo(tree, data);
if (cond2) {
collect(tree.left, data, depth + 1);
collect(tree.right, data, depth + 1);
}
}
// comment for else block
else {
doBar(data);
}
As it is now, Rome will throw errors suggesting the following format
// comment for if block
if (cond1) {
doFoo(tree, data);
if (cond2) {
collect(tree.left, data, depth + 1);
collect(tree.right, data, depth + 1);
}
} else {
// comment for else block
doBar(data);
}
The problems with eliminating the break before the else are that it now lines up the else block with the wrong conditional and that it eliminates the clearest place for the else block comments.
I don't see much upside in a linter being rigid to this degree, and based on the the discussion on the Prettier issue linked above, many others would agree.
Edit: Since the title was changed, I'll reiterate:
I strongly prefer not removing the break before else, even in cases where there are no comments. The else should line up with the if it corresponds to, not an inner one.
One of the most contentious decisions in Prettier and the reason I personally no longer use it for any projects, was its forcing the removal of breaks before else blocks: prettier/prettier#840
To illustrate two issues with this, consider the following code:
As it is now, Rome will throw errors suggesting the following format
The problems with eliminating the break before the else are that it now lines up the else block with the wrong conditional and that it eliminates the clearest place for the else block comments.
I don't see much upside in a linter being rigid to this degree, and based on the the discussion on the Prettier issue linked above, many others would agree.
Edit: Since the title was changed, I'll reiterate:
I strongly prefer not removing the break before else, even in cases where there are no comments. The
elseshould line up with theifit corresponds to, not an inner one.