定义声明
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
}
网友评论