Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-stylelint

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-stylelint

Gulp plugin for running Stylelint results through various reporters.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28K
decreased by-0.92%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-stylelint

NPM version Build Status Code Climate Join the chat at https://gitter.im/olegskl/gulp-stylelint

A Gulp plugin that runs stylelint results through a list of provided reporters.

Installation

npm install gulp-stylelint --save-dev

Quick start

With gulp-stylelint, it's easy to generate CSS lint reports based on stylelint results.

If you already have a .stylelintrc file in your project directory:

import gulp from 'gulp';
import gulpStylelint from 'gulp-stylelint';
import consoleReporter from 'gulp-stylelint-console-reporter';

gulp.task('lint-css', function lintCssTask() {
  return gulp
    .src('src/**/*.css')
    .pipe(gulpStylelint({
      reporters: [
        consoleReporter()
      ]
    }));
});

Note that if you're using ES5, you will have to access the library via the default property due to the way exports are handled in Babel 6:

var gulpStylelint = require('gulp-stylelint').default;

Reporters

Here's the list of currently available reporters:

Options

Below is an example with all available options provided:

import gulp from 'gulp';
import gulpStylelint from 'gulp-stylelint';
import consoleReporter from 'gulp-stylelint-console-reporter';

gulp.task('lint-css', function lintCssTask() {
  return gulp
    .src('src/**/*.css')
    .pipe(gulpStylelint({
      stylelint: {
        extends: 'stylelint-config-suitcss'
      },
      reporters: [
        consoleReporter()
      ],
      debug: true
    }));
});
stylelint [Object]

See stylelint configuration options. When omitted, the configuration is taken from the .stylelintrc file.

reporters [Array] default: []

List of reporters. The order of execution is sequential.

debug [Boolean] default: false

When set to true, the error handler will print stack trace of errors.

Writing reporters

A gulp-stylelint reporter is an asynchronous function that takes the stylelint results array and outputs a report of some kind (logs to console, writes to a file, ...). The resolved result is not used.

Below is an example of a reporter that logs the number processed files after a preconfigured delay.

//
// gulp-stylelint-custom-reporter.js
// --------------------

export default function customReporterInit(options = {}) {

  return function customReporter(results) {
    return new Promise(resolve => {
      setTimeout(function () {
        console.log(`${results.length} files have been processed`);
        resolve();
      }, options.delay);
    })
  };

}

//
// css-lint-task.js
// --------------------

import gulp from 'gulp';
import gulpStylelint from 'gulp-stylelint';
import customReporter from './gulp-stylelint-custom-reporter';

gulp.task('lint-css', function lintCssTask() {
  return gulp
    .src('src/**/*.css')
    .pipe(gulpStylelint({
      reporters: [
        customReporter({delay: 1337})
      ]
    }));
});

License

gulp-stylelint is Copyright (c) 2016 Oleg Sklyanchuk and licensed under the MIT license. See the included LICENSE file for more details.

Keywords

FAQs

Package last updated on 18 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc