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..f1aa6ba425fb 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -550,6 +550,17 @@ function genericPrint(path, options, print) { continue; } + // Ignore SCSS @forward prefix + if ( + insideAtRuleNode(path, "forward") && + iNode.type === "value-word" && + iNode.value.endsWith("-") && + 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..4d368ad98852 100644 --- a/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap @@ -47,7 +47,7 @@ singleQuote: true @forward 'library' hide gradient; -@forward 'library' as btn- *; +@forward 'library' as btn-*; ================================================================================ `; @@ -98,7 +98,7 @@ printWidth: 80 @forward "library" hide gradient; -@forward "library" as btn- *; +@forward "library" as btn-*; ================================================================================ `;