Empty switch should not have an empty line (#384)

Fixes #368
master
Christopher Chedeau 2017-01-22 12:40:46 -08:00 committed by GitHub
parent 3d95e8317b
commit 7be4994d1a
3 changed files with 6 additions and 2 deletions

View File

@ -971,10 +971,10 @@ function genericPrintNoParens(path, options, print) {
"switch (",
path.call(print, "discriminant"),
") {",
indent(
n.cases.length > 0 ? indent(
options.tabWidth,
concat([ hardline, join(hardline, path.map(print, "cases")) ])
),
) : "",
hardline,
"}"
]);

View File

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

View File

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