Ignore EmptyStatement inside of switch case (#391)

Fixes #378
master
Christopher Chedeau 2017-01-22 12:33:21 -08:00 committed by GitHub
parent 8ed75acf46
commit d944ebf6db
3 changed files with 11 additions and 1 deletions

View File

@ -977,7 +977,7 @@ function genericPrintNoParens(path, options, print) {
if (n.test) parts.push("case ", path.call(print, "test"), ":");
else parts.push("default:");
if (n.consequent.length > 0) {
if (n.consequent.find(node => node.type !== "EmptyStatement")) {
const cons = path.call(
function(consequentPath) {
return printStatementSequence(consequentPath, options, print);

View File

@ -1,3 +1,12 @@
exports[`test empty_switch.js 1`] = `
"switch (1) { default:; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
switch (1) {
default:
}
"
`;
exports[`test more_switch.js 1`] = `
"/* @flow */

View File

@ -0,0 +1 @@
switch (1) { default:; }