2014-11-14 45 views
1

我正在尝试将grunt项目迁移到gulp项目。其实,在gruntfile我(对jshint任务)是这样的:gulp-jshint包:如何发送参数(没有.jshintrc文件)?

jshint: { options: { trailing:true, evil:false, indent:4, undef:true, unused:true, node:false, browser:false, loopfunc:true, devel:false }, default: { options: { browser:true, globals: { define:true } }, src: [basePath + "js/**/*.js"] } }

所以,当我在写终端“咕噜jshint”它似乎很好地工作。然而,在gulpfile我写了这个:

gulp.task("jshint", function() { return gulp.src(basePath + "js/**/*.js") .pipe(jshint({ "trailing": true,..., "globals": true })) .pipe(jshint.reporter("default")); });

但是,当我在写终端“一饮而尽jshint”,它崩溃。

我的问题是:有没有办法发送带有gulp-jshint节点包的.jshintrc文件的jshint参数? (我已经阅读了npm网站上的文档,但是我没有看到“lookup”选项)

回答

4

globals是一个数组,不是真的假,这是我的例子。查找工作就像你想的那样。

gulp.src(files.backend) 
    .pipe(jshint({ "lookup": false, /* other options */ "globals": ['$']})) 
    .pipe(jshint.reporter(stylish)) 
    .on('error', gutil.log); 
+0

详细说明,globals是false或值的数组。 http://www.jshint.com/docs/ – ngourley 2014-11-14 22:19:04

+0

它的工作原理!谢谢! – 2014-11-16 21:25:56