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
Format SCSS maps like CSS rules #3070
Conversation
src/printer-postcss.js
Outdated
join(concat([",", line]), path.map(print, "groups")) | ||
join( | ||
concat([",", parent.type === "value-value" ? hardline : line]), | ||
path.map(print, "groups") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you've probably noticed, the AST nodes in CSS/SCSS/Less are super vague and super general. While this PR looks good, I'm worried about what unintended side effects this might/will have. Our tests aren't very comprehensive. But I guess we could also just release it and do the regular couple of point releases afterwards with CSS regression fixes ¯\_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it help if we checked startsWith('$')
on the parent value? If that doesn't give any more assurance, I am fine fielding any regressions that arise related to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the startsWith
check is a good idea, but otherwise LGTM.
Added the |
src/printer-postcss.js
Outdated
const declaration = path.getParentNode(2); | ||
const isMap = | ||
declaration.type === "css-decl" && declaration.prop.startsWith("$"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to be a bit defensive and prefix with declaration &&
. It might not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - just updated.
Thanks! |
Resolves #3056
This makes prettier format SCSS maps like CSS rules (line breaks after each rule). e.g.
will format to