【问题标题】:stylelint-selector-bem-pattern BEM linter not workingstylelint-selector-bem-pattern BEM linter 不工作
【发布时间】:2017-09-01 09:57:24
【问题描述】:

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

【问题讨论】:

    标签: gruntjs postcss bem stylelint


    【解决方案1】:

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

    must use要么 简洁 冗长语法:

    /** @define campaign-settings */
    

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

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

    【讨论】:

    • 在您的第一条评论中,您的意思是文件名和组件名应该相同吗?
    • 现在我收到Invalid component name in definition /*/** @define campaign-settings */*/ plugin/selector-bem-pattern 错误
    猜你喜欢
    • 2016-08-21
    • 2017-09-02
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多