pug-lint

raw JSON →
2.7.0 verified Fri May 01 auth: no javascript abandoned

An unopinionated and configurable linter and style checker for Pug (formerly Jade). Current stable version is 2.7.0, released in 2016 with no further updates. The project is effectively abandoned; no releases since 2016. It provides a CLI, configuration via .pug-lintrc files or package.json, and supports extending configs from npm packages. Key differentiators: highly configurable with many rules, but no longer maintained, so use with caution.

error Error: Cannot find module 'pug-lexer'
cause Missing peer dependency pug-lexer.
fix
Install pug-lexer: npm install pug-lexer
error TypeError: linter.configure is not a function
cause Using default import incorrectly (e.g. import pugLint from 'pug-lint' without calling new).
fix
Use const linter = new pugLint.Linter() or import { Linter } from 'pug-lint' and then new Linter().
error Error: No configuration found for pug-lint
cause Missing .pug-lintrc or package.json pugLintConfig.
fix
Create a .pug-lintrc file or add pugLintConfig to package.json.
deprecated Deprecated preset configuration option in favour of extends.
fix Use extends property in config file instead of preset.
gotcha Configuration file loading can be inconsistent with .pug-lintrc.js needing module.exports.
fix Ensure .pug-lintrc.js exports a config object via module.exports.
gotcha Some rules like 'validateIndentation' may not report correct column numbers in older versions.
fix Update to v2.1.8+ or adjust error parsing.
npm install pug-lint
yarn add pug-lint
pnpm add pug-lint

Shows how to create a linter instance, configure it with rules, and lint a Pug string.

const pugLint = require('pug-lint');
const linter = new pugLint();
linter.configure({
  rules: {
    'disallowIdLiterals': true
  }
});
const results = linter.checkString('div#my-id');
console.log(results);