Skip to main content

selector-attribute-name-disallowed-list

Specify a list of disallowed attribute names.

[class~="foo"] {}
/** ↑
* This name */

Use this rule to enforce a convention. For example, disallow:

  • class and id, so that .foo and #foo are used instead
  • /^data-(js|test)/ if your tests own those attributes

This rule supports 1 message argument: the disallowed attribute name.

Options​

Array<string>​

["array", "of", "attribute-names", "/regex/"]

Given:

{
"selector-attribute-name-disallowed-list": ["class", "id", "/^data-/"]
}

The following patterns are considered problems:

[class*="foo"] {}
[id~="bar"] {}
[data-foo*="bar"] {}

The following patterns are not considered problems:

[lang~="en-us"] {}
[target="_blank"] {}
[href$=".bar"] {}