Skip to main content

selector-class-pattern

指定类选择器的模式。

¥Specify a pattern for class selectors.

    .foo, #bar.baz span, #hoo[disabled] { color: pink; }
/** ↑ ↑

* These class selectors */

该规则忽略非输出的 Less mixin 定义并称为 Less mixin。

¥This rule ignores non-outputting Less mixin definitions and called Less mixins.

转义选择器(例如 .u-size-11\/12\@sm)被解析为转义两次(例如 .u-size-11\\/12\\@sm)。你的正则表达式应该考虑到这一点。

¥Escaped selectors (e.g. .u-size-11\/12\@sm) are parsed as escaped twice (e.g. .u-size-11\\/12\\@sm). Your RegExp should account for that.

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

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

选项

¥Options

regex|string

字符串将被转换为正则表达式,如 new RegExp(yourString) — 因此请务必正确转义。

¥A string will be translated into a RegExp like so new RegExp(yourString) — so be sure to escape properly.

将检查 . 之后的选择器值。无需在你的模式中包含 .

¥The selector value after . will be checked. No need to include . in your pattern.

给定字符串:

¥Given the string:

"foo-[a-z]+"

以下模式被视为问题:

¥The following patterns are considered problems:

.foop {}
.foo-BAR {}
div > #zing + .foo-BAR {}

以下模式不被视为问题:

¥The following patterns are not considered problems:

.foo-bar {}
div > #zing + .foo-bar {}
#foop {}
[foo='bar'] {}

可选的辅助选项

¥Optional secondary options

resolveNestedSelectors: true | false(默认:false

¥resolveNestedSelectors: true | false (default: false)

此选项将使用 & 插值解析嵌套选择器。

¥This option will resolve nested selectors with & interpolation.

例如,true

¥For example, with true.

给定字符串:

¥Given the string:

"^[A-Z]+$"

以下模式被视为问题:

¥The following patterns are considered problems:

.A {
&__B {} /* resolved to ".A__B" */
}

以下模式不被视为问题:

¥The following patterns are not considered problems:

.A {
&B {} /* resolved to ".AB" */
}