Skip to main content

no-invalid-position-declaration

禁止无效的位置声明。

¥Disallow invalid position declarations.

color: red;
/** ↑

* This declaration */

声明只能定位在 <declaration-list><declaration-rule-list><block-contents> 产生式中。

¥Declarations can only be positioned within the <declaration-list>, <declaration-rule-list> and <block-contents> productions.

选项

¥Options

true

{
"no-invalid-position-declaration": true
}

以下模式被视为问题:

¥The following patterns are considered problems:

color: red;
--foo: red;
@media all {
color: red;
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a { color: red; }
a { --foo: red; }
@media all {
a {
color: red;
}
}
a {
@media all {
color: red;
}
}

可选的辅助选项

¥Optional secondary options

ignoreAtRules

{ "ignoreAtRules": ["array", "of", "at-rules", "/regex/"] }

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

¥Ignore nesting at-rules within specified at-rules.

鉴于:

¥Given:

{
"no-invalid-position-declaration": [
true,
{ "ignoreAtRules": ["--foo", "/^--bar-/"] }
]
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

@--foo {
@media all {
color: red;
}
}
@--bar-baz qux {
@layer foo {
color: red;
}
}