Gulp无法解析.hintrc文件

时间:2015-07-26 12:48:24

标签: gulp jshint

运行此Gulp任务时

var gulp = require('gulp'),
    util = require('gulp-util'),    // For logging
    print = require('gulp-print'),  // For logging
    jshint = require('gulp-jshint');

gulp.task('analyse', function () {
    log('Analyzing source with JSHint')
    gulp.src(paths.jsContent)
        .pipe(print())
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish', { verbose: true }))
        .pipe(jshint.reporter('fail'));
});

我得到了这个输出:

  

[14:43:26]开始'分析'......   [14:43:26]用JSHint分析源代码   [14:43:26] 32 ms后完成'分析'   [gulp] Scripts \ main.js
  错误:无法解析配置文件:C:\ MyProject \ src \ MyProject.jshintrc
  错误:SyntaxError:意外的令牌

我使用的Gulp文件来自https://raw.githubusercontent.com/johnpapa/pluralsight-gulp/master/.jshintrc,看起来像是:

{
    "bitwise": true,
    "camelcase": true,
    "curly": true,
    "eqeqeq": true,
    "es3": false,
    "forin": true,
    "freeze": true,
    "immed": true,
    "indent": 4,
    "latedef": "nofunc",
    "newcap": true,
    "noarg": true,
    "noempty": true,
    "nonbsp": true,
    "nonew": true,
    "plusplus": false,
    "quotmark": "single",
    "undef": true,
    "unused": false,
    "strict": false,
    "maxparams": 10,
    "maxdepth": 5,
    "maxstatements": 40,
    "maxcomplexity": 8,
    "maxlen": 120,

    "asi": false,
    "boss": false,
    "debug": false,
    "eqnull": true,
    "esnext": false,
    "evil": false,
    "expr": false,
    "funcscope": false,
    "globalstrict": false,
    "iterator": false,
    "lastsemic": false,
    "laxbreak": false,
    "laxcomma": false,
    "loopfunc": true,
    "maxerr": 50,
    "moz": false,
    "multistr": false,
    "notypeof": false,
    "proto": false,
    "scripturl": false,
    "shadow": false,
    "sub": true,
    "supernew": false,
    "validthis": false,
    "noyield": false,

    "browser": true,
    "node": true,

    "globals": {
        "angular": false
    }
}

这可以解决吗?

1 个答案:

答案 0 :(得分:1)

只需将您的.jshintrc文件替换为John的回购中的原件,您就可以了。