Gulp plugin for jscodesniffer


Gulp plugin for the jscodesniffer project.

From the jscodesniffer docs:

JSCodeSniffer is a node.js application that checks JavaScript code style consistency according to a provided coding style, just like phpcs. One can define a custom coding style by using described below JSON notation or use one of predefined standards.

npm install gulp-jscodesniffer --save-dev

Optional | Default:EmptyString

A string defining a pre-made jscodesniffer coding standard. As of writing this only two pre-made standards exist, Idiomatic or Jquery. You can read more about them at the jscodesniffer repo.

Optional | Default:EmptyObj

Path to a jscodesniffer JSON configuration file. Without a defined standard this can be used on its own as the only source of rules. When used together with a standard your rc rules will take precedent. Here's our example .jscsrc. Note that if you define neither a standard nor a rc then no style checking will occur.

Optional | Default:['default']

An array of reporters used to process jscodesniffer output. There are three supplied reporters, which are detailed below. To use a supplied reporter add its name to the reporters array. You can add your own custom reporter by adding it to the array as a function (have a look at the supplied reporters for help).

Prints out pleasantly formatted information about failures to the console.

Rings your terminal bell if any failures occurred.

By default this Gulp plugin will not fail its task if it encounters style breaches. Add this reporter to emit an error into the stream and fail the task.

var gulp = require('gulp');
var jscs = require('gulp-jscodesniffer');
gulp.task('jscs',function () {
    return gulp.src('src/**/*.js')
            rc: '.jscsrc',
            standard: 'Idiomatic',
            reporters: ['default','beep']

Run the Mocha tests:

npm test

Run this project's gulpfile against its fixtures and .jscsrc.

npm run jscs