diff --git a/changelog_unreleased/scss/11461.md b/changelog_unreleased/scss/11461.md new file mode 100644 index 000000000000..e470a4088597 --- /dev/null +++ b/changelog_unreleased/scss/11461.md @@ -0,0 +1,42 @@ + + +#### Consistently quote Sass modules strings (#11461 by @niksy) + + + + +```scss +// Input +@use "sass:math"; +@forward "list"; + +// Prettier stable +@use "sass:math"; +@forward "list"; + +// Prettier main +@use 'sass:math'; +@forward 'list'; +``` diff --git a/src/language-css/parser-postcss.js b/src/language-css/parser-postcss.js index 71b466bc940f..7a47524391c4 100644 --- a/src/language-css/parser-postcss.js +++ b/src/language-css/parser-postcss.js @@ -525,7 +525,7 @@ function parseNestedCSS(node, options) { return node; } - if (lowercasedName === "import") { + if (["import", "use", "forward"].includes(lowercasedName)) { node.import = true; delete node.filename; node.params = parseValue(params, options); diff --git a/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000000..ff900ce9ed15 --- /dev/null +++ b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`quotes.scss - {"singleQuote":true} format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 +singleQuote: true + | printWidth +=====================================input====================================== +@use "module"; +@forward "module"; + +=====================================output===================================== +@use 'module'; +@forward 'module'; + +================================================================================ +`; + +exports[`quotes.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +@use "module"; +@forward "module"; + +=====================================output===================================== +@use "module"; +@forward "module"; + +================================================================================ +`; diff --git a/tests/format/scss/quotes/jsfmt.spec.js b/tests/format/scss/quotes/jsfmt.spec.js new file mode 100644 index 000000000000..0c94ceec9417 --- /dev/null +++ b/tests/format/scss/quotes/jsfmt.spec.js @@ -0,0 +1,2 @@ +run_spec(__dirname, ["scss"]); +run_spec(__dirname, ["scss"], { singleQuote: true }); diff --git a/tests/format/scss/quotes/quotes.scss b/tests/format/scss/quotes/quotes.scss new file mode 100644 index 000000000000..9d6af808c126 --- /dev/null +++ b/tests/format/scss/quotes/quotes.scss @@ -0,0 +1,2 @@ +@use "module"; +@forward "module";