selector-max-attribute
Limit the number of attribute selectors in a selector.
[rel="external"] {}/** ↑ * This type of selector */Use this rule to enforce a convention. For example, limit selectors to 1 attribute, so that selectors stay readable.
Each selector in a selector list is evaluated separately.
This rule supports 2 message arguments: the selector and the configured maximum.
Options
Section titled “Options”number
Section titled “number”Specify a maximum attribute selectors allowed.
Given:
{ "selector-max-attribute": 2}The following patterns are considered problems:
[type="number"][name="quality"][data-attribute="value"] {}[type="number"][name="quality"][disabled] {}The following patterns are not considered problems:
[type="text"] {}[type="text"][name="message"] {}[type="text"][disabled] {}[type="text"][name="message"] { & [disabled] {}}Optional secondary options
Section titled “Optional secondary options”ignoreAttributes
Section titled “ignoreAttributes”{ "ignoreAttributes": ["array", "of", "attributes", "/regex/"] }Given:
{ "selector-max-attribute": [0, { "ignoreAttributes": ["/^data-my-/", "dir"] }]}The following patterns are not considered problems:
[dir] [data-my-attr] {}[dir] [data-my-other-attr] {}