Socket
Socket
Sign inDemoInstall

postcss-bem-linter

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-bem-linter


Version published
Maintainers
1
Created

Changelog

Source

0.2.0 (January 24, 2015)

  • Use postcss 4.0.x API.

Readme

Source

postcss-bem-linter

Build Status

A PostCSS plugin to lint BEM-style CSS, ported from rework-suit-conformance Currently only supports the SUIT CSS methodology.

Installation

npm install postcss-bem-linter

Conformance tests

Default mode:

  • Only allow selectors that begin with a class matching the defined ComponentName.
  • Only allow custom-property names that begin with the defined ComponentName.
  • The :root selector can only contain custom-properties.
  • The :root cannot be combined with other selectors.

Strict mode:

  • All the tests in "default mode".
  • Disallow selectors that contain any classes that do not match the SUIT CSS conventions.
  • Disallow selectors that contain classes of other components.

Use

Defining a component

The plugin will only run against files that explicitly define themselves as a named component, using a /** @define ComponentName */ or /** @define ComponentName; use strict */ comment on the first line of the file.

/** @define MyComponent */

:root {
  --MyComponent-property: value;
}

.MyComponent {}

.MyComponent .other {}

Strict mode:

/** @define MyComponent; use strict */

:root {
  --MyComponent-property: value;
}

.MyComponent {}

.MyComponent-other {}

Testing CSS files

Pass your individual CSS files through the plugin. It will throw errors for conformance failures, which you can log when caught by your build tools.

var postcss = require('postcss');
var bemLinter = require('postcss-bem-linter');

files.forEach(function (file) {
  var css = fs.readFileSync(file, 'utf-8');
  postcss().use(bemLinter).process(css);
});

Development

Install the dependencies.

npm install

Run the tests.

npm test

Watch and automatically re-run the unit tests.

npm start

Keywords

FAQs

Last updated on 24 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc