From 5847c168e4360727d8e4c160600104191c93dc80 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Wed, 9 Jan 2019 17:08:34 +0100 Subject: [PATCH] Fix formatting of lists in SCSS property/variable values (#5710) --- src/language-css/printer-postcss.js | 14 ++------------ .../css_comments/__snapshots__/jsfmt.spec.js.snap | 8 ++++++++ tests/css_comments/lists.scss | 5 +++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index 14dc1a87..dc31d532 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -625,19 +625,9 @@ function genericPrint(path, options, print) { continue; } - // Ignore inline comment, they already contain newline at end (i.e. `// Comment`) // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`) - const isInlineComment = isInlineValueCommentNode(iNode); - - if ( - (iPrevNode && isInlineValueCommentNode(iPrevNode)) || - isInlineComment || - isInlineValueCommentNode(iNextNode) - ) { - if (isInlineComment) { - parts.push(hardline); - } - + if (isInlineValueCommentNode(iNode)) { + parts.push(hardline); continue; } diff --git a/tests/css_comments/__snapshots__/jsfmt.spec.js.snap b/tests/css_comments/__snapshots__/jsfmt.spec.js.snap index 7255a01c..e96fb1bf 100644 --- a/tests/css_comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css_comments/__snapshots__/jsfmt.spec.js.snap @@ -699,11 +699,19 @@ $my-list: 'foo', // Foo 'bar'; // Bar +$my-list2: + a // a + b + c; + =====================================output===================================== $my-list: "foo", // Foo "bar"; // Bar +$my-list2: a // a + b c; + ================================================================================ `; diff --git a/tests/css_comments/lists.scss b/tests/css_comments/lists.scss index 7e2d9b3c..b4b72e3b 100644 --- a/tests/css_comments/lists.scss +++ b/tests/css_comments/lists.scss @@ -1,3 +1,8 @@ $my-list: 'foo', // Foo 'bar'; // Bar + +$my-list2: + a // a + b + c;