diff --git a/changelog_unreleased/scss/11487.md b/changelog_unreleased/scss/11487.md new file mode 100644 index 000000000000..f562cf488cc5 --- /dev/null +++ b/changelog_unreleased/scss/11487.md @@ -0,0 +1,13 @@ +#### Fix wildcard syntax in `@forward` (#11482) (#11487 by @niksy) + + +```scss +// Input +@forward "library" as btn-*; + +// Prettier stable +@forward "library" as btn- *; + +// Prettier main +@forward "library" as btn-*; +``` diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index c7ebe7e561f4..0c326d6d26bd 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -550,6 +550,19 @@ function genericPrint(path, options, print) { continue; } + // Ignore SCSS @forward wildcard suffix + if ( + insideAtRuleNode(path, "forward") && + iNode.type === "value-word" && + iNode.value && + iPrevNode.type === "value-word" && + iPrevNode.value === "as" && + iNextNode.type === "value-operator" && + iNextNode.value === "*" + ) { + continue; + } + // Ignore after latest node (i.e. before semicolon) if (!iNextNode) { continue; diff --git a/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap index 042fdbb3bf79..06419858dada 100644 --- a/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap @@ -29,6 +29,8 @@ singleQuote: true @forward "library" as btn-*; +@forward "library" as btn*; + =====================================output===================================== @use 'library'; @@ -47,7 +49,9 @@ singleQuote: true @forward 'library' hide gradient; -@forward 'library' as btn- *; +@forward 'library' as btn-*; + +@forward 'library' as btn*; ================================================================================ `; @@ -80,6 +84,8 @@ printWidth: 80 @forward "library" as btn-*; +@forward "library" as btn*; + =====================================output===================================== @use "library"; @@ -98,7 +104,9 @@ printWidth: 80 @forward "library" hide gradient; -@forward "library" as btn- *; +@forward "library" as btn-*; + +@forward "library" as btn*; ================================================================================ `; diff --git a/tests/format/scss/quotes/quotes.scss b/tests/format/scss/quotes/quotes.scss index 332074a453a5..20607380fbad 100644 --- a/tests/format/scss/quotes/quotes.scss +++ b/tests/format/scss/quotes/quotes.scss @@ -19,3 +19,5 @@ @forward "library" hide gradient; @forward "library" as btn-*; + +@forward "library" as btn*;