From c36dd48339c3dacc321e118d8d2f48c019a58dfa Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 21 Jun 2017 15:45:55 -0700 Subject: [PATCH] First try scss when there's an @import with comma (#2225) It's annoying that the less parser is so lenient that it drops things instead of throwing :( Fixes #2125 --- src/parser-postcss.js | 2 +- tests/css_scss/__snapshots__/jsfmt.spec.js.snap | 7 +++++++ tests/css_scss/import_comma.css | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/css_scss/import_comma.css diff --git a/src/parser-postcss.js b/src/parser-postcss.js index c1a94f951..1c77f6347 100644 --- a/src/parser-postcss.js +++ b/src/parser-postcss.js @@ -209,7 +209,7 @@ function requireParser(isSCSS) { } function parse(text) { - const isLikelySCSS = !!text.match(/(\w\s*: [^}:]+|#){|\@import url/); + const isLikelySCSS = !!text.match(/(\w\s*: [^}:]+|#){|\@import[^\n]+(url|,)/); try { return parseWithParser(requireParser(isLikelySCSS), text); } catch (e) { diff --git a/tests/css_scss/__snapshots__/jsfmt.spec.js.snap b/tests/css_scss/__snapshots__/jsfmt.spec.js.snap index 1a11bc92c..e726f9ff0 100644 --- a/tests/css_scss/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css_scss/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`import_comma.css 1`] = ` +@import "rounded-corners", "text-shadow"; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +@import "rounded-corners", "text-shadow"; + +`; + exports[`scss.css 1`] = ` @media #{$g-breakpoint-tiny} {} .#{$fa-css-prefix}-glass:before { content: $fa-var-glass; } diff --git a/tests/css_scss/import_comma.css b/tests/css_scss/import_comma.css new file mode 100644 index 000000000..bea7a805e --- /dev/null +++ b/tests/css_scss/import_comma.css @@ -0,0 +1 @@ +@import "rounded-corners", "text-shadow";