bem-validator-loader

0.0.6 • Public • Published

bem-validator-loader

npm version

This is a validator to check that your css complains with BEM naming convention

Installing

Using npm:

$ npm install --save-dev bem-validator-loader

Using yarn

$ yarn add -D bem-validator-loader

Example webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader', 'bem-validator-loader']
      }
    ]
  }
}

Options

  • include (exclude) List of regular expressions of filepaths to validate (skip)
{
  loader: "bem-validator-loader",
  options: {
    exclude: "/node_modules"
  }
}
  • webpackDirectories Callback to calculate list of directories for bem module checking
{
  loader: "bem-validator-loader",
  options: {
    include: [/webpack\/pages/, /webpack\/common/],
    webpackDirectories: fullpath => {
      const dirs = fullpath.split('/')
      const i = dirs.indexOf('webpack')
      return dirs.filter((dir, I) => I > i +1 )
    }
  }
}
  • onError Callback to catch errors. For example to replace all errors with warnings
{
  loader: "bem-validator-loader",
  options: {
    onError: (error, options) => {
      if (options.filename.match(/pages/indes.sass/)) options.this.emitWarning(error)
      else throw new Error(error)
    }
  }
}

BEM (Block Element Modifier) Validator webpack loader

This is a fork of @torleif’s BEM (Block Element Modifier) Validation Service

which is forked from

This is a fork of @iamdustan’s iamdustan’s AST explorer

which is forked from

This is a fork of @fkling’s Esprima AST Explorer

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i bem-validator-loader

    Weekly Downloads

    21

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    12.7 kB

    Total Files

    5

    Last publish

    Collaborators

    • pipocavsobake