Skip to main content

declaration-property-value-allowed-list

指定声明中允许的属性和值对的列表。

¥Specify a list of allowed property and value pairs within declarations.

a { text-transform: uppercase; }
/** ↑ ↑

* These properties and these values */

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

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

选项

¥Options

object{ "unprefixed-property-name": ["array", "of", "values", "/regex/", /regex/]|"value"|"/regex/"|/regex/ }

如果在对象中找到属性名称,则仅允许列出的属性值。该规则诉说所有不匹配的值。(如果对象中不包含属性名称,则一切正常。)

¥If a property name is found in the object, only the listed property values are allowed. This rule complains about all non-matching values. (If the property name is not included in the object, anything goes.)

如果属性名称被 "/" 包围(例如 "/^animation/"),则它被解释为正则表达式。例如,这可以轻松定位简写:/^animation/ 将匹配 animationanimation-durationanimation-timing-function 等。

¥If a property name is surrounded with "/" (e.g. "/^animation/"), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: /^animation/ will match animation, animation-duration, animation-timing-function, etc.

值也是如此。请记住,正则表达式值与声明的整个值匹配,而不是与声明的特定部分匹配。例如,像 "10px solid rgba( 255 , 0 , 0 , 0.5 )" 这样的值不会匹配 "/^solid/"(注意行边界的开头),但会匹配 "/\\s+solid\\s+/""/\\bsolid\\b/"

¥The same goes for values. Keep in mind that a regular expression value is matched against the entire value of the declaration, not specific parts of it. For example, a value like "10px solid rgba( 255 , 0 , 0 , 0.5 )" will not match "/^solid/" (notice beginning of the line boundary) but will match "/\\s+solid\\s+/" or "/\\bsolid\\b/".

请小心正则表达式匹配,不要意外考虑带引号的字符串值和 url() 参数。例如,"/red/" 将匹配 "1px dotted red""\"red\"""white url(/mysite.com/red.png)" 等值。

¥Be careful with regex matching not to accidentally consider quoted string values and url() arguments. For example, "/red/" will match value such as "1px dotted red" as well as "\"red\"" and "white url(/mysite.com/red.png)".

鉴于:

¥Given:

{
"transform": ["/scale/"],
"whitespace": "nowrap",
"/color/": ["/^green/"]
}

以下模式被视为问题:

¥The following patterns are considered problems:

a { whitespace: pre; }
a { transform: translate(1, 1); }
a { -webkit-transform: translate(1, 1); }
a { color: pink; }
a { background-color: pink; }

以下模式不被视为问题:

¥The following patterns are not considered problems:

a { whitespace: nowrap; }
a { transform: scale(1, 1); }
a { -webkit-transform: scale(1, 1); }
a { color: green; }
a { background-color: green; }