Philipp Partosch 46a936d7de added all files to project | 2 years ago | |
---|---|---|
.. | ||
README.md | 2 years ago | |
index.js | 2 years ago |
Require or disallow an empty line before comments.
a {}
/* ← */
/* comment */ /* ↑ */
/** ↑
* This line */
This rule ignores:
//
(when you’re using a custom syntax that supports them)The fix
option can automatically fix all of the problems reported by this rule. We recommend to enable indentation
rule for better autofixing results with this rule.
string
: "always"|"never"
"always"
There must always be an empty line before comments.
The following patterns are considered violations:
a {}
/* comment */
The following patterns are not considered violations:
a {}
/* comment */
a {} /* comment */
"never"
There must never be an empty line before comments.
The following patterns are considered violations:
a {}
/* comment */
The following patterns are not considered violations:
a {}
/* comment */
a {} /* comment */
except: ["first-nested"]
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 violations:
a {
/* comment */
color: pink;
}
The following patterns are not considered violations:
a {
/* comment */
color: pink;
}
ignore: ["after-comment", "stylelint-commands"]
"after-comment"
Ignore comments that follow another comment.
For example, with "always"
:
The following patterns are not considered violations:
a {
background: pink;
/* comment */
/* comment */
color: #eee;
}
a {
background: pink;
/* comment */
/* comment */
color: #eee;
}
"stylelint-commands"
Ignore comments that deliver commands to stylelint, e.g. /* stylelint-disable color-no-hex */
.
For example, with "always"
:
The following patterns are considered violations:
a {
background: pink;
/* not a stylelint command */
color: #eee;
}
The following patterns are not considered violations:
a {
background: pink;
/* stylelint-disable color-no-hex */
color: pink;
}
ignoreComments: ["/regex/", /regex/, "string"]
Ignore comments matching the given regular expressions or strings.
For example, with "always"
and given:
[/^ignore/, "string-ignore"]
The following comments are not considered violations:
:root {
background: pink;
/* ignore this comment because of the regex */
color: pink;
}
:root {
background: pink;
/* string-ignore */
color: pink;
}