Skip to main content

selector-max-universal

Limit the number of universal selectors in a selector.

    * {}
/** ↑
* This universal selector */

Each selector in a selector list is evaluated separately.

note

In versions prior to 17.0.0, this rule would evaluate functional pseudo-classes separately, such as :not() and :is(), and resolve nested selectors (in a nonstandard way) before counting.

Options

number

Specify a maximum universal selectors allowed.

Given:

{
"selector-max-universal": 2
}

The following pattern is considered a problem:

* * * {}

The following patterns are not considered problems:

* {}
* * {}
.foo * {}
*.foo * {}

Optional secondary options

ignoreAfterCombinators

{ "ignoreAfterCombinators": ["array", "of", "combinators"] }

Ignore universal selectors that come after one of the specified combinators.

Given:

{
"selector-max-universal": [2, { "ignoreAfterCombinators": [">", "+"] }]
}

The following pattern is not considered a problem:

* * > * {}