Skip to content

selector-max-universal

Limit the number of universal selectors in a selector.

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

Use this rule to enforce a convention. For example, limit component selectors to 0 universal selectors, as a reset is the only common use of *.

Each selector in a selector list is evaluated separately.

This rule supports 2 message arguments: the selector and the configured maximum.

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 * {}
{ "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:

* * > * {}