Skip to content

Commit 59b5eb4

Browse files
niksythorn0
andauthored
Fix wildcard syntax in @forward (#11482) (#11487)
* Fix wildcard syntax in `@forward` (#11482) * Add additional tests * Apply suggestions from code review Co-authored-by: Georgii Dolzhykov <[email protected]> Co-authored-by: Georgii Dolzhykov <[email protected]>
1 parent aa63269 commit 59b5eb4

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

changelog_unreleased/scss/11487.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#### Fix wildcard syntax in `@forward` (#11482) (#11487 by @niksy)
2+
3+
<!-- prettier-ignore -->
4+
```scss
5+
// Input
6+
@forward "library" as btn-*;
7+
8+
// Prettier stable
9+
@forward "library" as btn- *;
10+
11+
// Prettier main
12+
@forward "library" as btn-*;
13+
```

src/language-css/printer-postcss.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,19 @@ function genericPrint(path, options, print) {
550550
continue;
551551
}
552552

553+
// Ignore SCSS @forward wildcard suffix
554+
if (
555+
insideAtRuleNode(path, "forward") &&
556+
iNode.type === "value-word" &&
557+
iNode.value &&
558+
iPrevNode.type === "value-word" &&
559+
iPrevNode.value === "as" &&
560+
iNextNode.type === "value-operator" &&
561+
iNextNode.value === "*"
562+
) {
563+
continue;
564+
}
565+
553566
// Ignore after latest node (i.e. before semicolon)
554567
if (!iNextNode) {
555568
continue;

tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ singleQuote: true
2929
3030
@forward "library" as btn-*;
3131
32+
@forward "library" as btn*;
33+
3234
=====================================output=====================================
3335
@use 'library';
3436
@@ -47,7 +49,9 @@ singleQuote: true
4749
4850
@forward 'library' hide gradient;
4951
50-
@forward 'library' as btn- *;
52+
@forward 'library' as btn-*;
53+
54+
@forward 'library' as btn*;
5155
5256
================================================================================
5357
`;
@@ -80,6 +84,8 @@ printWidth: 80
8084
8185
@forward "library" as btn-*;
8286
87+
@forward "library" as btn*;
88+
8389
=====================================output=====================================
8490
@use "library";
8591
@@ -98,7 +104,9 @@ printWidth: 80
98104
99105
@forward "library" hide gradient;
100106
101-
@forward "library" as btn- *;
107+
@forward "library" as btn-*;
108+
109+
@forward "library" as btn*;
102110
103111
================================================================================
104112
`;

tests/format/scss/quotes/quotes.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
@forward "library" hide gradient;
2020

2121
@forward "library" as btn-*;
22+
23+
@forward "library" as btn*;

0 commit comments

Comments
 (0)