简体   繁体   English

gulp-jshint软件包:如何发送参数(不带.jshintrc文件)?

[英]gulp-jshint package: How to send parameters (without .jshintrc file)?

I'm currently trying to migrate a grunt project to a gulp project. 我目前正在尝试将咕unt的项目迁移到gulp项目。 Actually, in the gruntfile I have (for the jshint task) something like this: 实际上,在gruntfile中,我(对于jshint任务)具有以下内容:

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"] } }

So, when I write "grunt jshint" in the terminal it seems to work fine. 因此,当我在终端中编写“ grunt jshint”时,它似乎可以正常工作。 However, in the gulpfile I wrote this: 但是,在gulpfile中,我这样写:

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

But when I write "gulp jshint" in terminal, it crashes. 但是,当我在终端中写“ gulp jshint”时,它崩溃了。

My question is: Is there a way to send jshint parameters without .jshintrc file with the gulp-jshint node package? 我的问题是:有没有一种方法可以通过gulp-jshint节点包发送不带.jshintrc文件的jshint参数? (I've already read the documentation in the npm site, but I dont undestand the "lookup" option) (我已经阅读了npm网站上的文档,但是我不理解“ lookup”选项)

globals is an array, not true false, here is my example. globals是一个数组,不是true false,这是我的示例。 lookup works just like you were thinking. 查找工作就像您在想的那样。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM