GulpJS: JS Code Style Guide and Analysis

Standard

JS Code Style Guide and Analysis

  • Use this task in order to implement your javascript style guide and detect errors.
  • Highlight all rules in your .jshintrc and .jscsrc file.
  • Gulp will test javascript code from these files in order to enforce rules.

Sample Js Hint File

Sample Js Code Style File

Pre Install:

    npm install --save-dev gulp gulp-load-plugins 

Install:

    npm install --save-dev gulp-load-plugins jshint-stylish gulp-util

Code:

    var gulp = require('gulp');
    var $ = require('gulp-load-plugins')({ lazy: true });

    gulp.task('jsCode', function () {
    return gulp
        .src('test/*.js')
        .pipe($.jscs())
        .pipe($.jshint())
        .pipe($.jshint.reporter('fail'));
    });

Execute:

    gulp jscode
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s