selector-max-type
限制选择器中类型选择器的数量。
¥Limit the number of type selectors in a selector.
a {}
/** ↑
* This type of selector */
此规则在计算类型选择器的数量之前解析嵌套选择器。选择器列表 中的每个选择器都是单独评估的。
¥This rule resolves nested selectors before counting the number of type selectors. Each selector in a selector list is evaluated separately.
:not()
伪类也被单独评估。该规则将参数视为独立选择器,并且结果不计入整个选择器的总数。
¥The :not()
pseudo-class is also evaluated separately. The rule processes the argument as if it were an independent selector, and the result does not count toward the total for the entire selector.
message
次要选项 可以接受该规则的参数。
¥The message
secondary option can accept the arguments of this rule.
选项
¥Options
int
:允许的最大类型选择器。
¥int
: Maximum type selectors allowed.
例如,对于 2
:
¥For example, with 2
:
以下模式被视为问题:
¥The following patterns are considered problems:
div a span {}
div a {
& span {}
}
div a {
& > a {}
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
div {}
div a {}
.foo div a {}
div.foo a {}
/* each selector in a selector list is evaluated separately */
div,
a span {}
/* `span` is inside `:not()`, so it is evaluated separately */
div a .foo:not(span) {}
可选的辅助选项
¥Optional secondary options
ignore: ["child", "compounded", "custom-elements", "descendant", "next-sibling"]
"child"
折扣子类型选择器。
¥Discount child type selectors.
例如,对于 2
:
¥For example, with 2
:
以下模式不被视为问题:
¥The following patterns are not considered problems:
div span > a {}
#bar div span > a {}
"compounded"
折扣复合类型选择器 - 即与其他选择器链接的类型选择器。
¥Discount compounded type selectors -- i.e. type selectors chained with other selectors.
例如,对于 2
:
¥For example, with 2
:
以下模式不被视为问题:
¥The following patterns are not considered problems:
div span a.foo {}
div span a#bar {}
"custom-elements"
折扣定制元素。
¥Discount custom elements.
例如,对于 2
:
¥For example, with 2
:
以下模式不被视为问题:
¥The following pattern is not considered a problem:
div a foo-bar {}
"descendant"
折扣后代类型选择器。
¥Discount descendant type selectors.
例如,对于 2
:
¥For example, with 2
:
以下模式不被视为问题:
¥The following patterns are not considered problems:
.foo div span a {}
#bar div span a {}
"next-sibling"
折扣下一个兄弟类型选择器。
¥Discount next-sibling type selectors.
例如,对于 2
:
¥For example, with 2
:
以下模式不被视为问题:
¥The following patterns are not considered problems:
div a + span {}
#bar + div + span + a + span {}
ignoreTypes: ["/regex/", /regex/, "non-regex"]
鉴于:
¥Given:
["/^my-/", "custom"]
例如,2
。
¥For example, with 2
.
以下模式不被视为问题:
¥The following patterns are not considered problems:
div a custom {}
div a my-type {}
div a my-other-type {}