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 f83ec5c
Show file tree
Hide file tree
Showing 3 changed files with 31 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-*;
```
16 changes: 16 additions & 0 deletions src/language-css/printer-postcss.js
Expand Up @@ -550,6 +550,22 @@ function genericPrint(path, options, print) {
continue;
}

// Ignore SCSS @forward wildcard suffix
if (
insideAtRuleNode(path, "forward") &&
iNode.type === "value-word" &&
iNode.value &&
iNode.value.endsWith("-") &&
iPrevNode.type === "value-word" &&
iPrevNode.value &&
iPrevNode.value === "as" &&
iNextNode.type === "value-operator" &&
iNextNode.value &&
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 f83ec5c

Please sign in to comment.