npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jeremywalton/stylelint-bem

v0.1.0

Published

A stylelint plugin that validates BEM methodology in CSS.

Readme

stylelint-bem

A stylelint plugin that validates BEM methodology in CSS written with native nesting. See PRODUCT.md for what this plugin is and why, and CHECKS.md for the full list of checks it runs.

Installation

npm install --save-dev @jeremywalton/stylelint-bem

Requires stylelint ^16.0.0 or ^17.0.0 as a peer dependency.

Configuring the linter

The plugin ships five independent rules, one per check, each enabled and configured on its own:

  • stylelint-bem/valid-name
  • stylelint-bem/no-orphaned-element
  • stylelint-bem/no-orphaned-modifier
  • stylelint-bem/no-double-nested-element
  • stylelint-bem/require-nesting

Quick start

The fastest way to turn everything on with sensible defaults is to extend the recommended config in your .stylelintrc.json (or equivalent):

{
  "extends": ["stylelint-bem/config/recommended"]
}

This registers the plugin and enables all five rules with their defaults — no separate plugins entry needed. See Presets below.

Manual setup

To configure rules individually, register the plugin yourself and list each rule under rules:

{
  "plugins": ["stylelint-bem"],
  "rules": {
    "stylelint-bem/valid-name": true,
    "stylelint-bem/no-orphaned-element": true,
    "stylelint-bem/no-orphaned-modifier": true,
    "stylelint-bem/no-double-nested-element": true,
    "stylelint-bem/require-nesting": true
  }
}

Any subset of the five rules can be listed. Omit a rule to leave it off entirely. Each rule follows the standard stylelint two-arg shape: a primary option (usually just true), and an optional secondary options object for that rule's settings.

{
  "plugins": ["stylelint-bem"],
  "rules": {
    "stylelint-bem/no-orphaned-element": [true, { "knownBlocks": ["react-select"] }],
    "stylelint-bem/require-nesting": ["weak", { "ignoreSelectors": [".js-*"] }]
  }
}

You can also start from the recommended config and layer overrides on top by extending it and then re-declaring the rules you want to change under rulesextends and rules compose normally in stylelint, with rules taking precedence.

Options

Secondary options shared by all five rules:

| Option | Type | Default | Description | |---|---|---|---| | elementSeparator | string | __ | Separator marking an element | | modifierSeparator | string | -- | Separator marking a modifier | | ignoreSelectors | (string \| RegExp)[] | [] | Selectors to skip entirely. String entries match exactly; RegExp entries use .test(). |

Additional secondary option, stylelint-bem/no-orphaned-element and stylelint-bem/no-orphaned-modifier only:

| Option | Type | Default | Description | |---|---|---|---| | knownBlocks | string[] | [] | Block names always treated as defined, wherever they appear — for third-party/vendor classes (e.g. a component library's own DOM classes) that will never be defined in any project CSS/SCSS file. |

stylelint-bem/require-nesting's primary option is true (equivalent to "strict"), "strict", or "weak" — see CHECKS.md for what weak relaxes.

Only class names that participate in BEM are checked: those using the configured separators, plus a bare block name that a BEM element or modifier in the same file confirms is a block (see CHECKS.md). Genuinely non-BEM selectors — utility classes, globals, third-party overrides — are never flagged. No rule provides autofix.

stylelint-bem/no-orphaned-element and stylelint-bem/no-orphaned-modifier look for a block's definition across the whole project, not just the file being linted — see CHECKS.md for how the project root is determined.

Presets

  • recommended (stylelint-bem/config/recommended) — enables all five rules with their defaults. See Quick start above for how to extend it.