From 0dc93484c9312ed43cf5afba83674831883cfca4 Mon Sep 17 00:00:00 2001 From: "bhavinpatel@ebay.com" Date: Mon, 31 Dec 2018 16:17:51 -0800 Subject: [PATCH 1/5] remove new lines after a group of statements --- packages/prettyprint/src/printNodes.js | 15 ++++++++++++++- .../test/autotest/static-vars/expected.marko | 19 +++++++++++++++++++ .../test/autotest/static-vars/template.marko | 7 +++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 packages/prettyprint/test/autotest/static-vars/expected.marko create mode 100644 packages/prettyprint/test/autotest/static-vars/template.marko diff --git a/packages/prettyprint/src/printNodes.js b/packages/prettyprint/src/printNodes.js index 335f411e..e7fa469a 100644 --- a/packages/prettyprint/src/printNodes.js +++ b/packages/prettyprint/src/printNodes.js @@ -132,9 +132,22 @@ module.exports = function printNodes(nodes, printContext, inputWriter) { } // Insert line break between certain top-level tags - if (breakAfterTags[prevChild.tagName]) { + if ( + breakAfterTags[prevChild.tagName] && + child.tagName != prevChild.tagName + ) { writer.write(printContext.eol); } + + //Insert line break group of scriptlets + if ( + child.type === "Text" && + child.nextSibling && + (!prevChild.tag && + prevChild.type === "Scriptlet" && + child.nextSibling.type !== "Scriptlet") + ) + writer.write(printContext.eol); } printers.printNode(child, printContext, childWriter); diff --git a/packages/prettyprint/test/autotest/static-vars/expected.marko b/packages/prettyprint/test/autotest/static-vars/expected.marko new file mode 100644 index 00000000..c6a2dee2 --- /dev/null +++ b/packages/prettyprint/test/autotest/static-vars/expected.marko @@ -0,0 +1,19 @@ +static var a = 1; +static var b = 2; +static var c = 1; + +$ var k = 1; +$ var l = 2; +$ var m = 3; + +
+~~~~~~~ +static var a = 1; +static var b = 2; +static var c = 1; + +$ var k = 1; +$ var l = 2; +$ var m = 3; + +div \ No newline at end of file diff --git a/packages/prettyprint/test/autotest/static-vars/template.marko b/packages/prettyprint/test/autotest/static-vars/template.marko new file mode 100644 index 00000000..a1598244 --- /dev/null +++ b/packages/prettyprint/test/autotest/static-vars/template.marko @@ -0,0 +1,7 @@ +static var a = 1; +static var b = 2; +static var c = 1; +$ var k = 1; +$ var l = 2; +$ var m = 3; +
\ No newline at end of file From f1c0c21a9dcb1a3d38261905f0c53d7ad2bf43c0 Mon Sep 17 00:00:00 2001 From: "bhavinpatel@ebay.com" Date: Mon, 31 Dec 2018 16:20:38 -0800 Subject: [PATCH 2/5] fix test cases --- packages/prettyprint/test/autotest/js-block/expected.marko | 4 +++- packages/prettyprint/test/autotest/js-line/expected.marko | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/prettyprint/test/autotest/js-block/expected.marko b/packages/prettyprint/test/autotest/js-block/expected.marko index 9fbadf20..f40b81e0 100644 --- a/packages/prettyprint/test/autotest/js-block/expected.marko +++ b/packages/prettyprint/test/autotest/js-block/expected.marko @@ -2,10 +2,12 @@ $ { var name = "Frank"; console.log(`Hello ${name}!`); } +
~~~~~~~ $ { var name = "Frank"; console.log(`Hello ${name}!`); } -div + +div \ No newline at end of file diff --git a/packages/prettyprint/test/autotest/js-line/expected.marko b/packages/prettyprint/test/autotest/js-line/expected.marko index 25ebc409..50577828 100644 --- a/packages/prettyprint/test/autotest/js-line/expected.marko +++ b/packages/prettyprint/test/autotest/js-line/expected.marko @@ -1,5 +1,7 @@ $ console.log("Hello World!"); +
~~~~~~~ $ console.log("Hello World!"); -div + +div \ No newline at end of file From 4e67cd44c0cb6a50b7855278c6fa9300ae442b5d Mon Sep 17 00:00:00 2001 From: "bhavinpatel@ebay.com" Date: Mon, 31 Dec 2018 16:29:08 -0800 Subject: [PATCH 3/5] included test case for import --- packages/prettyprint/test/autotest/static-vars/template.marko | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/prettyprint/test/autotest/static-vars/template.marko b/packages/prettyprint/test/autotest/static-vars/template.marko index a1598244..745ee2e6 100644 --- a/packages/prettyprint/test/autotest/static-vars/template.marko +++ b/packages/prettyprint/test/autotest/static-vars/template.marko @@ -1,6 +1,9 @@ static var a = 1; static var b = 2; static var c = 1; +import { foo } from './bar' +import { blah } from './foo' +import { haha } from './blah' $ var k = 1; $ var l = 2; $ var m = 3; From a61dd932344368e8f40ae7e2f54648ed989f8d71 Mon Sep 17 00:00:00 2001 From: "bhavinpatel@ebay.com" Date: Thu, 3 Jan 2019 11:28:17 -0800 Subject: [PATCH 4/5] fix testcase --- .../prettyprint/test/autotest/static-vars/expected.marko | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/prettyprint/test/autotest/static-vars/expected.marko b/packages/prettyprint/test/autotest/static-vars/expected.marko index c6a2dee2..07a9d740 100644 --- a/packages/prettyprint/test/autotest/static-vars/expected.marko +++ b/packages/prettyprint/test/autotest/static-vars/expected.marko @@ -2,6 +2,10 @@ static var a = 1; static var b = 2; static var c = 1; +import { foo } from './bar' +import { blah } from './foo' +import { haha } from './blah' + $ var k = 1; $ var l = 2; $ var m = 3; @@ -12,6 +16,10 @@ static var a = 1; static var b = 2; static var c = 1; +import { foo } from './bar' +import { blah } from './foo' +import { haha } from './blah' + $ var k = 1; $ var l = 2; $ var m = 3; From 5d9437068be706338304b47da9fc74263e0878e3 Mon Sep 17 00:00:00 2001 From: "bhavinpatel@ebay.com" Date: Thu, 3 Jan 2019 11:59:50 -0800 Subject: [PATCH 5/5] fix migrate test cases --- .../test/fixtures/multiple-templates/snapshot-expected.marko | 1 + .../test/fixtures/single-template/snapshot-expected.marko | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko b/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko index ff7478b2..a582efc0 100644 --- a/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko +++ b/packages/migrate/test/fixtures/multiple-templates/snapshot-expected.marko @@ -2,6 +2,7 @@ $ var x = 1; $ x++; + -- ${x} diff --git a/packages/migrate/test/fixtures/single-template/snapshot-expected.marko b/packages/migrate/test/fixtures/single-template/snapshot-expected.marko index 4da9e689..c8e223e7 100644 --- a/packages/migrate/test/fixtures/single-template/snapshot-expected.marko +++ b/packages/migrate/test/fixtures/single-template/snapshot-expected.marko @@ -2,4 +2,5 @@ $ var x = 1; $ x++; + -- ${x}