Skip to content

layer-name-pattern

Reports a @layer name that does not match the pattern option (a regex). An empty pattern allows everything.

Layer names fix the order of the cascade across a project and its libraries, so a convention keeps them predictable and collisions rare. The rule is a policy: with no pattern it reports nothing.

Reported
...
@keyframes good-frames { from { top: 0 } }
...
@custom-media --good-media (min-width: 1px);
@layer badLayer, good-layer;
...
@container good-box (min-width: 1px) { a { color: red } }
...
css:
lint:
rules:
layer-name-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
less:
lint:
rules:
layer-name-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
scss:
lint:
rules:
layer-name-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
Option Type Default Description
pattern string "" The regex a layer name must match.

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line layer-name-pattern 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 layer-name-pattern full