Skip to content

at-rule-empty-line-before

Reports an at-rule with no empty line before it. The first at-rule of a block, one right after a comment, and a blockless at-rule right after a blockless one of the same name (a run of @import lines) need none. @else is not checked.

Blank lines separate the blocks of a stylesheet, so an @media or @include that follows a declaration or a rule stays visible as its own unit. A run of @import or @use lines is one list and stays together.

Reported
@import "a.css";
@import "b.css";
@import "c.css";
a { color: red; }
b { color: red; }
...
g { x: y }
...
@media (a) { top: 0; }
...
}
@media (a) { top: 0; }
@media (b) { top: 0; }
@font-face { font-family: x; }
...
--b: 2;
...
@media (b) { top: 0; }
}
css:
lint:
rules:
at-rule-empty-line-before: warn # off (default), warn, error
less:
lint:
rules:
at-rule-empty-line-before: warn # off (default), warn, error
scss:
lint:
rules:
at-rule-empty-line-before: warn # off (default), warn, error

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line at-rule-empty-line-before in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
stylelint at-rule-empty-line-before full