stylelint-selector-bem-pattern BEM linter不工作

时间:2017-04-06 11:33:48

标签: gruntjs postcss bem stylelint

在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正在使用其他规则。

1 个答案:

答案 0 :(得分:2)

我认为您错误地定义了组件名称。因此,linter正在跳过文件。

must use 简明 详细语法:

/** @define campaign-settings */

/* postcss-bem-linter: define campaign-settings */

目前您似乎使用了无效形式的简明语法,即您的评论以/*开头,而不是/**