Skip to content

selector-max-combinators

Reports a selector with more combinators than the max option; a space between two compound selectors counts.

Every combinator ties the rule to one more level of the markup, so deep selectors break when the markup changes and are slow to read and match. A limit keeps selectors shallow.

Reported
.a.b.c, #x #y, a b c d, [p][q], * *, a:hover:focus { color: red }
...
.i {
...
css:
lint:
rules:
selector-max-combinators:
level: warn # off (default), warn, error
options:
max: 2
less:
lint:
rules:
selector-max-combinators:
level: warn # off (default), warn, error
options:
max: 2
scss:
lint:
rules:
selector-max-combinators:
level: warn # off (default), warn, error
options:
max: 2
Option Type Default Description
max int 2 The most combinators a selector may have.

Suppress one line with sudsy-disable-next-line selector-max-combinators in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
stylelint selector-max-combinators partial differs from stylelint on :nth-child(An+B of S) selector lists