跳至主要內容

declaration-empty-line-before

要求或禁止在宣告前空一行。

a {
--foo: pink;
/* ← */
top: 15px; /* ↑ */
} /* ↑ */
/** ↑
* This line */

此規則僅適用於標準屬性宣告。對自訂屬性宣告,請使用 custom-property-empty-line-before 規則。

fix 選項 可以自動修正此規則報告的所有問題。

選項

字串"always"|"never"

"always"

下列模式會被視為問題

a {
--foo: pink;
top: 5px;
}
a {
bottom: 15px;
top: 5px;
}

下列模式不會被視為問題

a {
--foo: pink;

top: 5px;
}
a {

bottom: 15px;

top: 5px;
}

"never"

下列模式會被視為問題

a {
--foo: pink;

bottom: 15px;
}
a {

bottom: 15px;

top: 5px;
}

下列模式不會被視為問題

a {
--foo: pink;
bottom: 15px;
}
a {
bottom: 15px;
top: 5px;
}

其他選項

except: ["after-comment", "after-declaration", "first-nested"]

"after-comment"

反轉主要選項,適用於在註解後面的宣告。

共用行註解不會觸發此選項。

例如,使用 "always"

下列模式會被視為問題

a {
/* comment */

top: 5px;
}
a {
bottom: 5px; /* comment */
top: 5px;
}

下列模式不會被視為問題

a {
/* comment */
top: 5px;
}

a {
bottom: 5px; /* comment */

top: 5px;
}

"after-declaration"

反轉主要選項,適用於在其他宣告後面的宣告。

共用行註解不會影響此選項。

例如,使用 "always"

下列模式會被視為問題

a {

bottom: 15px;

top: 5px;
}
a {

bottom: 15px; /* comment */

top: 5px;
}

下列模式不會被視為問題

a {

bottom: 15px;
top: 5px;
}
a {

bottom: 15px; /* comment */
top: 5px;
}

"first-nested"

反轉巢狀且為其父節點第一個子節點的宣告的主要選項。

例如,使用 "always"

下列模式會被視為問題

a {

bottom: 15px;

top: 5px;
}

下列模式不會被視為問題

a {
bottom: 15px;

top: 5px;
}

ignore: ["after-comment", "after-declaration", "first-nested", "inside-single-line-block"]

"after-comment"

忽略在註解之後的宣告。

例如,使用 "always"

下列模式不會被視為問題

a {
/* comment */
bottom: 15px;
}

"after-declaration"

忽略在另一個宣告之後的宣告。

例如,使用 "always"

下列模式不會被視為問題

a {

bottom: 15px;
top: 15px;
}
a {

bottom: 15px;

top: 15px;
}
a {

color: orange;
text-decoration: none;

bottom: 15px;
top: 15px;
}

"first-nested"

忽略巢狀且為其父節點第一個子節點的宣告。

例如,使用 "always"

下列模式不會被視為問題

a {
bottom: 15px;

top: 5px;
}

"inside-single-line-block"

忽略在單行區塊內的宣告。

例如,使用 "always"

下列模式不會被視為問題

a { bottom: 15px; top: 5px; }