diff --git a/src/pp.js b/src/pp.js index b2ee3bfb7..7b09d3f78 100644 --- a/src/pp.js +++ b/src/pp.js @@ -239,6 +239,11 @@ function print(w, doc) { } // fallthrough case MODE_BREAK: + const lastString = out[out.length - 1]; + if(lastString.match(/^\s*\n\s*$/)) { + out[out.length - 1] = "\n"; + } + if(doc.literal) { out.push("\n"); pos = 0; diff --git a/src/printer.js b/src/printer.js index 3bfe6cf70..0e697676c 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1680,7 +1680,7 @@ function printStatementSequence(path, options, print) { parts.push(stmtPrinted); if (addSpacing && !isLastStatement(stmtPath)) { - parts.push(literalline); + parts.push(hardline); } printed.push(concat(parts));