Skip to main content

selector-type-no-unknown

禁止未知类型选择器。

¥Disallow unknown type selectors.

    unknown {}
/** ↑

* This type selector */

此规则认为 HTML、SVG 和 MathML 规范中定义的标签是已知的。

¥This rule considers tags defined in the HTML, SVG, and MathML specifications to be known.

message 次要选项 可以接受该规则的参数。

¥The message secondary option can accept the arguments of this rule.

选项

¥Options

true

{
"selector-type-no-unknown": true
}

以下模式被视为问题:

¥The following patterns are considered problems:

unknown {}
tag {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

input {}
ul li {}
li > a {}

可选的辅助选项

¥Optional secondary options

ignore

{ "ignore": ["array", "of", "options"] }

"custom-elements"

允许自定义元素。

¥Allow custom elements.

{
"selector-type-no-unknown": [true, { "ignore": ["custom-elements"] }]
}

以下模式被视为问题:

¥The following patterns are considered problems:

unknown {}
x-Foo {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

x-foo {}

"default-namespace"

如果未知类型选择器属于默认命名空间,则允许它们。

¥Allow unknown type selectors if they belong to the default namespace.

{
"selector-type-no-unknown": [true, { "ignore": ["default-namespace"] }]
}

以下模式被视为问题:

¥The following patterns are considered problems:

namespace|unknown {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

unknown {}

ignoreNamespaces

{ "ignoreNamespaces": ["array", "of", "namespaces", "/regex/"] }

鉴于:

¥Given:

{
"selector-type-no-unknown": [
true,
{ "ignoreNamespaces": ["/^my-/", "custom-namespace"] }
]
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

custom-namespace|unknown {}
my-namespace|unknown {}
my-other-namespace|unknown {}

ignoreTypes

{ "ignoreTypes": ["array", "of", "types", "/regex/"] }

鉴于:

¥Given:

{
"selector-type-no-unknown": [
true,
{ "ignoreTypes": ["/^my-/", "custom-type"] }
]
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

custom-type {}
my-type {}
my-other-type {}