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

Update isSCSS test regex #7922

Merged
merged 2 commits into from
Apr 2, 2020
Merged

Update isSCSS test regex #7922

merged 2 commits into from
Apr 2, 2020

Conversation

fisker
Copy link
Member

@fisker fisker commented Apr 1, 2020

Fix css_atrule/include.css second format.

I don't really understand this regex, but space after : should be optional.

It's added in https://github.com/prettier/prettier/pull/4317/files#diff-29bcb0b461c4ae51930e975e53edfdd9L481

Try the playground for this PR

@@ -60,7 +60,7 @@ function getPropOfDeclNode(path) {

function isSCSS(parser, text) {
const hasExplicitParserChoice = parser === "less" || parser === "scss";
const IS_POSSIBLY_SCSS = /(\w\s*: [^}:]+|#){|@import[^\n]+(url|,)/;
const IS_POSSIBLY_SCSS = /(\w\s*: ?[^}:]+|#){|@import[^\n]+(url|,)/;
Copy link
Member Author

Choose a reason for hiding this comment

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

Should it be *?

Copy link
Member

Choose a reason for hiding this comment

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

I can't understand regexp too 😄 , I think we should rewrite it, on looking extension

Copy link
Member Author

@fisker fisker Apr 2, 2020

Choose a reason for hiding this comment

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

You mean file extension? File extension is not always available, maybe check actual parser (not options.parser)?

This function is also used to decided parser...

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

I think we should avoid using regex to choice of parser, it most likely doesn't even work correctly

@fisker
Copy link
Member Author

fisker commented Apr 2, 2020

Let's keep it this way to make test pass, we won't need it anymore after #7933

@thorn0 thorn0 merged commit 93aa378 into prettier:master Apr 2, 2020
@fisker fisker deleted the is-scss-regex branch April 2, 2020 12:59
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2021
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.

3 participants