npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-sass-lint

v1.4.0

Published

Gulp plugin for Sass Lint

Downloads

82,320

Readme

Gulp Sass Lint npm version

Gulp plugin for Sass Lint.

Install

npm install gulp-sass-lint --save-dev

Usage

gulpfile.js

'use strict';

var gulp = require('gulp'),
    sassLint = require('gulp-sass-lint');

gulp.task('default', function () {
  return gulp.src('sass/**/*.s+(a|c)ss')
    .pipe(sassLint())
    .pipe(sassLint.format())
    .pipe(sassLint.failOnError())
});

API

sassLint(options)

You can pass an object of options to configure gulp-sass-lint to your specific projects needs the options are listed below.

options.options

You can find out more about the specific SassLint options from the SassLint Documentation

{
  options: {
    formatter: 'stylish',
    'merge-default-rules': false
  }
}

By default SassLint includes it's own configuration file, if you provide one it attempts to merge everything except for the files section below. If you pass options directly into the plugin they take precedence. The order can be visualised below with the SassLint config being the base.

options > config file > SassLint default included config

You can disable this behaviour by setting merge-default-rules to false within the options.options object that you pass to gulp-sass-lint or you can include it in your config file options that you can pass into gulp-sass-lint with options.configFile.

More info and examples can be found within the SassLint docs

options.files

Type: Object

Within the files object you can specify a glob pattern as a string or an array of glob pattern for both the include and ignore options. Please note that your include option will currently be ignored as you should be passing the glob patterns / file paths to be linted directly to gulp gulp.src('sass/**/*.s+(a|c)ss'). The ignore option however will still be respected if you'd rather specify them in your config rather than in the gulp.src method.

{
  files: {
    include: '**/*.scss', // This will be ignored by gulp-sass-lint
    ignore: 'test/**/*.scss' // This will still be respected and read
  }
}

options.rules

Type: Object

You can define which rules you would like to use here and set a severity too. For more information see how to configure and also the SassLint rules

{
  rules: {
    'no-ids': 0, // Severity 0 (disabled)
    'no-mergeable-selectors': 1, // Severity 1 (warning)
    'hex-length': [
      2, // Severity 2 (error)
      {
        'style': 'long'
      }
    ]
  }
}

options.configFile

You can pass the path to a custom config file via the configFile option. The path will be relative to where you're running gulp from.

{
  configFile: 'app/config/.my-config.yml'
}

Example

The following highlights all of the above options in use


'use strict';

var gulp = require('gulp'),
    sassLint = require('gulp-sass-lint');

gulp.task('default', function () {
  return gulp.src('sass/**/*.s+(a|c)ss')
    .pipe(sassLint({
      options: {
        formatter: 'stylish',
        'merge-default-rules': false
      },
      files: {ignore: '**/*.scss'},
      rules: {
        'no-ids': 1,
        'no-mergeable-selectors': 0
      },
      configFile: 'config/other/.sass-lint.yml'
    }))
    .pipe(sassLint.format())
    .pipe(sassLint.failOnError())
});

sassLint.format(writable)

Formats the results dependent on your config file or the options you provided to the sassLint task above. The default format is stylish but you can choose any of the others that SassLint provides, see the docs.

You can also choose to output to a file from within the options you provide or your config file. See the output-file docs

gulp.task('lint_sass_jenkins', function () {
    var file = fs.createWriteStream('reports/lint_sass.xml');
    var stream = gulp.src('public/sass/**/*.scss')
        .pipe(sassLint({
            options: {
                configFile: '.sass-lint.yml',
                formatter: 'checkstyle'
            }
        }))
        .pipe(sassLint.format(file));
    stream.on('finish', function() {
        file.end();
    });
    return stream;
});

sassLint.failOnError()

Fails the task and emits a gulp error when all files have been linted if an error has been detected (rules set to severity 2).