Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stylelint-selector-bem-pattern

simonsmith546.7kMIT4.0.1

A stylelint plugin that harnesses the power of postcss-bem-linter

stylelint, stylelint-plugin, css, nesting, linter, bem

readme

stylelint-selector-bem-pattern

NPM version Build Status

A stylelint plugin that incorporates postcss-bem-linter.

To learn more about postcss-bem-linter, please read that module's documentation.

Installation

npm install stylelint-selector-bem-pattern

Usage

Add it to your stylelint config plugins array, then add "plugin/selector-bem-pattern" to your rules, specifying your postcss-bem-linter settings as the primary option.

Even though postcss-bem-linter has the default setting of { preset: 'suit' }, this plugin has no default setting: if you want to use the SUIT preset, you must pass { preset: 'suit' }, and the rule will not work if you do not pass a primary option object.

Like so:

// .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]+$"
    },
    // ...
  }
}

For more examples of postcss-bem-linter configuration possibilities, please read that module's documentation. Keep in mind that if your stylelint config is JSON you will have to use strings to specify your selector patterns (as above).

changelog

Changelog

4.0.1

  • Move eslint-plugin-jest to devDependencies

4.0.0

3.0.1

  • Update postcss-bem-linter to ^4.0.1

3.0.0

  • Update postcss-bem-linter to ^4.0.0
  • Update stylelint to ^15.9.0 - BREAKING CHANGE
    • Drops support for Node 12

2.1.1

  • Bump dependencies to resolve warnings #56

2.1.0

  • Supports implicitUtilities #38

2.0.0

1.1.1

  • Support ignoreCustomProperties.
  • Use root for implicitComponents warning if no node is in the warning.

1.1.0

  • Supports implicitComponents.

1.0.0

  • Namespace rule name.

0.2.3

  • Move PostCSS from devDependencies to dependencies.

0.2.2

  • Remove code for default options that didn't work anyway.

0.2.1

  • Fix option-validating bug that errored when presetOptions were passed.

0.2.0

  • Upgrade to stylelint v3; use stylelint.createPlugin().

0.1.0+

  • Initial experimentation.