Skip to content

Commit

Permalink
Fix wildcard syntax in @forward (#11482)
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy committed Sep 10, 2021
1 parent d3d1bc1 commit 9aa02da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
13 changes: 13 additions & 0 deletions changelog_unreleased/scss/11487.md
@@ -0,0 +1,13 @@
#### Fix wildcard syntax in `@forward` (#11482) (#11487 by @niksy)

<!-- prettier-ignore -->
```scss
// Input
@forward "library" as btn-*;

// Prettier stable
@forward "library" as btn- *;

// Prettier main
@forward "library" as btn-*;
```
11 changes: 11 additions & 0 deletions src/language-css/printer-postcss.js
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -47,7 +47,7 @@ singleQuote: true
@forward 'library' hide gradient;
@forward 'library' as btn- *;
@forward 'library' as btn-*;
================================================================================
`;
Expand Down Expand Up @@ -98,7 +98,7 @@ printWidth: 80
@forward "library" hide gradient;
@forward "library" as btn- *;
@forward "library" as btn-*;
================================================================================
`;

0 comments on commit 9aa02da

Please sign in to comment.