View on GitHub

grunt-lesslint

Lint LESS files with Grunt

Download this project as a .zip file Download this project as a tar.gz file

LESS Lint Grunt plugin Build Status

Lint your LESS files using CSS Lint from Grunt.

This plugin compiles your LESS files, runs the generated CSS through CSS Lint, and outputs the offending LESS line for any CSS Lint errors found.

Installing

npm install grunt-lesslint

Building

Configuring

Add the following to your Gruntfile.coffee:

grunt.initConfig
  lesslint:
    src: ['src/**/*.less']

grunt.loadNpmTasks('grunt-lesslint')

Then run grunt lesslint to lint all the .less files under src/.

By default the plugin uses the less and csslint config settings to configure the LESS parser and the CSS Lint validator.

CSS Lint

You can configure the CSS Lint validator, such as for disabling certain rules, by adding a csslint config value:

csslint:
  'known-properties': false

LESS

You can configure the LESS parser, such as for adding include paths, by adding a less config value:

less:
  paths: ['includes']

Linting imports

By default, this plugin does not include any lint errors from imported files in the output.

You can enable this by adding an imports configuration option:

lesslint:
  src: ['src/**/*.less']
  imports: ['imports/**/*.less']

Generating reports

This plugin provides the same output formatter options as the CSS Lint plugin and can be configured similarly:

lesslint:
  options:
    formatters: [
      id: 'csslint-xml'
      dest: 'report/lesslint.xml'
    ]

Example output

> grunt lesslint
Running "lesslint" (lesslint) task
static/editor.less (1)
Values of 0 shouldn't have units specified. You don't need to specify units when a value is 0. (zero-units)
>> 14: line-height: 0px;

>> 1 linting error in 56 files.