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

grunt-stylelint

v0.20.1

Published

A Grunt checker for CSS files using Stylelint

Downloads

184,990

Readme

NPM version NPM Downloads

grunt-stylelint

Grunt plugin for running stylelint

Getting started

If this is the first time you're using Grunt, the getting started guide will show you how to get up and running.

Once you have that installed, with a Gruntfile set for your code, you can install the plugin with:

Note that this installs both grunt-stylelint and the stylelint tool itself, which is a peer dependency. If you do not explicitly depend on stylelint in your package.json file and do not have it available, grunt-stylelint will not work. Modern versions of npm will warn you of such unmet peer dependencies.

In your Gruntfile, add the line:

Running and configuring stylelint task

Run this task with the grunt stylelint command.

You can specify the targets and options for the task using the normal Grunt configuration – see Grunt's guide on how to configure tasks in general.

For more explanations of the lint errors stylelint will throw at you please visit http://stylelint.io/.

Usage examples

Example simple config

In this example, running grunt stylelint:all (or grunt stylelint because stylelint is a multi task) will lint the project's CSS and Sass files in the css and sass directories and their subdirectories, using the default stylelint options or the options specified in the .stylelintrc in the root of the project. For an example config see http://stylelint.io/user-guide/example-config/.

// Project configuration.
grunt.initConfig({
  stylelint: {
    all: ['css/**/*.css', 'sass/**/*.scss']
  }
});

Example full config

A full set of config with default options would be:

// Project configuration.
grunt.initConfig( {
  stylelint: {
    options: {
      configFile: '.stylelintrc',
      formatter: 'string',
      ignoreDisables: false,
      failOnError: true,
      outputFile: '',
      reportNeedlessDisables: false,
      fix: false,
      syntax: ''
    },
    src: [
            'src/**/*.{css,less,scss}',
            …,
            '!src/badstyles/*.css'
        ]
    }
}

Options

The options object is passed through to stylelint. Options you may wish to set are:

formatter

Type: function or string Default value: "string" Values: "string"|"verbose"|"json"

In which output format would you like results. If grunt is run with --verbose and this is not explicitly set, it will act as though you passed in "verbose".

ignoreDisables

Type: boolean Default value: false

Whether to ignore inline comments that disable stylelint.

outputFile

Type: string

Output the report to a file.

reportNeedlessDisables

Type: boolean Default value: false

Whether to ignore inline comments that disable stylelint and report which ones did not block a lint warning.

failOnError

Type: boolean Default value: true

Whether to fail if stylelint detects an error.

fix

Type: boolean Default value: false

Automatically fix, where possible, violations reported by rules. If grunt is run with --fix and this is not explicitly set, it will be set to true.