4.0.2 • Published 7 years ago

gulp-stylint v4.0.2

Weekly downloads
1,064
License
MIT
Repository
github
Last release
7 years ago

gulp-stylint Build Status

Gulp plugin for stylus stylint linter

Install

$ npm install --save-dev gulp-stylint

Usage

var gulp = require('gulp');
var stylint = require('gulp-stylint');

gulp.task('default', function () {
	return gulp.src('src/*.styl')
		.pipe(stylint())
		.pipe(stylint.reporter());
});

Custom options

var gulp = require('gulp');
var stylint = require('gulp-stylint');

gulp.task('default', function () {
	return gulp.src('src/*.styl')
		.pipe(stylint({config: '.stylintrc'}))
		.pipe(stylint.reporter());
});

Reporters

Standard

Standard reporter is just printing out the report created from stylint (possibly formatted by #reporter).

var gulp = require('gulp');
var stylint = require('gulp-stylint');

gulp.task('default', function () {
	return gulp.src('src/*.styl')
		.pipe(stylint())
		.pipe(stylint.reporter());
});

Reporter options

logger

Type: function
Default: console.log

Default warnings log function, you can use for example gutil.log.

var gulp = require('gulp');
var stylint = require('gulp-stylint');

gulp.task('default', function () {
	return gulp.src('src/*.styl')
		.pipe(stylint())
		.pipe(stylint.reporter({ logger: gutil.log.bind(null, 'gulp-stylint:') }));
});

Fail-reporter

Another reporter you can use is the fail-reporter. You can use it to fail the gulp-process in the case of linting-errors, or optionally warnings.

var gulp = require('gulp');
var stylint = require('gulp-stylint');

gulp.task('default', function () {
	return gulp.src('src/*.styl')
		.pipe(stylint())
		.pipe(stylint.reporter())
		.pipe(stylint.reporter('fail'));
});

Fail-reporter options

failOnWarning

Type: boolean
Default: false If provided, fail the process not only on errors from stylint, but also on warnings.

var gulp = require('gulp');
var stylint = require('gulp-stylint');

gulp.task('default', function () {
	return gulp.src('src/*.styl')
		.pipe(stylint())
		.pipe(stylint.reporter())
		.pipe(stylint.reporter('fail', { failOnWarning: true }));
});

API

stylint(options)

options

type: object

config

Type: string
Default: undefined

Pass in path to custom rules configuration file as a string. If no configuration is passed in, it will use the .stylintrc file in the project root if present. If that file is not present, it will use default rules.

rules

type: object
Default: undefined

Pass in an object with rules for stylint to lint by. This will override all default rules.

reporter

type: string or object
Default: undefined

If using rules, and you want to use a custom reporter, you can pass in either a string with it's name, or an object containing both a string with the name, and options for it.
If you only pass in config, this config can be placed in that file instead.

Example:

gulp.task('default', function () {
  return gulp.src('src/*.styl')
    .pipe(stylint({
      rules: { semicolons: 'always' },
      reporter: {
        reporter: 'stylint-stylish',
        reporterOptions: {
          verbose: true
        }
      }
    }))
    .pipe(stylint.reporter());
}

NOTE: You must install the reporter yourself. E.g. npm i -D stylint-stylish.

License

MIT © Daniel Husar

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

9 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.1.10

10 years ago

1.1.9

10 years ago

1.1.8

10 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago