# gulp-stylelint

> Gulp plugin for running Stylelint results through various reporters.

Latest version **13.0.0** (published 2020-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-stylelint
pnpm add gulp-stylelint
yarn add gulp-stylelint
bun add gulp-stylelint
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 13.0.0 |
| Published | 2020-01-22 |
| First published | 2015-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.12.0 |
| Dependencies | 6 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 151 |
| Author | Oleg Sklyanchuk |
| Maintainers | olegskl |
| Keywords | gulpplugin, stylelint, postcss, css |

## Links

- npm: https://www.npmjs.com/package/gulp-stylelint
- Repository: https://github.com/olegskl/gulp-stylelint
- Issues: https://github.com/olegskl/gulp-stylelint/issues
- npm.io page: https://npm.io/package/gulp-stylelint

## Dependencies (6)

- [chalk](https://npm.io/package/chalk.md) ^3.0.0
- [through2](https://npm.io/package/through2.md) ^3.0.1
- [fancy-log](https://npm.io/package/fancy-log.md) ^1.3.3
- [source-map](https://npm.io/package/source-map.md) ^0.7.3
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^6.0.0
- [plugin-error](https://npm.io/package/plugin-error.md) ^1.0.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 13.0.0 (latest) — 2020-01-22
- 11.0.0 — 2019-12-10
- 10.0.0 — 2019-10-14
- 9.0.0 — 2019-04-15
- 8.0.0 — 2018-10-24
- 7.0.0 — 2018-03-03
- 6.0.0 — 2018-01-02
- 5.0.0 — 2017-08-31
- 4.0.0 — 2017-07-18
- 3.9.0 — 2017-02-20
- 3.8.0 — 2017-02-08
- 3.7.0 — 2016-12-18
- 3.6.1 — 2016-12-16
- 3.6.0 — 2016-12-11
- 3.5.0 — 2016-11-28
- … 18 more at https://npm.io/package/gulp-stylelint/versions

## README

# gulp-stylelint

[![NPM version](http://img.shields.io/npm/v/gulp-stylelint.svg)](https://www.npmjs.org/package/gulp-stylelint)
[![Build Status](https://travis-ci.org/olegskl/gulp-stylelint.svg?branch=master)](https://travis-ci.org/olegskl/gulp-stylelint)
[![Dependency Status](https://david-dm.org/olegskl/gulp-stylelint.svg)](https://david-dm.org/olegskl/gulp-stylelint)
[![Join the chat at https://gitter.im/olegskl/gulp-stylelint](https://badges.gitter.im/olegskl/gulp-stylelint.svg)](https://gitter.im/olegskl/gulp-stylelint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

A [Gulp](http://gulpjs.com/) plugin that runs [stylelint](https://github.com/stylelint/stylelint) results through a list of reporters.

## Installation

```bash
npm install stylelint gulp-stylelint --save-dev
```

## Quick start

Once you have [configured stylelint](http://stylelint.io/user-guide/configuration/) (e.g. you have a *.stylelintrc* file), start with the following code. You will find additional configuration [options](#options) below.

```js
const gulp = require('gulp');

gulp.task('lint-css', function lintCssTask() {
  const gulpStylelint = require('gulp-stylelint');

  return gulp
    .src('src/**/*.css')
    .pipe(gulpStylelint({
      reporters: [
        {formatter: 'string', console: true}
      ]
    }));
});
```

## Formatters

Below is the list of currently available stylelint formatters. Some of them are bundled with stylelint by default and exposed on `gulpStylelint.formatters` object. Others need to be installed. You can [write a custom formatter](http://stylelint.io/developer-guide/formatters/) to tailor the reporting to your needs.

 - `"string"` (same as `gulpStylelint.formatters.string`) – bundled with stylelint
 - `"verbose"` (same as `gulpStylelint.formatters.verbose`) – bundled with stylelint
 - `"json"` (same as `gulpStylelint.formatters.json`) – bundled with stylelint
 -  [stylelint-checkstyle-formatter](https://github.com/davidtheclark/stylelint-checkstyle-formatter) – requires installation

## Options

gulp-stylelint supports all [stylelint options](http://stylelint.io/user-guide/node-api/#options) except [`files`](http://stylelint.io/user-guide/node-api/#files) and [`formatter`](http://stylelint.io/user-guide/node-api/#formatter) and accepts a custom set of options listed below:

```js
const gulp = require('gulp');

gulp.task('lint-css', function lintCssTask() {
  const gulpStylelint = require('gulp-stylelint');
  const myStylelintFormatter = require('my-stylelint-formatter');

  return gulp
    .src('src/**/*.css')
    .pipe(gulpStylelint({
      failAfterError: true,
      reportOutputDir: 'reports/lint',
      reporters: [
        {formatter: 'verbose', console: true},
        {formatter: 'json', save: 'report.json'},
        {formatter: myStylelintFormatter, save: 'my-custom-report.txt'}
      ],
      debug: true
    }));
});
```

#### `failAfterError`

When set to `true`, the process will end with non-zero error code if any error-level warnings were raised. Defaults to `true`.

#### `reportOutputDir`

Base directory for lint results written to filesystem. Defaults to current working directory.

#### `reporters`

List of reporter configuration objects (see below). Defaults to an empty array.

```js
{
  // stylelint results formatter (required):
  // - pass a function for imported, custom or exposed formatters
  // - pass a string ("string", "verbose", "json") for formatters bundled with stylelint
  formatter: myFormatter,

  // save the formatted result to a file (optional):
  save: 'text-report.txt',

  // log the formatted result to console (optional):
  console: true
}
```

#### `debug`

When set to `true`, the error handler will print an error stack trace. Defaults to `false`.

## Autofix

The `fix: true` option instructs stylelint to try to fix as many issues as possible. The fixes are applied to the gulp stream. The fixed content can be saved to file using `gulp.dest`.

```js
const gulp = require('gulp');

gulp.task('fix-css', function fixCssTask() {
  const gulpStylelint = require('gulp-stylelint');

  return gulp
    .src('src/**/*.css')
    .pipe(gulpStylelint({
      fix: true
    }))
    .pipe(gulp.dest('src'));
});
```

## License

[MIT License](http://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/gulp-stylelint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
