bemhint Build Status Dependency Status devDependency Status

bemhint – it is an extendable code quality tool for BEM projects.

This module is a core of the tool. It provides the API for external plugins which perform checks of project BEM entities.


$ npm install bemhint


$ bemhint --help

  bemhint [OPTIONS] [ARGS]

  -h, --help : Help
  -c CONFIGPATH, --config=CONFIGPATH : Path to a configuration file (default: .bemhint.js)
  -r REPORTERS, --reporter=REPORTERS : flat, html or/and teamcity (default: flat)

  TARGETS : Paths to BEM entities (required)


Configuration is a JavaScript/JSON file in the following format:

module.exports = {
    // list of the folder names which represent redefinition levels (folders with blocks)
    levels: [

    // paths which will be ignored during the validation
    excludePaths: [

    // list of available plugins (node module names relatively to config file path)
    plugins: {
        // plugin is disabled
        '<plugin_name>': false,

        // plugin is enabled
        '<plugin_name>': true, 

        // plugin is enabled and uses following settigns
        '<plugin_name>': { 
            // settings

            // paths which will be ignored during the validation by this plugin
            excludePaths: [

            // set of the BEM technologies which should be validated by this plugin
            techs: { 
                '*': false,
                'js|deps.js': true,

                // separated settings for `bemhtml.js`
                'bemhtml.js': { 
                    // settings

Note! Plugin settings can have any other fields which needs for plugin (not only special fields excludePaths and techs). Set of the fields is defined by implementation of plugin.

How to create your own plugin

You need to create the JavaScript file in following format:

module.exports = {
     * Default plugin settings (it will be merged with settings from configuration file)
     * @returns {Object}
    configure: function() {
        return {
            // settings

     * Checks which needs the information about all BEM entities of the project
     * @param {Entity[]} entities
     * @param {Config} config
    forEntities: function(entities, config) {

     * Checks of the specific BEM entity
     * @param {Entity} entity
     * @param {Config} config
    forEachEntity: function(entity, config) {

     * Checks of the separate technology of the specific BEM entity
     * @param {Object} tech
     * @param {Entity} entity
     * @param {Config} config
    forEachTech: function(tech, entity, config) {

Note! Your plugin should contain at least one of the functions forEntities, forEachEntity, forEachTech, but configure function is not required.


BEM entity (block, element or modifier).

@returns {Tech[]} - list of technologies which implement this BEM entity

@param {String} – technology name (css, js etc. - part of a file name which goes after the first dot)
@returns {Tech} – technology of BEM entity

@param {Object} - object which contains the information about an error:

  • msg {String} – error message
  • tech {String} – technology name where error was found
  • [value] {String|Object} – error data


Plugin configuration.

@returns {Object} – full configuration of a plugin

@param {String} – technology name
@returns {Object} – configuration of the specific technology

@param {String} – file path
@returns {Boolean}

@param {String} – relative path
@returns {String} – absolute path built relatively from config file location

Plugin examples

If you notice a mistake or want something to supplement the article, you can always write to us at GitHub, or correct an article using