Fix empty line in block with EmptyStatement (#1375)

* Fix empty line in block with EmptyStatement

* Update code per review
master
Vinh Le 2017-04-22 22:57:52 +08:00 committed by Christopher Chedeau
parent 7a8380772d
commit d0e8976af8
3 changed files with 21 additions and 1 deletions

View File

@ -3428,7 +3428,7 @@ function isFirstStatement(path) {
function isLastStatement(path) {
const parent = path.getParentNode();
const node = path.getValue();
const body = parent.body;
const body = parent.body.filter(stmt => stmt.type !== "EmptyStatement");
return body && body[body.length - 1] === node;
}

View File

@ -21,3 +21,17 @@ do;
while (1);
`;
exports[`no-newline.js 1`] = `
if (a) {
b;
;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (a) {
b;
}
`;

View File

@ -0,0 +1,6 @@
if (a) {
b;
;
}