Skip to content

selector-max-class

Reports a selector with more class selectors than the max option; classes inside :not() and the like count.

Every class in a selector is one more thing that must match, so a rule with many classes has high specificity and is hard to override and tied to the markup. A limit keeps selectors short.

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

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