only align variable declarations if at least one declarator has an init
This commit is contained in:
@@ -157,7 +157,22 @@ exports.DebuggerStatement = function () {
|
||||
exports.VariableDeclaration = function (node, print, parent) {
|
||||
this.push(node.kind + " ");
|
||||
|
||||
print.join(node.declarations, { separator: ",\n" + this.getIndent(2) });
|
||||
var hasInits = false;
|
||||
for (var i in node.declarations) {
|
||||
if (node.declarations[i].init) {
|
||||
hasInits = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var sep = ",";
|
||||
if (hasInits) {
|
||||
sep += "\n" + this.getIndent(2);
|
||||
} else {
|
||||
sep += " ";
|
||||
}
|
||||
|
||||
print.join(node.declarations, { separator: sep });
|
||||
|
||||
if (!t.isFor(parent)) {
|
||||
this.semicolon();
|
||||
|
||||
Reference in New Issue
Block a user