美文网首页
gulp-jshint总结

gulp-jshint总结

作者: MF_遇见零一 | 来源:发表于2017-07-05 14:55 被阅读0次
    定义声明
    var gulp = require('gulp'),
         jshint = require('gulp-jshint'),
         pkg = requrie('./package'),
         jshintConfig = pkg.jshintConfig; 
    
    jshintConfig.lookup = false;         
    
    gulp.task('_babel',function(){
      return gulp.src('./src/es6/**/*.js')
      .pipe(jshint(jshintConfig))  //如果是引入外部.jshintrc也可以
      .pipe(jshint.reporter('default'))
      .pipe($.babel({
        presets: ['es2015']
      }))
      .pipe(gulp.dest('./src/js'))
    });
    
    常见检查规则
    "jshintConfig": {
        "globals": {
          "$": false,
          "jQuery": false,
          "console": false,
          "alert": false,
          "setInterval": false
        },
        "undef": true,
        "unused": true,
        "asi": false,
        "debug": true,
        "maxerr": 20,
        "newcap": true,
        "onevar": true,
        "eqeqeq": true,
        "camelcase": true,
        "freeze": true,
        "indent": 4,
        "noempty": true
      }
    

    相关文章

      网友评论

          本文标题:gulp-jshint总结

          本文链接:https://www.haomeiwen.com/subject/uwrqhxtx.html