Skip to content

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

Merged
sosukesuzuki merged 3 commits intoprettier:mainfrom
niksy:scss-forward-prefix
Sep 16, 2021
Merged

Fix wildcard syntax in @forward (#11482)#11487
sosukesuzuki merged 3 commits intoprettier:mainfrom
niksy:scss-forward-prefix

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
Contributor

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
Contributor

@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 sosukesuzuki requested a review from fisker September 10, 2021 12:00
@sosukesuzuki
Copy link
Contributor

@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!

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
@sosukesuzuki sosukesuzuki merged commit 59b5eb4 into prettier:main Sep 16, 2021
@sosukesuzuki
Copy link
Contributor

I'll release new patch version includes this.

@sosukesuzuki
Copy link
Contributor

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