Skip to main content

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.

选项

¥Options

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: ["/regex/", /regex/, "string"]

鉴于:

¥Given:

["/^my-/", "custom"]

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
my-property: 10px;
}
a {
my-other-property: 10px;
}
a {
custom: 10px;
}

ignoreSelectors: ["/regex/", /regex/, "string"]

跳过根据此规则检查给定选择器的属性。

¥Skips checking properties of the given selectors against this rule.

鉴于:

¥Given:

[":root"]

以下模式不被视为问题:

¥The following patterns are not considered problems:

:root {
my-property: blue;
}

ignoreAtRules: ["/regex/", /regex/, "string"]

忽略指定 at 规则中嵌套的属性。

¥Ignores properties nested within specified at-rules.

鉴于:

¥Given:

["supports"]

以下模式不被视为问题:

¥The following patterns are not considered problems:

@supports (display: grid) {
a {
my-property: 1;
}
}

checkPrefixed: true | false(默认:false

¥checkPrefixed: true | false (default: false)

如果是 true,则此规则将检查浏览器前缀的属性。

¥If true, this rule will check vendor-prefixed properties.

true 为例:

¥For example with 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;
}