postcss-bem-linter – BEM linter for PostCSS

postcss-bem-linter is a PostCSS plugin designed to enforce component-oriented naming conventions in CSS stylesheets. It concentrates on selector organisation rather than general CSS syntax validation, helping developers maintain consistent relationships between components, their constituent elements and their modifiers.

The software supports BEM (Block, Element, Modifier) and SUIT CSS conventions. Both approaches encourage developers to organise stylesheets around reusable components, using predictable class names that describe the relationship between an element and its associated component. The linter examines selectors against the chosen convention and identifies names that do not conform to the expected structure.

Developers can also define their own naming conventions using regular expressions or functions that construct matching patterns. Components and utility rules are identified through comments embedded in stylesheets, allowing different naming requirements to be applied to different sections of the source.

This is free and open source software.

Key Features

  • Built-in naming convention presets for BEM and SUIT CSS.
  • Configurable namespace prefixes for component class names.
  • Custom validation patterns for component names and selector sequences.
  • Separate patterns for selectors appearing before and after combinators.
  • Custom regular expressions for utility selectors.
  • Validation of component-specific CSS custom property names.
  • Strict checking of complete selector sequences.
  • Weak checking mode that relaxes restrictions on selectors following combinators.
  • Support for component and utility definitions within stylesheet comments.
  • Support for chained component and state classes through configurable patterns.
  • Reports naming convention violations through the PostCSS warning system.
  • Integration with Stylelint through the stylelint-selector-bem-pattern plugin.
  • Can be combined with other PostCSS analysis plugins in a common processing workflow.

Website: github.com/postcss/postcss-bem-linter
Support:
Developer: Nicolas Gallagher
License: MIT License

postcss-bem-linter is written in JavaScript. Learn JavaScript with our recommended free books and free tutorials.


Related Software

CSS Linter Tools
StylelintCSS linter that helps you avoid errors and enforce conventions
CSSLintCSS code quality tool
SCSS-LintKeep SCSS files clean and readable
CppcheckStatic analysis tool
postcss-bem-linterBEM linter for PostCSS

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted