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

Conversation

@niksy
Copy link
Contributor

@niksy niksy commented Sep 10, 2021

Description

Fixes #11482.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@niksy niksy force-pushed the scss-forward-prefix branch 2 times, most recently from 9aa02da to f83ec5c Sep 10, 2021
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 === "*"
Copy link
Member

@sosukesuzuki sosukesuzuki Sep 10, 2021

@alexander-akait Could you check if this condition works file? Sorry I'm not familiar with SCSS...

Copy link
Member

@alexander-akait alexander-akait Sep 10, 2021

I think fine

Copy link
Member

@alexander-akait alexander-akait Sep 10, 2021

Ideally we need special logic for @use/@forward, but it will require parser for this, postcss-values-parser violate spec in many places, to solve it in right way we need another parser, so I think we can safely merge it

Copy link
Contributor Author

@niksy niksy Sep 10, 2021

@sosukesuzuki @alexander-akait check is based on official documentation on prefixes. @forward is available only for Sass files.

Copy link
Member

@sosukesuzuki sosukesuzuki left a comment

Thanks for your quick PR!

@sosukesuzuki sosukesuzuki requested a review from fisker Sep 10, 2021
@sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Sep 11, 2021

@fisker Can you review this? If you approve this, I'll release new patch version.

@fisker
Copy link
Member

@fisker fisker commented Sep 11, 2021

Are these valid?

Prettier pr-11487
Playground link

--parser scss

Input:

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

Output:

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

@fisker
Copy link
Member

@fisker fisker commented Sep 11, 2021

This should not related to this PR, but somehow cross the printWidth

Prettier pr-11487
Playground link

--parser scss

Input:

@forward 'library' with (
  $black: #222 !default,
  $border-radius: 0.1rem !default
);

Output:

@forward "library" with ($black: #222 !default, $border-radius: 0.1rem !default);

@niksy
Copy link
Contributor Author

@niksy niksy commented Sep 13, 2021

@fisker

Input:

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

Only the first is valid, and I’ve made changes to reflect that. Other two are invalid Sass syntax for @forward rule.

@niksy
Copy link
Contributor Author

@niksy niksy commented Sep 13, 2021

This should not related to this PR, but somehow cross the printWidth

Prettier pr-11487
Playground link

--parser scss

Input:

@forward 'library' with (
  $black: #222 !default,
  $border-radius: 0.1rem !default
);

Output:

@forward "library" with ($black: #222 !default, $border-radius: 0.1rem !default);

You’re right, this is not related to this PR. I will create new one with adjustments.

EDIT: Done!

src/language-css/printer-postcss.js Outdated Show resolved Hide resolved
src/language-css/printer-postcss.js Outdated Show resolved Hide resolved
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
thorn0
thorn0 approved these changes Sep 15, 2021
@sosukesuzuki sosukesuzuki merged commit 59b5eb4 into prettier:main Sep 16, 2021
25 checks passed
@sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Sep 16, 2021

I'll release new patch version includes this.

@sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Sep 16, 2021

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants