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-contrib-csslint

v2.0.0

Published

Lint CSS files

Downloads

31,535

Readme

grunt-contrib-csslint v2.0.0 Build Status: Linux Build Status: Windows

Lint CSS files

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-contrib-csslint --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-contrib-csslint');

Csslint task

Run this task with the grunt csslint command.

Options

Any specified option will be passed through directly to csslint, thus you can specify any option that csslint supports. The csslint API is a bit awkward: For each rule, a value of false ignores the rule, a value of 2 will set it to become an error. Otherwise all rules are considered warnings.

For the current csslint version, these rules are available:

For an explanation of those rules, check the csslint wiki.

Side note: To update this list, run this:

node -e "require('csslint').CSSLint.getRules().forEach(function(x) { console.log(x.id) })"

A few additional options are supported:

csslintrc

Type: string
Default: null

If this filename is specified, options and globals defined therein will be used. Task and target options override the options within the .csslintrc file. It should be a JSON file, but it supports comments:

{
  // unicorns
  "qualified-headings": true,
  "unique-headings": true,
  "known-properties": false
}

formatters

Type: array
Default: null

If the formatters options is specified, the grunt csslint task is able to use the all formatters provided by csslint.

For the current csslint version, the following formatters are included out of the box:

  • text
  • compact
  • lint-xml
  • csslint-xml
  • checkstyle-xml
  • junit-xml

For an explanation of those formatters, check the csslint wiki, section Options/--format.

You are also able to supply your own custom formatter, such as csslint-stylish. Note that you have to provide the complete module, not just the id. See example.

absoluteFilePathsForFormatters

Type: boolean
Default: false

If the absoluteFilePathsForFormatters option is specified and set to true, the file names in the generated reports are absolute.

quiet

Type: boolean
Default: false

Only output errors.

quiet_all

Type: boolean
Default: false

Outputs without errors and warnings.

Usage Examples

csslint: {
  strict: {
    options: {
      import: 2
    },
    src: ['path/to/**/*.css']
  },
  lax: {
    options: {
      import: false
    },
    src: ['path/to/**/*.css']
  }
}

Loading rules from an external file

csslint: {
  options: {
    csslintrc: '.csslintrc'
  },
  strict: {
    options: {
      import: 2
    },
    src: ['path/to/**/*.css']
  },
  lax: {
    options: {
      import: false
    },
    src: ['path/to/**/*.css']
  }
}

Specifiying output formatters

csslint: {
  options: {
    csslintrc: '.csslintrc',
    formatters: [
      {id: 'junit-xml', dest: 'report/csslint_junit.xml'},
      {id: 'csslint-xml', dest: 'report/csslint.xml'}
    ]
  },
  strict: {
    options: {
      import: 2
    },
    src: ['path/to/**/*.css']
  }
}

Providing a custom formatter

csslint: {
  options: {
    csslintrc: '.csslintrc',
    formatters: [
      {id: require('csslint-stylish'), dest: 'report/csslint_stylish.xml'}
    ]
  },
  strict: {
    options: {
      import: 2
    },
    src: ['path/to/**/*.css']
  }
}

Using absolute file paths in the output formatters

csslint: {
  options: {
    absoluteFilePathsForFormatters: true,
    formatters: [
      {id: 'junit-xml', dest: 'report/csslint_junit.xml'},
      {id: 'csslint-xml', dest: 'report/csslint.xml'}
    ]
  }
}

Release History

  • 2016-09-22   v2.0.0   Update (dev)dependecies including to csslint to v1.0.3.
  • 2016-03-04   v1.0.0   Point main to task and remove peerDeps. Updates to docs.
  • 2015-07-18   v0.5.0   Add ability to register custom formatters.
  • 2015-01-18   v0.4.0   The .csslintrc file can now contain comments.
  • 2014-09-07   v0.3.1   Show affected browsers in errors and warnings.
  • 2014-09-07   v0.3.0   CSSLint "warnings" no longer fail build. Updated dependencies.
  • 2013-12-02   v0.2.0   Bump to csslint 0.10.0
  • 2013-04-02   v0.1.2   Allow absolute filepaths in reports.
  • 2013-03-14   v0.1.1   Support formatters. Support .csslintrc.
  • 2013-03-07   v0.1.0   Initial release.

Task submitted by Jörn Zaefferer

This file was generated on Thu Sep 22 2016 02:55:13.