comment-empty-line-before
要求或禁止注释前有空行。
¥Require or disallow an empty line before comments.
a {}
/* ← */
/* comment */ /* ↑ */
/** ↑
* This line */
该规则忽略了:
¥This rule ignores:
-
注释是源中的第一个节点
¥comments that are the very first node in the source
-
共享行注释
¥shared-line comments
-
带
//
的单行注释(当你使用支持它们的自定义语法时)¥single-line comments with
//
(when you're using a custom syntax that supports them) -
选择器和值列表中的注释
¥comments within selector and value lists
fix
选项 可以自动修复此规则报告的所有问题。
¥The fix
option can automatically fix all of the problems reported by this rule.
选项
¥Options
string
:"always"|"never"
"always"
注释之前必须始终有一个空行。
¥There must always be an empty line before comments.
以下模式被视为问题:
¥The following patterns are considered problems:
a {}
/* comment */
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {}
/* comment */
a {} /* comment */
"never"
注释之前绝对不能有空行。
¥There must never be an empty line before comments.
以下模式被视为问题:
¥The following patterns are considered problems:
a {}
/* comment */
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {}
/* comment */
a {} /* comment */
可选的辅助选项
¥Optional secondary options
except: ["first-nested"]
反转嵌套注释及其父节点的第一个子节点的主要选项。
¥Reverse the primary option for comments that are nested and the first child of their parent node.
例如,对于 "always"
:
¥For example, with "always"
:
以下模式被视为问题:
¥The following patterns are considered problems:
a {
/* comment */
color: pink;
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
/* comment */
color: pink;
}
ignore: ["after-comment", "stylelint-commands"]
"after-comment"
忽略其他注释之后的注释。
¥Ignore comments that follow another comment.
例如,对于 "always"
:
¥For example, with "always"
:
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
background: pink;
/* comment */
/* comment */
color: #eee;
}
a {
background: pink;
/* comment */
/* comment */
color: #eee;
}
"stylelint-commands"
忽略配置注释,例如 /* stylelint-disable color-no-hex */
。
¥Ignore configuration comments, e.g. /* stylelint-disable color-no-hex */
.
例如,对于 "always"
:
¥For example, with "always"
:
以下模式被视为问题:
¥The following patterns are considered problems:
a {
background: pink;
/* not a configuration comment */
color: #eee;
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
background: pink;
/* stylelint-disable color-no-hex */
color: pink;
}
ignoreComments: ["/regex/", /regex/, "string"]
忽略与给定正则表达式或字符串匹配的注释。
¥Ignore comments matching the given regular expressions or strings.
例如,对于 "always"
并给出:
¥For example, with "always"
and given:
["/^ignore/", "string-ignore"]
以下模式不被视为问题:
¥The following patterns are not considered problems:
:root {
background: pink;
/* ignore this comment because of the regex */
color: pink;
}
:root {
background: pink;
/* string-ignore */
color: pink;
}