Ignore EmptyStatement inside of switch case (#391)

Fixes #378
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-01-22 12:33:21 -08:00
1 parent 8ed75acf46
commit d944ebf6db
3 files changed
+11 -1

No files matched your search

+1 -1
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);
@@ -1,3 +1,12 @@
exports[`test empty_switch.js 1`] = `
"switch (1) { default:; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
switch (1) {
default:
}
"
`;
exports[`test more_switch.js 1`] = `
"/* @flow */
+1
View File
@@ -0,0 +1 @@
switch (1) { default:; }