简体   繁体   English

使用Gulp抑制JSHint中的分号警告

[英]Suppressing Semicolon Warnings in JSHint with Gulp

I am currently using JSHint with my Gulp workflow, and would like to suppress the semicolon errors when working with JavaScript. 我目前正在使用JSHint和我的Gulp工作流程,并希望在使用JavaScript时抑制分号错误。

I'm currently using gulp-jshint. 我目前正在使用gulp-jshint。 How do I enable the "asi" flag within Gulp to make the errors go away? 如何在Gulp中启用“asi”标志以使错误消失?

The type of error I am receiving is: 我收到的错误类型是:

~/bootstrap-4.0.0-alpha/js/src/modal.js: line 1, col 26, Missing semicolon. 〜/ bootstrap-4.0.0-alpha / js / src / modal.js:第1行,第26列,缺少分号。

Despite it being valid JavaScript. 尽管它是有效的JavaScript。 Any help would be appreciated! 任何帮助,将不胜感激!

Here's my Gulp File in case it helps: 这是我的Gulp文件,如果有帮助:

    // Load Node Modules/Plugins
var gulp = require('gulp');
var concat = require('gulp-concat');
var del = require('del');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint'); 

// Process Styles
gulp.task('styles', function() {
    return gulp.src('scss/*.scss')
        .pipe(sass())
        .pipe(gulp.dest('dist'));
});

// Process Scripts
gulp.task('scripts', function() {
       return gulp.src('js/src/*.js')
           .pipe(jshint())
           .pipe(jshint.reporter('default'))
    .pipe(concat('bootstrap.js'))
           .pipe(uglify())
           .pipe(gulp.dest('dist'));
});

gulp.task('clean', del.bind(null, ['.tmp', 'dist']));

// Watch tasks
gulp.task('watch', function() {
       gulp.watch('scss/*.scss', 'styles');
       gulp.watch('js/src/*.js', 'scripts');
});

gulp.task('build', ['styles', 'scripts', 'watch']);

gulp.task('default', ['clean'], () => {
  gulp.start('build');
});

In .jshintrc , set the following to tolerate Automatic Semicolon Insertion: .jshintrc ,设置以下内容以容忍自动分号插入:

"asi" : true,

As described here , which points you to this example . 如上所述这里 ,这点你这个例子

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

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