本文へスキップ

declaration-empty-line-before

宣言の前に空行を必須または禁止します。

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

このルールは標準のプロパティ宣言にのみ適用されます。カスタムプロパティ宣言には、custom-property-empty-line-beforeルールを使用してください。

fixオプションを使用すると、このルールによって報告されたすべての問題を自動的に修正できます。

オプション

string: "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; }