在gruntfile中
stylelint: {
all: ['app/styles/**/*.scss']
},
.stylelintrc
{
"plugins": [
"stylelint-selector-bem-pattern"
],
"rules": {
"plugin/selector-bem-pattern": {
"componentName": "[A-Z]+",
"componentSelectors": {
"initial": "^\\.{componentName}(?:-[a-z]+)?$",
"combined": "^\\.combined-{componentName}-[a-z]+$"
},
"utilitySelectors": "^\\.util-[a-z]+$"
}
}
}
/Users/jitendravyas/app-test/styles/components/_campaign-settings-integrations.scss
/* @define campaign-settings */
.campaign-settings__integrations {
@include flex;
}
.campaign-settings__integration {
border: 1px solid $color-green;
border-radius: 3px;
color: $color-green;
margin-right: $base-spacing-unit;
@include flex;
.check {
background: $color-green;
color: white;
@include vertical-center;
}
> div {
padding: $half-spacing-unit;
}
}
运行stylelint时没有出现任何错误。 Stylelint正在使用其他规则。
答案 0 :(得分:2)
我认为您错误地定义了组件名称。因此,linter正在跳过文件。
您must use 简明 或 详细语法:
/** @define campaign-settings */
或
/* postcss-bem-linter: define campaign-settings */
目前您似乎使用了无效形式的简明语法,即您的评论以/*
开头,而不是/**
。