npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-gjslint

v0.1.5

Published

Gulp task for running gjslint, the Google Closure linter.

Downloads

211

Readme

gulp-gjslint

NPM version Build Status Code Climate Test Coverage

Lint Javascript using Google's Javascript linter

Install

$ npm install --save-dev gulp-gjslint

Usage

// See also: Gulpfile.example.js

var gulp = require('gulp'),
    gjslint = require('gulp-gjslint');

// Lint files and output results to the console
gulp.task('default', function() {
    return gulp.src('some/files/**/*.js')
        .pipe(gjslint())
        .pipe(gjslint.reporter('console'));
});

// Lint files, output to console and exit if
// an error is raised (useful for CI servers).
gulp.task('default', function() {
    return gulp.src('some/files/**/*.js')
        .pipe(gjslint())
        .pipe(gjslint.reporter('console'), {fail: true})
});

// Pass options to the linter
// See https://github.com/jmendiara/node-closure-linter-wrapper
var lintOptions = {flags: ['--nojsdoc', '--max_line_length 120']};
gulp.task('default', function() {
    return gulp.src('some/files/**/*.js')
        .pipe(gjslint(lintOptions))
        .pipe(gjslint.reporter('console'));
});

API

Options can be passed to the gulp-gjslint task, which will be passed directly to the gjslint library.

See the library documentation for details on what can be specified.

Note: The reporter option is disabled. Use the additional reporter tasks as shown in the examples above.

gjslint(options)

Run gjslint on each file.

Writes gjslint object to each Vinyl object, e.g.

{
    success: false,
    results: {
        errors: [
            {
                line: 1,
                code: 2
                description: 'Missing space before "{"'
            }
        ],
        total: 1,
        newErrors: 1,
        filesCount: 1,
        filesOK: 0
    }
}

gjslint.reporter(name, options)

Write reporter on each file that was processed by gjslint.

Reporter: Console

Output results to the console.

Example usage
gulp.task('lint', function() {
    var gjslint = require('gulp-gjslint'),
        lintOptions = {},
        reporterOptions = {};

    return gulp.src('./**/*.js')
        .pipe(gjslint(lintOptions))
        .pipe(gjslint.reporter('console', reporterOptions));
Default options:
{
    fail: false // If true, emits an error on failure. Useful for CI servers.
                // Note: This will cause the task to fail after the first
                // linting error.
}

Reporter: Fail

Emits an error on when processing a failed file.

Intended for use with a CI server in conjunction with another style of reporter.

Example usage
gulp.task('lint', function() {
    var gjslint = require('gulp-gjslint');

    return gulp.src('./**/*.js')
        .pipe(gjslint())
        .pipe(gjslint.reporter('console'))
        .pipe(gjslint.reporter('fail'));
});

Reporter: Jshint Adapter

Experimental adapter for using Jshint reporters. Only tested with jshint-stylish.

Format for usage is:

.pipe(gjslint.reporter('jshint', reporterFunction, reporterOptions));
Example usage
gulp.task('lint', function() {
    var gjslint = require('gulp-gjslint'),
        stylish = require('jshint-stylish').reporter,
        reporterOptions = {};

    return gulp.src('./**/*.js')
        .pipe(gjslint())
        .pipe(gjslint.reporter('jshint', stylish, reporterOptions));
});

Known issues:

  • Poor handling for when closure-linter-wrapper blows up.
  • Limitation of closure-linter-wrapper where errors are not returned when a file fails with a large number of errors. The task will still output the names of the failed file(s) and the number of errors, but not the errors themselves.

NPM