1. stylelint-selector-bem-pattern
A stylelint plugin that harnesses the power of postcss-bem-linter
stylelint-selector-bem-pattern
Package: stylelint-selector-bem-pattern
Created by: simonsmith
Last modified: Tue, 27 Feb 2024 21:10:58 GMT
Version: 4.0.0
License: MIT
Downloads: 367,827
Repository: https://github.com/simonsmith/stylelint-selector-bem-pattern

Install

npm install stylelint-selector-bem-pattern
yarn add stylelint-selector-bem-pattern

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).

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin