Skip to content

Commit

Permalink
Fix issue semi-colon gets inserted unnecessarily (#5749)
Browse files Browse the repository at this point in the history
* Fix issue semi-colon gets inserted unnecessarily

* Simplify if condition a bit
  • Loading branch information
buunguyen authored and hzoo committed May 19, 2017
1 parent 2788a91 commit c474fd4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Expand Up @@ -17,14 +17,11 @@ var A = function (_B) {
_classCallCheck(this, A);

if (track !== undefined) {
;

var _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this, track));
} else {
;

var _this = _possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this));
}return _possibleConstructorReturn(_this);
}
return _possibleConstructorReturn(_this);
}

return A;
Expand Down
@@ -0,0 +1 @@
if (true) [a, b] = [b, a];
@@ -0,0 +1,6 @@
if (true) {
var _ref = [b, a];
a = _ref[0];
b = _ref[1];
_ref;
}
5 changes: 4 additions & 1 deletion packages/babel-traverse/src/path/modification.js
Expand Up @@ -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. " +
Expand Down

0 comments on commit c474fd4

Please sign in to comment.