Skip to content

no-invalid-position-at-import-rule

Reports an @import that comes after a rule that is not @charset, @layer or another @import.

CSS ignores an @import that is not at the top of the stylesheet, so the file it names is never loaded and the styles silently are missing. There is no error in the browser.

To fix, move the @import above every rule, behind @charset and @layer.

Reported
.a { color: red }
@import "a";
css:
lint:
rules:
no-invalid-position-at-import-rule: warn # off, warn (default), error
less:
lint:
rules:
no-invalid-position-at-import-rule: warn # off, warn (default), error
scss:
lint:
rules:
no-invalid-position-at-import-rule: warn # off, warn (default), error

Enabled by the presets: css/stylelint-recommended.

Suppress one line with sudsy-disable-next-line no-invalid-position-at-import-rule 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 no-invalid-position-at-import-rule full