跳到主要內容

selector-no-qualifying-type

禁止依類型限定選取器。

    a.foo {}
/** ↑
* This type selector is qualifying the class */

當類型選取器與其他選取器結合(例如 a.fooa#foo)時,即為「限定」。此規則不規範透過組合器與其他選取器結合的類型選取器(例如 a > .fooa #foo)。

message 次要選項可接受此規則的參數。

選項

true

以下模式被視為問題

a.foo {
margin: 0
}
a#foo {
margin: 0
}
input[type='button'] {
margin: 0
}

以下模式不被視為問題

.foo {
margin: 0
}
#foo {
margin: 0
}
input {
margin: 0
}

選用次要選項

ignore: ["attribute", "class", "id"]

"attribute"

允許依類型限定的屬性選取器。

以下模式不被視為問題

input[type='button'] {
margin: 0
}

"class"

允許依類型限定的類別選取器。

以下模式不被視為問題

a.foo {
margin: 0
}

"id"

允許依類型限定的 ID 選取器。

以下模式不被視為問題

a#foo {
margin: 0
}