Fix issue semi-colon gets inserted unnecessarily (#5749)

* Fix issue semi-colon gets inserted unnecessarily

* Simplify if condition a bit
This commit is contained in:
Buu Nguyen
2017-05-19 13:54:51 -07:00
committed by Henry Zhu
parent 2788a914f6
commit c474fd48e1
4 changed files with 13 additions and 6 deletions

View File

@@ -126,7 +126,10 @@ export function insertAfter(nodes) {
if (Array.isArray(this.container)) {
return this._containerInsertAfter(nodes);
} else if (this.isStatementOrBlock()) {
if (this.node) nodes.unshift(this.node);
// Unshift current node if it's not an empty expression
if (this.node && (!this.isExpressionStatement() || this.node.expression != null)) {
nodes.unshift(this.node);
}
this._replaceWith(t.blockStatement(nodes));
} else {
throw new Error("We don't know what to do with this node type. " +