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 Compare September 10, 2021 07:00
Comment on lines 555 to 563
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your quick PR!

@sosukesuzuki
Copy link
Member

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

@fisker
Copy link
Member

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 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 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 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>
@sosukesuzuki sosukesuzuki merged commit 59b5eb4 into prettier:main Sep 16, 2021
@sosukesuzuki
Copy link
Member

I'll release new patch version includes this.

@sosukesuzuki
Copy link
Member

done

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[scss] Wildcard syntax in @forward broken
5 participants