gulp-jscs

Check JavaScript code style with jscs

JSCS is deprecated. Switch to ESLint.
Last updated 3 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-jscs 
SYNC missed versions from official npm registry.

gulp-jscs Build Status

Check JavaScript code style with JSCS

Issues with the output should be reported on the JSCS issue tracker.

Install

$ npm install --save-dev gulp-jscs

Usage

Reporting

const gulp = require('gulp');
const jscs = require('gulp-jscs');

gulp.task('default', () => {
	return gulp.src('src/app.js')
		.pipe(jscs())
		.pipe(jscs.reporter());
});

Fixing

const gulp = require('gulp');
const jscs = require('gulp-jscs');

gulp.task('default', () => {
	return gulp.src('src/app.js')
		.pipe(jscs({fix: true}))
		.pipe(gulp.dest('src'));
});

Reporting & fixing & failing on lint error

const gulp = require('gulp');
const jscs = require('gulp-jscs');

gulp.task('default', () => {
	return gulp.src('src/app.js')
		.pipe(jscs({fix: true}))
		.pipe(jscs.reporter())
		.pipe(jscs.reporter('fail'))
		.pipe(gulp.dest('src'));
});

Results

A jscs object will be attached to the file object.
An example with one error might look like this:

{
	success: false,  // or true if no errors
	errorCount: 1,   // number of errors in the errors array
	errors: [{       // an array of jscs error objects
		filename: 'index.js',  // basename of the file
		rule: 'requireCamelCaseOrUpperCaseIdentifiers',  // the rule which triggered the error
		message: 'All identifiers must be camelCase or UPPER_CASE',  // error message
		line: 32,  // error line number
		column: 7  // error column
	}]
};

API

JSCS config should be placed in a .jscsrc file.

jscs([options])

options

fix

Type: boolean
Default: false

Make JSCS attempt to auto-fix your files.
Be sure to pipe to gulp.dest if you use this option.

configPath

Type: string
Default: JSCS will search for the config file up to your home directory.

Set the path to the JSCS config file.
Only use this option when it can't be found automatically.

jscs.reporter([reporter])

reporter

Type: string
Default: console

See the JSCS reporter docs for supported input.

Can be used multiple times in the same pipeline.

This plugin also ships with some custom reporters:

  • fail - Emits an error at the end of the stream if there are lint errors.
  • failImmediately - Emits an error immediately if there are lint errors.

License

MIT © Sindre Sorhus

Current Tags

  • 4.1.0                                ...           latest (3 years ago)

35 Versions

  • 4.1.0 [deprecated]           ...           3 years ago
  • 4.0.0 [deprecated]           ...           4 years ago
  • 3.0.2 [deprecated]           ...           5 years ago
  • 3.0.1 [deprecated]           ...           5 years ago
  • 3.0.0 [deprecated]           ...           5 years ago
  • 2.0.0 [deprecated]           ...           5 years ago
  • 1.6.0 [deprecated]           ...           5 years ago
  • 1.5.2 [deprecated]           ...           5 years ago
  • 1.5.1 [deprecated]           ...           5 years ago
  • 1.5.0 [deprecated]           ...           5 years ago
  • 1.4.0 [deprecated]           ...           6 years ago
  • 1.3.1 [deprecated]           ...           6 years ago
  • 1.3.0 [deprecated]           ...           6 years ago
  • 1.2.2 [deprecated]           ...           6 years ago
  • 1.2.1 [deprecated]           ...           6 years ago
  • 1.2.0 [deprecated]           ...           6 years ago
  • 1.1.2 [deprecated]           ...           6 years ago
  • 1.1.1 [deprecated]           ...           6 years ago
  • 1.1.0 [deprecated]           ...           6 years ago
  • 1.0.0 [deprecated]           ...           6 years ago
  • 0.6.1 [deprecated]           ...           6 years ago
  • 0.6.0 [deprecated]           ...           6 years ago
  • 0.5.0 [deprecated]           ...           6 years ago
  • 0.4.2 [deprecated]           ...           6 years ago
  • 0.4.1 [deprecated]           ...           6 years ago
  • 0.4.0 [deprecated]           ...           6 years ago
  • 0.3.2 [deprecated]           ...           6 years ago
  • 0.3.1 [deprecated]           ...           6 years ago
  • 0.3.0 [deprecated]           ...           6 years ago
  • 0.2.1 [deprecated]           ...           6 years ago
  • 0.2.0 [deprecated]           ...           6 years ago
  • 0.1.3 [deprecated]           ...           7 years ago
  • 0.1.2 [deprecated]           ...           7 years ago
  • 0.1.1 [deprecated]           ...           7 years ago
  • 0.1.0 [deprecated]           ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 62
This Month 49
Last Day 2
Last Week 121
Last Month 451
Dependencies (4)
Dev Dependencies (5)
Dependents (148)

Copyright 2014 - 2017 © taobao.org |