Skip to main content

selector-nested-pattern

为规则中嵌套的规则选择器指定模式。

¥Specify a pattern for the selectors of rules nested within rules.

    a {
color: orange;
&:hover { color: pink; } }
/** ↑

* This nested selector */

非标准选择器(例如使用 Sass 或 Less 插值的选择器)和嵌套在 at 规则中的规则选择器将被忽略。

¥Non-standard selectors (e.g. selectors with Sass or Less interpolation) and selectors of rules nested within at-rules are ignored.

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

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

选项

¥Options

string

指定未用 "/" 括起来的正则表达式字符串。

¥Specify a regex string not surrounded with "/".

将完整检查选择器值。如果你想允许使用组合符和逗号,则必须将它们合并到你的模式中。

¥The selector value will be checked in its entirety. If you'd like to allow for combinators and commas, you must incorporate them into your pattern.

鉴于:

¥Given:

{
"selector-nested-pattern": "^&:(?:hover|focus)$"
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {
.bar {}
}
a {
.bar:hover {}
}
a {
&:hover,
&:focus {}
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
&:hover {}
}
a {
&:focus {}
}
a {
&:hover {}
&:focus {}
}

可选的辅助选项

¥Optional secondary options

splitList

将选择器列表拆分为单独的选择器。默认为 false

¥Split selector lists into individual selectors. Defaults to false.

鉴于:

¥Given:

{
"selector-nested-pattern": ["^&:(?:hover|focus)$", { "splitList": true }]
}

以下模式被视为问题:

¥The following patterns are considered problems:

a {
.bar:hover,
&:focus {}
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

a {
&:hover,
&:focus {}
}