gruntjs - stylelint-selector-bem-pattern BEM linter 不起作用

标签 gruntjs postcss bem stylelint

在 grunt 文件中

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

最佳答案

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

must use 简洁详细语法:

/** @define campaign-settings */

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

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

关于gruntjs - stylelint-selector-bem-pattern BEM linter 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43254007/

相关文章:

javascript - 使用 grunt 设置等待秒数

html - CSS BEM - SVG 类

gruntjs - 如何将 less-plugin-clean-css 与 grunt-contrib-less 一起使用?

gruntjs - 通配符包括

vue.js - Tailwind CSS : The `focus:border-2` class does not exist, 但 `focus:rotate-2` 确实

css - postcss 在需要包的 css 文件时找不到配置

css - 在 BEM CSS 中标记它的最佳方式

css - 如何使用 BEM CSS 修改 block 的多个元素

express - 带有 contrib-watch 的 grunt-express-server

css - 从常规 CSS 自动生成嵌套 SCSS?