Skip to content

selector-id-pattern

Reports an id selector whose name does not match the pattern option (a regex). An empty pattern allows everything.

A naming convention for ids makes them predictable, so you can guess one and search for it. The rule is a policy: with no pattern it reports nothing.

Reported
.good-name, .badName, #bad_id, #good-id { --good-name: 1; --badName: 2 }
...
@keyframes good-frames { from { top: 0 } }
...
css:
lint:
rules:
selector-id-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
less:
lint:
rules:
selector-id-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
scss:
lint:
rules:
selector-id-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
Option Type Default Description
pattern string "" The regex an id name must match.

Enabled by the presets: css/stylelint-standard.

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