CSSLint : How to config tasks just print error not warning
Asked Answered
P

1

8

I'm new with Grunt - csslint plugin, after I run and cssLint task complete, there are many and many errors and warnings that I can't follow. So how to config task just print out the errors, not warning??

Perl answered 26/11, 2013 at 2:2 Comment(1)
Maybe try the command line: github.com/stubbornella/csslint/wiki/Command-line-interfaceBirr
M
13

If you use grunt-contrib-csslint you can specify the options in a .csslintrc file.

From the grunt-contrib-csslint Readme:

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.

Assuming you have a structure like this:

├── .csslintrc
├── Gruntfile.js
├── css
│   └── foo.css
├── node_modules
└── package.json

.csslintrc

{ "ignore": [ "adjoining-classes", "box-model", "box-sizing", "bulletproof-font-face", "compatible-vendor-prefixes", "display-property-grouping", "duplicate-background-images", "duplicate-properties", "empty-rules", "fallback-colors", "floats", "font-faces", "font-sizes", "gradients", "ids", "import", "import-ie-limit", "important", "known-properties", "non-link-hover", "order-alphabetical", "outline-none", "overqualified-elements", "qualified-headings", "regex-selectors", "rules-count", "selector-max", "selector-max-approaching", "selector-newline", "shorthand", "star-property-hack", "text-indent", "underscore-property-hack", "unique-headings", "universal-selector", "unqualified-attributes", "vendor-prefix", "zero-units" ] }

reference: https://github.com/CSSLint/csslint/wiki/Command-line-interface

Gruntfile

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    csslint: {
      strict: {
        src: ['css/*.css']
      },
      lax: {
        options: {
          csslintrc: '.csslintrc'
        },
        src: ['css/*.css']
      }
    }
  });

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

  grunt.registerTask('default', ['csslint:lax']);
};

Then grunt will report only errors and grunt csslint:strict will report warnings and errors.

Madge answered 26/11, 2013 at 4:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.