Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gulp-pug-linter

ilyakam1.2kMIT1.5.0TypeScript support: definitely-typed

Gulp plugin to lint Pug (nee Jade) files

gulp, lint, pug, plugin, jade

readme

gulp-pug-linter

Gulp plugin to lint Jade or Pug files

Status

npm
Codeship Status Coverage Status Dependencies Status Dev Dependencies Status Conventional Commits Known Vulnerabilities

About

Screenshot from Terminal

A no-frills wrapper for the pug-lint CLI tool. It expects the same configuration files as the CLI. This means that whether you prefer configuring the linter with .pug-lintrc, .pug-lint.json, package.json ("pugLintConfig": ...), or even with the legacy .jade files, this plugin is going to work for you right out of the box. In addition, it can be set to fail after it encounters lint errors. That's important if you care about making the Continuous Integration (CI) builds fail after error.

Enterprise Users

This package is available as part of the Tidelift Subscription.

The maintainers of gulp-pug-linter and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Installation

$ npm install gulp-pug-linter --save-dev

Options

  • failAfterError - whether to throw a plugin error after encountering one or more lint errors (default: false)
  • reporter - reporter type, name, module, or function to show lint errors (default: 'default')
  • silenceOnSuccess - whether to bypass the reporter when there are no lint errors (default: false)

Usage

Basic

To lint the template files without breaking the build, pipe the source files into pugLinter({ reporter: 'default' }):

// gulpfile.js
const gulp = require('gulp');
const pugLinter = require('gulp-pug-linter');

gulp.task('lint:template', () => (
  gulp
    .src('./**/*.pug')
    .pipe(pugLinter({ reporter: 'default' }))
));

Note that specifying a reporter key with an invalid value would fall back to the 'default' reporter and display a warning. The screenshot above shows the 'default' reporter in action.

Fail After Error(s)

If you want to break the build after seeing one or more errors, set the { failAfterError: true } option on pugLinter():

// gulpfile.js
const gulp = require('gulp');
const pugLinter = require('gulp-pug-linter');

gulp.task('lint:template', () => (
  gulp
    .src('./**/*.pug')
    .pipe(pugLinter({ failAfterError: true }))
));

Note that without a reporter option, this usage example would break the build without displaying any lint errors. This might be useful in pre-production CI builds or during a git bisect.

External Reporter

If you want to specify an external module as a reporter, you may provide its constructor:

// gulpfile.js
const gulp = require('gulp');
const pugLinter = require('gulp-pug-linter');
const pugLintStylish = require('puglint-stylish');

gulp.task('lint:template', () => (
  gulp
    .src('./**/*.pug')
    .pipe(pugLinter({ reporter: pugLintStylish }))
));

Or you may provide the module's name:

// gulpfile.js
const gulp = require('gulp');
const pugLinter = require('gulp-pug-linter');

gulp.task('lint:template', () => (
  gulp
    .src('./**/*.pug')
    .pipe(pugLinter({ reporter: 'puglint-stylish' }))
));

Custom Reporter

You may define a custom reporter:

// gulpfile.js
const gulp = require('gulp');
const pugLinter = require('gulp-pug-linter');

const myReporter = (errors) => {
  errors.map(error => console.error(error.message));
};

gulp.task('lint:template', () => (
  gulp
    .src('./**/*.pug')
    .pipe(pugLinter({ reporter: myReporter }))
));

changelog

Change Log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

[1.5.0] - 2021-02-06

Added

  • Option to bypass the reporter entirely when there are no errors

Changed

  • Bump eslint*, jest, and vinyl packages

[1.4.0] - 2020-08-18

Changed

  • [BREAKING CHANGE] Require Node.js engine v10 and higher
  • Bump eslint, jest, and through2

[1.3.0] - 2019-08-24

Changed

  • Bump eslint-config-airbnb-base and eslint-plugin-jest packages
  • Update index.js to comply with new ESLint rules via eslint . --fix

[1.2.1] - 2019-07-18

Fixed

  • Bump the Node.js engine to match the ES2017 syntax in this project

Security

  • Bump Lodash to version 4.17.15 to address vulnerability with defaultsDeep

[1.2.0] - 2019-06-30

Changed

  • Replace Dependencies Status badge with Tidelift
  • Manually update all dependencies with npx npm-check-updates -u && npm i

[1.1.0] - 2018-11-07

Changed

  • Bump through2 and estlint-plugin-jest packages

[1.0.0] - 2018-11-04

Added

  • [BREAKING CHANGE] New API with options to specify a reporter and to exit with errors
  • Custom commit message including a body for updating dependencies with Greenkeeper

Changed

  • Rewrote the entire plugin in ES6
  • Replaced chai, istanbul, mocha, proxyquire, and sinon with jest
  • Replaced standard with eslint and its related plugins
  • Replaced the AngularJS Commit guideline with Conventional Commits
  • Replaced npm run watch with npm run test -- --watch
  • Updated contents and code examples in the README and CONTRIBUTING guides

Removed

  • [BREAKING CHANGE] Separate reporter() stream handler including the 'fail' flag

[0.7.0] - 2018-11-04

Added

  • Deprecation warning for version 1.0.0
  • Migration guide to the README

Deprecated

  • Separate reporter() stream handler including the 'fail' flag

[0.6.0] - 2018-08-05

Added

  • Greenkeeper to automatically keep dependencies up to date
  • Ability to automatically run tests on change with npm run watch
  • David devDependencies badge

Changed

  • Require packages using proxyquire instead of mockery in the unit tests
  • Replace deprecated gulp-util with fancy-log, plugin-error, and vinyl
  • Upgraded coveralls, gulp, and mocha due to vulnerabilities found by npm audit

Fixed

  • Update CONTRIBUTING list items to be in order
  • Ignore all *.pug and *.jade files in this repository

[0.5.1] - 2017-06-17

Fixed

  • Update README examples to adhere to StandardJS

[0.5.0] - 2017-06-17

Changed

  • Bump Chai, Sinon, and StandardJS packages

[0.4.1] - 2016-10-15

Fixed

  • Ensure unit tests can run in Windows
  • Ensure Node.js engine is not limited to v5.x

[0.4.0] - 2016-10-09

Added

  • Allow use of custom and external reporters

[0.3.0] - 2016-06-13

Added

  • Allow use of extend in pug-lint

[0.2.1] - 2016-05-03

Fixed

  • Bump version

[0.2.0] - 2016-05-03

Added

  • Contributing guide
  • npm badge

Changed

  • Bump StandardJS package

[0.1.0] - 2016-04-10

Added

  • Initial release