Repository navigation
Labels
area:commentsIssues with how Prettier prints commentslang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!
Description
Input:
@font-face {
font-family: "Prettier";
src: local("Prettier"), /* Local */
url("http://prettier.com/font.woff") /* Network*/
}Expected:
@font-face {
font-family: "Prettier";
src: local("Prettier") /* Local */, url("http://prettier.com/font.woff"); /* Network*/
}
Output (the /* Local */) comment is dropped:
@font-face {
font-family: "Prettier";
src: local("Prettier"), url("http://prettier.com/font.woff"); /* Network*/
}
Reacted by Jed Fox and Georgii Dolzhykov
Metadata
Metadata
Assignees
Labels
area:commentsIssues with how Prettier prints commentslang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!
Activity
josephfrazier commentedon Jul 5, 2017
It looks like we need to make attachComments/ensureAllCommentsPrinted work with CSS comments. That way, prettier would throw an error instead of silently dropping comments.
vjeux commentedon Jul 5, 2017
Agreed, that would be much better. Are you interested in working on it?
vjeux commentedon Jul 5, 2017
The issue is that the value and media parsers do not give us comment tokens. The postcss parser makes comment nodes.
I think the best solution is to build a small tokenizer that knows how to extract comments so that we can let prettier attach and print them.
Maybe postcss can even do that?
This would also let us remove the hack we have in place for prettier-ignore in CSS and instead use the generic solution.
josephfrazier commentedon Jul 5, 2017
Hmm, with the following change, we can get the
/* Local */comment in the code sample posted above:It needs more work to actually print it out, though.
vjeux commentedon Jul 6, 2017
I tried that as well but if the comment is right after the
:it doesn't get picked up. I think that my solution would work all the time and solve it for real.TrySound commentedon Aug 8, 2017
My postcss value parser has comment tokens. Not sure about fork.