Require or disallow an empty line before //
-comments.
a {}
/* ← */
// comment /* ↑ */
/** ↑
* This line */
The --fix
option on the command line can automatically fix all of the problems reported by this rule.
This rule only works with SCSS-like single-line comments and ignores:
- comments that are the very first nodes in a file;
- CSS comments (
/* */
); - comments that are on the same line as some non-comment code (inline comments).
string
: "always"|"never"
There must always be an empty line before //
-comments.
The following patterns are considered warnings:
a {}
// comment
The following patterns are not considered warnings:
a {}
// comment
a {} // comment
There must never be an empty line before //
-comments.
The following patterns are considered warnings:
a {}
// comment
The following patterns are not considered warnings:
a {}
// comment
a {} // comment
Reverse the primary option for //
-comments that are nested and the first child of their parent node.
For example, with "always"
:
The following patterns are considered warnings:
a {
// comment
color: pink;
}
The following patterns are not considered warnings:
a {
// comment
color: pink;
}
Reverse the primary option for //
-comments that are inside a block.
For example, with "always"
:
The following patterns are considered warnings:
a {
background: pink;
// comment
color: pink;
}
The following patterns are not considered warnings:
a {
background: pink;
// comment
color: pink;
}
Don't require an empty line before //
-comments that are placed after other //
-comments or CSS comments.
For example, with "always"
:
The following patterns are not considered warnings:
a {
background: pink;
// comment
// comment
color: #eee;
}
a {
background: pink;
/* comment */
// comment
color: #eee;
}
Ignore //
-comments that deliver commands to stylelint, e.g. // stylelint-disable color-no-hex
.
For example, with "always"
:
The following patterns are considered warnings:
a {
background: pink;
// not a stylelint command
color: #eee;
}
The following patterns are not considered warnings:
a {
background: pink;
// stylelint-disable color-no-hex
color: pink;
}
Ignore //
-comments that are inside a block.
For example, the following patterns are not considered warnings:
a {
background: pink;
// comment
color: pink;
}
a {
background: pink;
// comment
color: pink;
}