space-after-declaration vs comments
See original GitHub issue@mishanga @kizu, I can really use your advice here.
Take this code as an example:
a {
color: tomato; /* comment */
position: fixed;
/* comment */
top: 0;
left: 0;
&:hover {
color: black; // comment
top: 100%;
}
}
What should be the result after processing this code with settings:
'space-after-declaration': ' '
and'space-after-declaration': '\n'
?
Related issue: #232
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
declaration-colon-space-after - Stylelint
There must always be a single space after the colon if the declaration's value is single-line. The following patterns are considered problems: a...
Read more >Formatting - Coding Style - Read the Docs
Comment lines can be longer than 80 characters if it is not feasible to split them ... Do not add spaces after the...
Read more >PEP 8 – Style Guide for Python Code
Block comments generally apply to some (or all) code that follows them, and are indented to the same level as that code. Each...
Read more >VS Code - space before function parentheses - Stack Overflow
In VS Code open File -> Preferences -> Settings; Add to your JSON config: "javascript.format.insertSpaceBeforeFunctionParenthesis": true.
Read more >False positive of declaration-colon-space-after for single line ...
There must always be a single space after the colon if the declaration's value is single-line. Yes. But I'm in clamp currently: I...
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
I’d say that when the comment is on a line with another declaration, then, from a user’s standpoint, it is a part of a declaration as it is related to it.
The comments themselves, I’d say, should have their own
space-before
andspace-after
, so when there is a block-level comment, it should be still on its own line.The preprocessor-style inline comment is tricky, I’d say that it should prevent the lines to join in all cases. Maybe we could add a preprocessor-specific option for converting such inline comments when there is something that should go after them.
So, as a user, I would expect:
'space-after-declaration': ' '
:'space-after-declaration': '\n'
: just the initial result, as I would expect the inline comments to be treated as the part of declaration.Also, I would expect the following options:
space-[before|after]-[block|inline]-comment
, where theinline
comment is the comment placed on the same line as a declaration (or any other entity), whileblock
comment is a comment that do not have any non-whitespace symbols on the line it starts from.@kizu @mishanga, thank you