Skip to content

efiand/posthtml-bem-linter

Repository files navigation

posthtml-bem-linter npm version

Pure agnostic function and posthtml plugin for linting a bem html. Fork of gulp-html-bemlinter, enriched by returning warnongs count and AST.

Usage

First, install posthtml-bem-linter as a development dependency:

npm i --DE posthtml-bem-linter

Then, add it to your posthtml.config.js:

import { getPosthtmlBemLinter } from "posthtml-bem-linter";

export default {
	plugins: [
		getPosthtmlBemLinter({
			getSourceName: (filename) => filename
		})
	]
};

Or use function lintBem in pure Node:

import { lintBem } from "posthtml-bem-linter";

const { nodes, warningCount } = lintBem({ content, name });