Skip to content

max-nesting-depth

Reports a rule or at-rule nested inside more rules or at-rules than the max option.

Nested rules multiply: three levels of nesting give a selector that is the product of three, with high specificity and tied to the markup. Deep nesting also makes the file hard to read. A limit keeps nesting shallow.

Reported
...
.d { .e { .f { .g { color: red } } } }
...
.i {
color: red; margin: 0;
...
css:
lint:
rules:
max-nesting-depth:
level: warn # off (default), warn, error
options:
max: 3
less:
lint:
rules:
max-nesting-depth:
level: warn # off (default), warn, error
options:
max: 3
scss:
lint:
rules:
max-nesting-depth:
level: warn # off (default), warn, error
options:
max: 3
Option Type Default Description
max int 3 How deep rules may nest.

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