Skip to content

custom-media-pattern

Reports a @custom-media name, without its --, that does not match the pattern option (a regex). An empty pattern allows everything.

A naming convention for custom media queries keeps the breakpoints of a project predictable. The rule is a policy: with no pattern it reports nothing.

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

Enabled by the presets: css/stylelint-standard.

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