Giter Site home page Giter Site logo

gulp-sass-lint's Introduction

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()

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


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).

gulp-sass-lint's People

Contributors

snugug avatar danpurdy avatar bgriffith avatar troch avatar ubenzer avatar jelmerdemaat avatar

Watchers

Daniel Beilinson avatar Oliver Buchtala avatar James Cloos avatar Victor Saiz avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.