Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wildcard syntax in @forward (#11482) #11487

Merged
merged 3 commits into from Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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-*;
```
13 changes: 13 additions & 0 deletions src/language-css/printer-postcss.js
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions tests/format/scss/quotes/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -29,6 +29,8 @@ singleQuote: true

@forward "library" as btn-*;

@forward "library" as btn*;

=====================================output=====================================
@use 'library';

Expand All @@ -47,7 +49,9 @@ singleQuote: true

@forward 'library' hide gradient;

@forward 'library' as btn- *;
@forward 'library' as btn-*;

@forward 'library' as btn*;

================================================================================
`;
Expand Down Expand Up @@ -80,6 +84,8 @@ printWidth: 80

@forward "library" as btn-*;

@forward "library" as btn*;

=====================================output=====================================
@use "library";

Expand All @@ -98,7 +104,9 @@ printWidth: 80

@forward "library" hide gradient;

@forward "library" as btn- *;
@forward "library" as btn-*;

@forward "library" as btn*;

================================================================================
`;
2 changes: 2 additions & 0 deletions tests/format/scss/quotes/quotes.scss
Expand Up @@ -19,3 +19,5 @@
@forward "library" hide gradient;

@forward "library" as btn-*;

@forward "library" as btn*;