millermedeiros / esformatter

ECMAScript code beautifier/formatter
MIT License
970 stars 91 forks source link

Does not format space before "else" in else if statement #438

Closed felixhao28 closed 8 years ago

felixhao28 commented 8 years ago

Is there a way to configure esformatter to format this:

if (a == 1) {
  b;
}else if (a == 2) { // notice the space before else
  c;
} else {
  d;
}

into

if (a == 1) {
  b;
} else if (a == 2) { // notice the space before else
  c;
} else {
  d;
}

I read your code and it does not seem to handle that specific space.

millermedeiros commented 8 years ago

the code is always formatted the way you expect with the default settings.

the space between } and else is handled by whiteSpace.after.IfStatementClosingBrace, try esformatter --whiteSpace.after.IfStatementClosingBrace=1 and esformatter --whiteSpace.after.IfStatementClosingBrace=0 to see the difference in the behavior.