selector-max-attribute
限制选择器中属性选择器的数量。
¥Limit the number of attribute selectors in a selector.
[rel="external"] {}
/** ↑
* This type of selector */
此规则在计算属性选择器的数量之前解析嵌套选择器。选择器列表 中的每个选择器都是单独评估的。
¥This rule resolves nested selectors before counting the number of attribute 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 attribute selectors allowed.
例如,对于 2
:
¥For example, with 2
:
以下模式被视为问题:
¥The following patterns are considered problems:
[type="number"][name="quality"][data-attribute="value"] {}
[type="number"][name="quality"][disabled] {}
[type="number"][name="quality"] {
& [data-attribute="value"] {}
}
[type="number"][name="quality"] {
& [disabled] {}
}
[type="number"][name="quality"] {
& > [data-attribute="value"] {}
}
/* `[type="text"][data-attribute="value"][disabled]` is inside `:not()`, so it is evaluated separately */
input:not([type="text"][data-attribute="value"][disabled]) {}
以下模式不被视为问题:
¥The following patterns are not considered problems:
[type="text"] {}
[type="text"][name="message"] {}
[type="text"][disabled] {}
/* each selector in a selector list is evaluated separately */
[type="text"][name="message"],
[type="number"][name="quality"] {}
/* `[disabled]` is inside `:not()`, so it is evaluated separately */
[type="text"][name="message"]:not([disabled]) {}
可选的辅助选项
¥Optional secondary options
ignoreAttributes: ["/regex/", /regex/, "non-regex"]
鉴于:
¥Given:
["/^data-my-/", "dir"]
例如,0
。
¥For example, with 0
.
以下模式不被视为问题:
¥The following patterns are not considered problems:
[dir] [data-my-attr] {}
[dir] [data-my-other-attr] {}