function extract(when) { when = when || 'auto'; return stream(function (file, cb) { fileIgnored(file, function (err, ignored) { if (err) return cb(err); if (ignored) return cb(null, file); file.jshint = file.jshint || {}; file.jshint.extracted = jshintcli.extract(file.contents.toString('utf8'), when); return cb(null, file); }); }); }
...
Tells JSHint to extract JavaScript from HTML files before linting (see [JSHint CLI flags](http://www.jshint.com/docs/cli/)). Keep
in mind that it doesn't override the file's content after extraction. This is your tool of choice to lint web components
!
```js
gulp.task('lintHTML', function() {
return gulp.src('./src/*.html')
// if flag is not defined default value is 'auto'
.pipe(jshint.extract('auto|always|never'))
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
```
## LICENSE
...
loadReporter = function (reporter) { // we want the function if (typeof reporter === 'function') return reporter; // object reporters if (typeof reporter === 'object' && typeof reporter.reporter === 'function') return reporter.reporter; // load jshint built-in reporters if (typeof reporter === 'string') { try { return exports.loadReporter(require('jshint/src/reporters/' + reporter)); } catch (err) {} } // load full-path or module reporters if (typeof reporter === 'string') { try { return exports.loadReporter(require(reporter)); } catch (err) {} } }
n/a
reporter = function (reporter, reporterCfg) { reporterCfg = reporterCfg || {}; if (reporter === 'fail') { return exports.failReporter(reporterCfg); } var rpt = exports.loadReporter(reporter || 'default'); if (typeof rpt !== 'function') { throw new PluginError('gulp-jshint', 'Invalid reporter'); } // return stream that reports stuff return stream(function (file, cb) { if (file.jshint && !file.jshint.success && !file.jshint.ignored) { // merge the reporter config into this files config var opt = defaults({}, reporterCfg, file.jshint.opt); rpt(file.jshint.results, file.jshint.data, opt); } cb(null, file); }); }
...
```js
const jshint = require('gulp-jshint');
const gulp = require('gulp');
gulp.task('lint', function() {
return gulp.src('./lib/*.js')
.pipe(jshint())
.pipe(jshint.reporter('YOUR_REPORTER_HERE'));
});
```
## Options
Plugin options:
...