add parens on expressions with trailing comments - fixes #349

This commit is contained in:
Sebastian McKenzie
2015-01-02 00:57:48 +11:00
parent e3dc2355e8
commit 470c8fced0
4 changed files with 23 additions and 8 deletions

View File

@@ -60,6 +60,10 @@ Node.prototype.needsParens = function () {
if (!parent) return false;
if (t.isExpression(node) && node.leadingComments && node.leadingComments.length) {
return true;
}
if (t.isNewExpression(parent) && parent.callee === node) {
return t.isCallExpression(node) || _.some(node, function (val) {
return t.isCallExpression(val);