12

I am currently using JSHint with my Gulp workflow, and would like to suppress the semicolon errors when working with JavaScript.

I'm currently using gulp-jshint. How do I enable the "asi" flag within Gulp to make the errors go away?

The type of error I am receiving is:

~/bootstrap-4.0.0-alpha/js/src/modal.js: line 1, col 26, Missing semicolon.

Despite it being valid JavaScript. Any help would be appreciated!

Here's my Gulp File in case it helps:

    // 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');
});
  • 1
    semicolon errors? you should use semicolons when writing JS, don't let the interpreter decide – user2844991 Aug 22 '15 at 20:15
30

In .jshintrc, set the following to tolerate Automatic Semicolon Insertion:

"asi" : true,

As described here, which points you to this example.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.