Skip to main content

relative-selector-nesting-notation

Specify explicit or implicit nesting notation for relative selectors.

a { & > b {} }
/** ↑
* This notation */

Use this rule to enforce a convention. A nested selector that starts with a combinator, e.g. > b, is relative to the parent selector whether or not it begins with &.

Choose:

  • "explicit" for clarity
  • "implicit" for brevity

The fix option can automatically fix all of the problems reported by this rule.

This rule supports 1 message argument: the configured notation.

Options​

"explicit"​

Relative selectors must always use explicit nesting selector notation.

{
"relative-selector-nesting-notation": "explicit"
}

The following patterns are considered problems:

a {
b {}
}
a {
> b {}
}

The following patterns are not considered problems:

a {
& b {}
}
a {
& > b {}
}

"implicit"​

Relative selectors must always use implicit nesting selector notation.

{
"relative-selector-nesting-notation": "implicit"
}

The following patterns are considered problems:

a {
& b {}
}
a {
& > b {}
}

The following patterns are not considered problems:

a {
b {}
}
a {
> b {}
}
a {
&:hover {}
}