# gulp-pug-linter

> Gulp plugin to lint Pug (nee Jade) files

Latest version **1.5.0** (published 2021-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-pug-linter
pnpm add gulp-pug-linter
yarn add gulp-pug-linter
bun add gulp-pug-linter
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2021-02-06 |
| First published | 2016-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/gulp-pug-linter) |
| Module format | CommonJS |
| Node | >=10.x |
| Dependencies | 4 |
| Unpacked size | 737.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Ilya Kaminsky |
| Maintainers | ilyakam |
| Keywords | gulp, lint, pug, plugin, jade |

## Links

- npm: https://www.npmjs.com/package/gulp-pug-linter
- Repository: https://github.com/ilyakam/gulp-pug-linter
- Homepage: https://github.com/ilyakam/gulp-pug-linter#readme
- Issues: https://github.com/ilyakam/gulp-pug-linter/issues
- npm.io page: https://npm.io/package/gulp-pug-linter

## Dependencies (4)

- [pug-lint](https://npm.io/package/pug-lint.md) ^2.6.0
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [fancy-log](https://npm.io/package/fancy-log.md) ^1.3.3
- [plugin-error](https://npm.io/package/plugin-error.md) ^1.0.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2021-02-06
- 0.0.1 (beta) — 2016-04-05
- 1.4.0 — 2020-08-18
- 1.3.0 — 2019-08-24
- 1.2.1 — 2019-07-19
- 1.2.0 — 2019-06-30
- 1.1.0 — 2018-11-08
- 1.0.0 — 2018-11-05
- 0.7.0 — 2018-11-05
- 0.6.0 — 2018-08-06
- 0.5.1 — 2017-06-18
- 0.5.0 — 2017-06-18
- 0.4.1 — 2016-10-16
- 0.4.0 — 2016-10-09
- 0.3.0 — 2016-06-14
- … 2 more at https://npm.io/package/gulp-pug-linter/versions

## README

# gulp-pug-linter

Gulp plugin to lint Jade or Pug files

## Status

[![npm](https://nodei.co/npm/gulp-pug-linter.png)](https://nodei.co/npm/gulp-pug-linter/)  
[![Codeship Status](https://www.codeship.io/projects/ca7127f0-dd21-0133-5b9a-6a36b574da30/status?branch=develop)](https://www.codeship.io/projects/144282)
[![Coverage Status](https://coveralls.io/repos/github/ilyakam/gulp-pug-linter/badge.svg?branch=develop)](https://coveralls.io/github/ilyakam/gulp-pug-linter?branch=develop)
[![Dependencies Status](https://david-dm.org/ilyakam/gulp-pug-linter/status.svg)](https://david-dm.org/ilyakam/gulp-pug-linter)
[![Dev Dependencies Status](https://david-dm.org/ilyakam/gulp-pug-linter/dev-status.svg)](https://david-dm.org/ilyakam/gulp-pug-linter?type=dev)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)
[![Known Vulnerabilities](https://snyk.io/test/github/ilyakam/gulp-pug-linter/badge.svg)](https://snyk.io/test/github/ilyakam/gulp-pug-linter)

## About

![Screenshot from Terminal](readme-about-terminal-screenshot.png "The helpful arrow is included!")

A no-frills wrapper for the [`pug-lint`](https://github.com/pugjs/pug-lint/blob/master/README.md) 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.](https://tidelift.com/subscription/pkg/npm-gulp-pug-linter?utm_source=npm-gulp-pug-linter&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

## Installation

```sh
$ 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' })`:

```js
// 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()`:

```js
// 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:

```js
// 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:

```js
// 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:

```js
// 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 }))
));
```

---
_Source: https://npm.io/package/gulp-pug-linter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
