Skip to main content

rule-empty-line-before

要求或禁止规则前有空行。

¥Require or disallow an empty line before rules.

a {}
/* ← */
b {} /* ↑ */
/** ↑

* This line */

此规则忽略源中第一个节点的规则。

¥This rule ignores rules that are the very first node in a source.

fix 选项 可以自动修复此规则报告的所有问题。

¥The fix option can automatically fix all of the problems reported by this rule.

选项

¥Options

"always"

规则之前必须始终有一个空行。

¥There must always be an empty line before rules.

{
"rule-empty-line-before": "always"
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {} b {}
a {}
b {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {}

b {}

"never"

规则之前绝不能有空行。

¥There must never be an empty line before rules.

{
"rule-empty-line-before": "never"
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {}

b {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {} b {}
a {}
b {}

"always-multi-line"

多行规则之前必须始终有一个空行。

¥There must always be an empty line before multi-line rules.

{
"rule-empty-line-before": "always-multi-line"
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {
color: red;
}
b {
color: blue;
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
color: red;
}

b {
color: blue;
}

"never-multi-line"

多行规则之前绝不能有空行。

¥There must never be an empty line before multi-line rules.

{
"rule-empty-line-before": "never-multi-line"
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {
color: red;
}

b {
color: blue;
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
color: red;
}
b {
color: blue;
}

可选的辅助选项

¥Optional secondary options

except

{ "except": ["array", "of", "options"] }

"after-rule"

反转遵循另一个规则的规则的主要选项。

¥Reverse the primary option for rules that follow another rule.

鉴于:

¥Given:

{
"rule-empty-line-before": ["always", { "except": ["after-rule"] }]
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {}

b {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {}
b {}

"after-single-line-comment"

反转单行注释后面的规则的主要选项。

¥Reverse the primary option for rules that follow a single-line comment.

鉴于:

¥Given:

{
"rule-empty-line-before": [
"always",
{ "except": ["after-single-line-comment"] }
]
}

以下模式被视为问题:

¥The following patterns are considered problems:

/* comment */

a {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

/* comment */
a {}

"inside-block-and-after-rule"

反转块内规则的主要选项并遵循另一个规则。

¥Reverse the primary option for rules that are inside a block and follow another rule.

鉴于:

¥Given:

{
"rule-empty-line-before": [
"always",
{ "except": ["inside-block-and-after-rule"] }
]
}

以下模式被视为问题:

¥The following patterns are considered problems:

@media {

a {}

b {}
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

@media {

a {}
b {}
}

"inside-block"

反转块内规则的主要选项。

¥Reverse the primary option for rules that are inside a block.

鉴于:

¥Given:

{
"rule-empty-line-before": ["always", { "except": ["inside-block"] }]
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {
color: red;

& b {
color: blue;
}
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
color: red;
& b {
color: blue;
}
}

"first-nested"

反转嵌套规则及其父节点的第一个子节点的主要选项。

¥Reverse the primary option for rules that are nested and the first child of their parent node.

鉴于:

¥Given:

{
"rule-empty-line-before": ["always", { "except": ["first-nested"] }]
}

以下模式被视为问题:

¥The following patterns are considered problems:

@media {

a {}

b {}
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

@media {
a {}

b {}
}

ignore

{ "ignore": ["array", "of", "options"] }

"after-comment"

忽略注释后面的规则。

¥Ignore rules that follow a comment.

鉴于:

¥Given:

{
"rule-empty-line-before": ["always", { "ignore": ["after-comment"] }]
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

/* comment */
a {}

"first-nested"

忽略嵌套规则及其父节点的第一个子节点。

¥Ignore rules that are nested and the first child of their parent node.

鉴于:

¥Given:

{
"rule-empty-line-before": ["always", { "ignore": ["first-nested"] }]
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

@media {
a {}

b {}
}

"inside-block"

忽略块内的规则。

¥Ignore rules that are inside a block.

鉴于:

¥Given:

{
"rule-empty-line-before": ["always", { "ignore": ["inside-block"] }]
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

@media {
a {}
}
@media {
a {}
b {}
}