Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gulp-jslint with all npm packages installed. Try it out:

var gulpJslint = require("gulp-jslint")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-jslint v1.0.10

The classic and strict javascript lint-tool for gulp.js

gulp-jslint Build Status View on NPM code climate code coverage

It's JSLint for Gulp.js.

NPM

Supports node >= 0.10.x.

Table of Contents

Installation

Simply install with npm by running npm install gulp-jslint.

Usage

var gulp = require('gulp');
var jslint = require('gulp-jslint');

gulp.task('default', function () {
    return gulp.src(['source.js'])
            .pipe(jslint({ /* this object represents the JSLint directives being passed down */ }))
            .pipe(jslint.reporter( 'my-reporter' ));
});

If you would like to specify a custom jslint edition to use, set the property 'edition' in your directives object. These versions should follow what the package node-jslint expects or this property can be set to a pre-loaded jslint function.

Directives

All directives being passed to the jslint() function are standard JSLint directives (for a list of directives, see the official JSLint docs).

However, to supply a list of global variables for your code, use the directive 'predef' or 'global' like so ('global' is an alias of 'predef' but 'predef' will be prefered since it is the official JSLint standard):

gulp.task('default', function () {
    return gulp.src(['source.js'])
            .pipe(jslint({
                predef: [ 'a_global' ],
                global: [ 'a_global' ]
            }));
});

Please see gulpfile.js for a more extensive sample gulpfile.

Reporters

By default, two reporters are provided by gulp-jslint. The first is the default reporter (appropriately named 'default') and the second report is the popular 'jshint-stylish' (named 'stylish').

To use either of these reporters, provide the name of the reporter followed by whatever arguments they expect to the function jslint.reporter().

For example:

gulp.task('default', function () {
    return gulp.src(['source.js'])
            .pipe(jslint())
            .pipe(jslint.reporter('default', errorsOnly))
            .pipe(jslint.reporter('stylish', options));
});

It's probably a good idea to use something like path.basename() on the file property to avoid lots of garbage in the command-line (i.e. path.basename('/path/to/index.js') === 'index.js').

Custom Reporters

Custom reporters should be either be synchronous or streams. Either way, the reporter will receive a results object and can output its report onto the console/logfile the way it wishes.

The results object will contain the following properties:

  • filename: the absolute path to the file being linted.
  • success: a boolean value representing whether the linting passed.
  • errors: an array of JSLint errors. Each element will contain the properties:
    • name: the string 'JSLintError'.
    • column: the column number of the error.
    • line: the line number of the error.
    • code: a code relating to the error.
    • message: a message describing the error.

Support and Licensing

Copyright (C) 2014-2016 Karim Alibhai. Code is licensed under the MIT license.

Please use the official issues section in GitHub to post issues or feature requests. Stars and helpful comments are much appreciated! :)

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free