2

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

4

1 回答 1

5

我相信您错误地定义了组件名称。因此,linter 正确地跳过了文件。

必须使用 简洁 详细 语法:

/** @define campaign-settings */

或者

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

目前,您似乎使用了无效形式的简洁语法,即您的注释以 开头/*,而不是/**.

于 2017-04-06T13:02:09.463 回答