【问题标题】:gulp-jshint package: How to send parameters (without .jshintrc file)?gulp-jshint 包:如何发送参数(没有 .jshintrc 文件)?
【发布时间】:2014-11-14 19:53:10
【问题描述】:

我目前正在尝试将 grunt 项目迁移到 gulp 项目。实际上,在 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"] } }

所以,当我在终端中写“grunt jshint”时,它似乎工作正常。但是,在 gulpfile 中我写了这个:

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

但是当我在终端中写“gulp jshint”时,它崩溃了。

我的问题是:有没有办法使用 gulp-jshint 节点包发送不带 .jshintrc 文件的 jshint 参数? (我已经阅读了 npm 站点中的文档,但我不理解“查找”选项)

【问题讨论】:

    标签: javascript node.js gulp jshint


    【解决方案1】:

    globals 是一个数组,不是真假,这是我的例子。查找的工作方式与您的想法一样。

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

    【讨论】:

    • 详细地说,全局变量要么是假的,要么是一个值数组。 jshint.com/docs
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2013-12-30
    • 2016-12-14
    • 2016-07-28
    • 2021-04-25
    • 2018-03-01
    • 1970-01-01
    相关资源
    最近更新 更多