index.js
function lintStream(spec) {
    if (!spec || !spec.jslint) {
        throw new gulpUtil.PluginError(pluginName, 'The file path to jslint is required.');
    }

    var errors = 0;

    function lint(source, callback) {
        var contents = source.contents.toString('utf8');
        var result = context.jslint(contents, spec.options, spec.globals);

        if (result.ok) {
            gulpUtil.log(colors.green(source.path));
        } else {
            gulpUtil.log(colors.red(source.path));

            errors += result.warnings.length;

            result.warnings.forEach(logWarning);
        }

        callback(null, source);
    }

    function map(source, callback) {
        if (context.jslint) {
            lint(source, callback);

            return;
        }

        fs.readFile(spec.jslint, 'utf8', function (err, jslint) {
            if (err) {
                throw new gulpUtil.PluginError(pluginName, err);
            }

            vm.runInNewContext(jslint, context);

            lint(source, callback);
        });
    }

    function onEnd() {
        if (errors && !spec.noFail) {
            var message = errors === 1
                ? 'JSLint found one error.'
                : 'JSLint found ' + errors + ' errors.';

            throw new gulpUtil.PluginError(pluginName, message);
        }
    }

    return eventStream
        .map(map)
        .on('end', onEnd);
}
function lintStream(spec) {
    if (!spec || !spec.jslint) {
        throw new gulpUtil.PluginError(pluginName, 'The file path to jslint is required.');
    }

    var errors = 0;

    function lint(source, callback) {
        var contents = source.contents.toString('utf8');
        var result = context.jslint(contents, spec.options, spec.globals);

        if (result.ok) {
            gulpUtil.log(colors.green(source.path));
        } else {
            gulpUtil.log(colors.red(source.path));

            errors += result.warnings.length;

            result.warnings.forEach(logWarning);
        }

        callback(null, source);
    }

    function map(source, callback) {
        if (context.jslint) {
            lint(source, callback);

            return;
        }

        fs.readFile(spec.jslint, 'utf8', function (err, jslint) {
            if (err) {
                throw new gulpUtil.PluginError(pluginName, err);
            }

            vm.runInNewContext(jslint, context);

            lint(source, callback);
        });
    }

    function onEnd() {
        if (errors && !spec.noFail) {
            var message = errors === 1
                ? 'JSLint found one error.'
                : 'JSLint found ' + errors + ' errors.';

            throw new gulpUtil.PluginError(pluginName, message);
        }
    }

    return eventStream
        .map(map)
        .on('end', onEnd);
}
function lintStream ( spec ) { if ( ! spec || ! spec . jslint ) { throw new gulpUtil . PluginError ( pluginName , 'The file path to jslint is required.' ) ; } var errors = 0 ; function lint ( source , callback ) { var contents = source . contents . toString ( 'utf8' ) ; var result = context . jslint ( contents , spec . options , spec . globals ) ; if ( result . ok ) { gulpUtil . log ( colors . green ( source . path ) ) ; } else { gulpUtil . log ( colors . red ( source . path ) ) ; errors += result . warnings . length ; result . warnings . forEach ( logWarning ) ; } callback ( null , source ) ; } function map ( source , callback ) { if ( context . jslint ) { lint ( source , callback ) ; return ; } fs . readFile ( spec . jslint , 'utf8' , function ( err , jslint ) { if ( err ) { throw new gulpUtil . PluginError ( pluginName , err ) ; } vm . runInNewContext ( jslint , context ) ; lint ( source , callback ) ; } ) ; } function onEnd ( ) { if ( errors && ! spec . noFail ) { var message = errors === 1 ? 'JSLint found one error.' : 'JSLint found ' + errors + ' errors.' ; throw new gulpUtil . PluginError ( pluginName , message ) ; } } return eventStream . map ( map ) . on ( 'end' , onEnd ) ; }
Runs JSLint over each item in the stream.
@param {Object} spec The specification.
@param {String} spec.jslint The file path to jslint.js.
@param {Object} [spec.options] The options to pass to JSLint.
@param {Array} [spec.globals] The list of known global variables to pass to JSLint.
@param {Boolean} [spec.noFail] True to log all warnings without failing.
Runs JSLint over each item in the stream .