具有选择器 Bem 模式的无效组件选择器
我遇到了 Stylelint 插件 stylelint-selector-bem-pattern
的问题。
我的 Stylelint 规则:
{
"extends": [
"stylelint-config-standard-scss"
],
"plugins": [
"stylelint-selector-bem-pattern"
],
"rules": {
"selector-class-pattern": null,
"color-function-notation": "legacy",
"alpha-value-notation": "number",
"plugin/selector-bem-pattern": {
"preset": "bem",
"componentName": "[A-Z]+",
"componentSelectors": {
"initial": "^\\.{componentName}(?:-[a-z]+)?$",
"combined": "^\\.combined-{componentName}-[a-z]+$"
}
}
}
}
我的 SCSS 组件:
// @define TOTO
.toto_test {
color: red;
}
.toto__test {
color: blue;
}
Stylelint 错误:
I get an issue with the plugin stylelint-selector-bem-pattern
of Stylelint.
My Stylelint rules :
{
"extends": [
"stylelint-config-standard-scss"
],
"plugins": [
"stylelint-selector-bem-pattern"
],
"rules": {
"selector-class-pattern": null,
"color-function-notation": "legacy",
"alpha-value-notation": "number",
"plugin/selector-bem-pattern": {
"preset": "bem",
"componentName": "[A-Z]+",
"componentSelectors": {
"initial": "^\\.{componentName}(?:-[a-z]+)?quot;,
"combined": "^\\.combined-{componentName}-[a-z]+quot;
}
}
}
}
My SCSS component :
// @define TOTO
.toto_test {
color: red;
}
.toto__test {
color: blue;
}
Stylelint errors :
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已选择
suit
预设,其 命名约定是:ComponentName
ComponentName--modifierName
ComponentName-descendentName
ComponentName.is-stateOfComponent
如果你希望遵循 SuitCSS 命名约定,您应该编写:
或者,您可以使用 < code>preset 选项来指定
bem
命名约定:您应该删除
componentName
和componentSelectors
属性,因为它们会覆盖“bem”
预设
使用自定义模式。这将允许:
You have chosen the
suit
preset, whose naming conventions are:ComponentName
ComponentName--modifierName
ComponentName-descendentName
ComponentName.is-stateOfComponent
If you wish to follow the SuitCSS naming conventions you should write:
Alternatively, you can use the
preset
option to specify thebem
naming conventions:You should remove the
componentName
andcomponentSelectors
properties as they overwrite the"bem"
preset
with custom patterns.This will allow: