SCSS single-line comments are formatted incorrectly
See original GitHub issueImportant Note: Prettier has nice support for Grid-Template-Areas . See here
The example shows only how to reproduce the issue with single-line comments!
Prettier 1.15.3 Playground link
--parser scss
Input:
// This is SCSS. Prettier moves the area specification up behind the // comment
.grid {
grid-template-areas: //
"header header header" //
"sidebar content content" //
"footer footer footer";
}
Output:
// This is SCSS. Prettier moves the area specification up behind the // comment
.grid {
grid-template-areas: // "header header header"//
"sidebar content content"//
"footer footer footer";
}
Expected behavior:
// This is SCSS. Prettier moves the area specification up behind the // comment
.grid {
grid-template-areas: //
"header header header" //
"sidebar content content" //
"footer footer footer";
}
There are related (closed) Issues for older Versions:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Comments - CSS: Cascading Style Sheets - MDN Web Docs
A CSS comment is used to add explanatory notes to the code or to prevent the browser from interpreting specific parts of the...
Read more >Comments in CSS - CSS-Tricks
Everything enclosed between /* and */ is treated as a comment regardless of how many lines they span, so any other apparent “syntax”...
Read more >Single Line Comments ( // ) in CSS - Tab Atkins Jr.
However, CSS is missing the "line comment" syntax that those languages have, where everything from // to the end of the line is...
Read more >wrong auto comments for scss in vscode - Stack Overflow
If you want to comment using the multi-line comment format, you can instead highlight what it is you want to comment, and perform...
Read more >How to Add Comments in CSS for Yourself or Your Developer
Technically, there is another way to comment-out single lines in CSS in some browsers, by placing a double forward-slash (//) in front of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why this happens? SCSS code like this:
is parsed into AST node like this:
The inline comment is a part of the raw
between
string. It is not parsed or interpreted in any way, i.e., Prettier doesn’t know there is a comment. And when printing it,trim
is called on the string. That’s how the critical newline gets lost. Result is:I’m experiencing the same issues:
It seems like comments are indenting the next line…