最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - gulp-ignore with gulp-jshint - Stack Overflow

programmeradmin0浏览0评论

I want to do a jshint on the files that is not library files like require js

var gulp = require('gulp');

var jshint = require('gulp-jshint');
var ignore = require('gulp-ignore');
gulp.task('jshint', function() {
  gulp.src('./js/src/*.js')
     .pipe(ignore.exclude('require.js'))
     .pipe(jshint())
     .pipe(jshint.reporter('default'));
});

This still reports require js

 C:\Work\neolivz\js\src\require.js: line 12, col 267, Too many errors. (32% scanned).

Any idea?

I want to do a jshint on the files that is not library files like require js

var gulp = require('gulp');

var jshint = require('gulp-jshint');
var ignore = require('gulp-ignore');
gulp.task('jshint', function() {
  gulp.src('./js/src/*.js')
     .pipe(ignore.exclude('require.js'))
     .pipe(jshint())
     .pipe(jshint.reporter('default'));
});

This still reports require js

 C:\Work\neolivz\js\src\require.js: line 12, col 267, Too many errors. (32% scanned).

Any idea?

Share Improve this question edited Aug 4, 2014 at 10:23 Neo asked Aug 4, 2014 at 9:31 NeoNeo 4,7606 gold badges38 silver badges55 bronze badges 4
  • I think you should refer to it ignore.exlude('./path/to/require.js'); if you're using gulp-ignore? – Samuli Hakoniemi Commented Aug 4, 2014 at 9:37
  • 3 Or just gulp.src(['./js/src/*.js', '!**/require.js']). – Chris Commented Aug 4, 2014 at 9:54
  • Sorry, I was using gulp igore. I tried that also. But did not ignore. – Neo Commented Aug 4, 2014 at 10:22
  • I am able to do .src filter, which is I am doing. but I would like to now how to do it with gulp-ignore and what I am doing wrong. – Neo Commented Aug 4, 2014 at 10:24
Add a ment  | 

2 Answers 2

Reset to default 9

You could also create a .jshintignore file that, just like .gitignore, contains files that you want to ignore.

I think you should be able to pass a regex to gulp ignore if using a specific path isn't working:

var gulp = require('gulp');

var jshint = require('gulp-jshint');
var ignore = require('gulp-ignore');
gulp.task('jshint', function() {
  gulp.src('./js/src/*.js')
     .pipe(ignore.exclude(/require\.js/))
     .pipe(jshint())
     .pipe(jshint.reporter('default'));
});
发布评论

评论列表(0)

  1. 暂无评论