only prepend whitespace to properties if we're the first

This commit is contained in:
Sebastian McKenzie 2014-11-09 16:28:56 +11:00
parent bd51215316
commit a90da9908c

View File

@ -20,7 +20,7 @@ Node.whitespace = {
ForStatement: 1,
SwitchStatement: 1,
IfStatement: { before: 1 },
Property: { before: 1 },
//Property: { before: 1 },
Literal: { after: 1 }
};
@ -68,13 +68,20 @@ Node.prototype.isUserWhitespacable = function () {
};
Node.prototype.needsWhitespace = function (type) {
var node = this.node;
var parent = this.parent;
var node = this.node;
if (!node) return 0;
if (t.isExpressionStatement(node)) {
node = node.expression;
}
if (type === "before") {
if (t.isProperty(node) && parent.properties[0] === node) {
return 1;
}
}
if (type === "after") {
if (t.isCallExpression(node)) {
return 1;
@ -120,7 +127,7 @@ Node.prototype.needsWhitespaceAfter = function () {
return this.needsWhitespace("after");
};
Node.prototype.needsParans = function () {
Node.prototype.needsParens = function () {
var parent = this.parent;
var node = this.node;