property-no-unknown
禁止未知属性。
¥Disallow unknown properties.
a { height: 100%; }
/** ↑
* This property */
该规则认为 CSS 规范和浏览器特定属性 中定义的属性是已知的。
¥This rule considers properties defined in the CSS Specifications and browser specific properties to be known.
该规则忽略了:
¥This rule ignores:
-
变量(
$sass
、@less
、--custom-property
)¥variables (
$sass
,@less
,--custom-property
) -
浏览器前缀属性(例如
-moz-align-self
、-webkit-align-self
)¥vendor-prefixed properties (e.g.,
-moz-align-self
,-webkit-align-self
)
使用下面描述的选项 checkPrefixed
打开对浏览器前缀属性的检查。
¥Use option checkPrefixed
described below to turn on checking of vendor-prefixed properties.
message
次要选项 可以接受该规则的参数。
¥The message
secondary option can accept the arguments of this rule.
有关自定义语法,请参阅 languageOptions
部分。
¥For customizing syntax, see the languageOptions
section.
选项
¥Options
true
{
"property-no-unknown": true
}
以下模式被视为问题:
¥The following patterns are considered problems:
a {
colr: blue;
}
a {
my-property: 1;
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
color: green;
}
a {
fill: black;
}
a {
-moz-align-self: center;
}
a {
-webkit-align-self: center;
}
a {
align-self: center;
}
可选的辅助选项
¥Optional secondary options
ignoreProperties
{ "ignoreProperties": ["array", "of", "properties", "/regex/"] }
鉴于:
¥Given:
{
"property-no-unknown": [true, { "ignoreProperties": ["/^my-/", "custom"] }]
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
my-property: 10px;
}
a {
my-other-property: 10px;
}
a {
custom: 10px;
}
ignoreSelectors
{ "ignoreSelectors": ["array", "of", "selectors", "/regex/"] }
跳过根据此规则检查给定选择器的属性。
¥Skips checking properties of the given selectors against this rule.
鉴于:
¥Given:
{
"property-no-unknown": [true, { "ignoreSelectors": [":root"] }]
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
:root {
my-property: blue;
}
ignoreAtRules
{ "ignoreAtRules": ["array", "of", "at-rules", "/regex/"] }
忽略指定 at 规则中嵌套的属性。
¥Ignores properties nested within specified at-rules.
鉴于:
¥Given:
{
"property-no-unknown": [true, { "ignoreAtRules": ["supports"] }]
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
@supports (display: grid) {
a {
my-property: 1;
}
}
checkPrefixed
如果是 true
,则此规则将检查浏览器前缀的属性。默认为 false
。
¥If true
, this rule will check vendor-prefixed properties. Defaults to false
.
鉴于:
¥Given:
{
"property-no-unknown": [true, { "checkPrefixed": true }]
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
-webkit-overflow-scrolling: auto;
}
a {
-moz-box-flex: 0;
}
以下模式被视为问题:
¥The following patterns are considered problems:
a {
-moz-align-self: center;
}
a {
-moz-overflow-scrolling: center;
}