Run JSLint analysis
How is this package different from other JSLint runners?
-
Contains a copy of the latest (2014-07-08) JSLint by Douglas Crockford
-
Compatible with JSHint reporters
-
jslint.report
can emiterror
event:-
Never (default behaviour)
-
After a file has been analysed and errors were found in it (
emitError
) -
After all files have been analysed and errors were found in at least one of them (
emitErrorAtEnd
)
-
$ npm install --save-dev gulp-jslint-simple
var gulp = require('gulp');
var jslint = require('gulp-jslint-simple');
gulp.task('lint', function () {
gulp.src('*.js')
.pipe(jslint.run({
// project-wide JSLint options
node: true,
vars: true
}))
.pipe(jslint.report({
// example of using a JSHint reporter
reporter: require('jshint-stylish').reporter
}));
});
Assuming:
var jslint = require('gulp-jslint-simple');
Creates a transform stream that expects Vinyl File objects in buffer mode (stream and null-contents modes are not supported) as input. The stream passes each incoming file object to the output unchanged. Each incoming object will be analysed using latest JSLint. If analysis fails, a property jslint
will be added to the object. A property jshint
pointing to jslint
will also be added for compatibility with JSHint reporters.
Type: Object
Default: no options
Options to pass through to JSLINT
function. Allows overriding default JSLint flags on a project level (flags can then be overridden again at a file level using /*jslint*/
comments).
Type: Boolean
Default: false
If true, jslint
property is added even when analysis succeeds. Additionally, jslint.data
property is populated with JSLINT.data()
object that contains analysis details.
Creates a transform stream that expects Vinyl File objects as input. The stream passes each incoming file object to the output unchanged. Each incoming object that contains a file that failed JSLint analysis will be reported using options.reporter
.
Type: Object
Default: no options
Control report behaviour.
Type: Function
Default: jslint.report.defaultReporter
Reporter to use to report errors for files that failed JSLint analysis.
Type: Boolean
Default: false
If true, jslint.report
will emit an error
event when an incoming file fails JSLint analysis.
Type: Boolean
Default: false
If true, jslint.report
will emit an error
event after the input stream has ended and at least one file failed analysis.
If neither options.emitError
nor options.emitErrorAtEnd
are set to true
, no error
event will be emitted. jslint.report
stream then acts as a simple pass-through transform stream.
JSHint-reporter-compatible function that prints formatted message for each specified error result. File, line and row specification is printed in a format that is recognized by many editors and tools (clicking the file specification in such tools will open the specified file for editing at the specified location). Example output:
-
Clone git repository
-
npm install
(will install dev dependencies needed by the next step) -
npm start
(will start a file system watcher that will re-lint JavaScript and JSON files + re-run all tests when change is detected) -
Make changes, don't forget to add tests, submit a pull request.
MIT © Pandell Technology