declaration-property-value-no-unknown
不允许声明中的属性值未知。
¥Disallow unknown values for properties within declarations.
a { top: unknown; }
/** ↑ ↑
* property and value pairs like these */
此规则认为 CSS 规范中定义的属性值是已知的。你可以使用 propertiesSyntax
和 typesSyntax
辅助选项来扩展语法。
¥This rule considers values for properties defined within the CSS specifications to be known. You can use the propertiesSyntax
and typesSyntax
secondary options to extend the syntax.
你可以过滤 CSSTree 语法参考 以找出属性已知的值语法。
¥You can filter the CSSTree Syntax Reference to find out what value syntax is known for a property.
此规则仅适用于 CSS。你不应该为类似 CSS 的语言(例如 Sass 或 Less)打开它,因为它们有自己的语法。
¥This rule is only appropriate for CSS. You should not turn it on for CSS-like languages, such as Sass or Less, as they have their own syntaxes.
该规则是实验性的,存在一些误报,我们将在次要版本中修补这些漏报。
¥This rule is experimental with some false negatives that we'll patch in minor releases.
它有时与以下内容重叠:
¥It sometimes overlaps with:
如果标记了重复问题,你可以关闭相应的规则。
¥If duplicate problems are flagged, you can turn off the corresponding rule.
选项
¥Options
true
以下模式被视为问题:
¥The following patterns are considered problems:
a { top: red; }
a { top: unknown; }
以下模式不被视为问题:
¥The following patterns are not considered problems:
a { top: 0; }
a { top: var(--foo); }
可选的辅助选项
¥Optional secondary options
ignoreProperties: { "property": ["/regex/", /regex/, "non-regex"]|"/regex/"|/regex/|"non-regex" }
忽略指定的属性和值对。对象中的键表示属性名称。如果对象中的字符串被 "/"
包围,则它被解释为正则表达式。例如,"/.+/"
匹配任何字符串。
¥Ignore the specified property and value pairs. Keys in the object indicate property names. If a string in the object is surrounded with "/"
, it's interpreted as a regular expression. For example, "/.+/"
matches any strings.
鉴于:
¥Given:
{
"top": ["unknown"],
"/^margin-/": "/^--foo/",
"padding": "/.+/",
"/.+/": "--unknown-value"
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a { top: unknown; }
a { margin-top: --foo-bar; }
a { padding: invalid; }
a { width: --unknown-value; }
propertiesSyntax: { property: syntax }
扩展或更改属性语法字典。CSS 值定义语法 用于定义值的语法。如果定义以 |
开头,则将其添加到 现有定义值(如果有)。
¥Extend or alter the properties syntax dictionary. CSS Value Definition Syntax is used to define a value's syntax. If a definition starts with |
it is added to the existing definition value if any.
鉴于:
¥Given:
{ "size": "<length-percentage>" }
以下模式不被视为问题:
¥The following patterns are not considered problems:
a { size: 0; }
a { size: 10px }
typesSyntax: { type: syntax }
扩展或更改类型语法字典。CSS 值定义语法 用于定义值的语法。如果定义以 |
开头,则将其添加到 现有定义值(如果有)。
¥Extend or alter the types syntax dictionary. CSS Value Definition Syntax is used to define a value's syntax. If a definition starts with |
it is added to the existing definition value if any.
类型类似于预设,允许你在其他定义中重用一个定义。因此,在使用此选项时你可能还想使用 propertiesSyntax
选项。
¥Types are something like a preset which allows you to reuse a definition across other definitions. So, you'll likely want to also use the propertiesSyntax
option when using this option.
鉴于:
¥Given:
{
"propertiesSyntax": { "top": "| <--foo()>" },
"typesSyntax": { "--foo()": "--foo( <length-percentage> )" }
}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a { top: --foo(0); }
a { top: --foo(10px); }