nesting-selector-no-missing-scoping-root
不允许嵌套选择器缺少作用域根。
¥Disallow missing scoping root for nesting selectors.
& {}
/** ↑
* This nesting selector */
CSS 嵌套选择器 (&
) 表示嵌套 CSS 中的父选择器。当在顶层或某些没有作用域根的 @ 规则中使用时,它们可能会导致意外行为或指示 CSS 结构中的错误。
¥CSS nesting selectors (&
) represent the parent selector in nested CSS. When used at the top level or within certain at-rules without a scoping root, they can cause unexpected behavior or indicate a mistake in the CSS structure.
选项
¥Options
true
{
"nesting-selector-no-missing-scoping-root": true
}
以下模式被视为问题:
¥The following patterns are considered problems:
& {}
@media all {
& {}
}
@scope (&) {}
以下模式不被视为问题:
¥The following patterns are not considered problems:
a {
& {}
}
a {
@media all {
& {}
}
}
a {
@scope (&) {}
}