1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 02:27:20 -04:00
notes/node_modules/stylelint/lib/rules/selector-max-compound-selectors
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00
..
index.js Initial commit 2017-03-09 13:16:08 -05:00
README.md Initial commit 2017-03-09 13:16:08 -05:00

selector-max-compound-selectors

Limit the number of compound selectors in a selector.

   div .bar[data-val] > a.baz + .boom > #lorem {}
/* ↑   ↑                ↑       ↑       ↑
   |   |                |       |       |
  Lv1 Lv2              Lv3     Lv4     Lv5  -- these are compound selectors */

A compound selector is a chain of one or more simple (tag, class, id, universal, attribute) selectors. If there is more than one compound selector in a complete selector, they will be separated by combinators (e.g. , +, >). One reason why you might want to limit the number of compound selectors is described in the SMACSS book.

This rule resolves nested selectors before calculating the depth of a selector.

:not() is considered one compound selector irrespective to the complexity of the selector inside it. The rule does process that inner selector, but does so separately, independent of the main selector.

Options

int: Maximum compound selectors allowed.

For example, with 3:

The following patterns are considered warnings:

.foo .bar .baz .lorem {}
.foo .baz {
  & > .bar .lorem {}
}

The following patterns are not considered warnings:

div {}
.foo div {}
#foo #bar > #baz {}
.foo + div :not (a b ~ c) {} /* `a b ~ c` is inside :not() and is processed separately */