Git Product home page Git Product logo

gulp-pug-linter's Introduction

gulp-pug-linter

Gulp plugin to lint Pug (nee Jade) files

Status

npm
Codeship Status Coverage Status Dependency Status Code Style

About

Screenshot from Terminal

A no-frills wrapper for the pug-lint CLI. It expects the same configuration files as does the CLI tool. This means that whether you prefer linting from .pug-lintrc, .pug-lint.json, directly from package.json ("pugLintConfig": ...), or even 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 once it encounters lint errors. That's important if you care about making the Continuous Integration (CI) builds to fail on error.

Installation

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

Usage

To see lint errors without breaking the build, simply pipe the Pug source files into .pugLinter() and then into the handy, built-in reporter pugLinter.reporter(). This is great for watching the *.pug files as you're developing them.

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

gulp.task('lint:template', function () {
  return gulp
    .src('./**/*.pug')
    .pipe(pugLinter())
    .pipe(pugLinter.reporter())
})

To break the build on lint errors, make sure that pugLinter.reporter is set to 'fail', like so:

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

gulp.task('lint:template', function () {
  return gulp
    .src('./**/*.pug')
    .pipe(pugLinter())
    .pipe(pugLinter.reporter('fail'))
})

Specify external modules as reporters using either the module's constructor or the module's name:

// gulpfile.js
var gulp = require('gulp')
var pugLinter = require('gulp-pug-linter')
var myPugLintReporter = require('my-pug-lint-reporter')

gulp.task('lint:template', function () {
  return gulp
    .src('./**/*.pug')
    .pipe(pugLinter())
    .pipe(pugLinter.reporter(myPugLintReporter))
})

- OR -

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

gulp.task('lint:template', function () {
  return gulp
    .src('./**/*.pug')
    .pipe(pugLinter())
    .pipe(pugLinter.reporter('my-pug-lint-reporter'))
})

Specify your own custom reporter:

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

var myReporter = function (errors) {
  if (errors.length) { console.error('It broke!') }
}

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.