selector-no-qualifying-type
Disallow qualifying a selector by type.
a.foo {}/** ↑ * This type selector is qualifying the class */Use this rule to enforce a convention, as .card works on any element and has a lower specificity than a.card.
A type selector is “qualifying” when it is compounded with (chained to) another selector (e.g. a.foo, a#foo). This rule does not regulate type selectors that are combined with other selectors via a combinator (e.g. a > .foo, a #foo).
This rule resolves nested selectors according the CSS Nesting specification.
This rule supports 2 message arguments: the selector and the qualifying type.
Options
Section titled “Options”{ "selector-no-qualifying-type": true}The following patterns are considered problems:
a.foo { margin: 0}a#foo { margin: 0}input[type='button'] { margin: 0}a:is(#foo, #bar) { margin: 0}a { #foo { margin: 0 }}The following patterns are not considered problems:
.foo { margin: 0}#foo { margin: 0}input { margin: 0}Optional secondary options
Section titled “Optional secondary options”ignore
Section titled “ignore”{ "ignore": ["array", "of", "options"] }"attribute"
Section titled “"attribute"”Allow attribute selectors qualified by type.
{ "selector-no-qualifying-type": [true, { "ignore": ["attribute"] }]}The following patterns are not considered problems:
input[type='button'] { margin: 0}"class"
Section titled “"class"”Allow class selectors qualified by type.
{ "selector-no-qualifying-type": [true, { "ignore": ["class"] }]}The following patterns are not considered problems:
a.foo { margin: 0}Allow ID selectors qualified by type.
{ "selector-no-qualifying-type": [true, { "ignore": ["id"] }]}The following patterns are not considered problems:
a#foo { margin: 0}