Giter Site home page Giter Site logo

mttr / grunt-lesslint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jgable/grunt-lesslint

0.0 2.0 0.0 951 KB

Lint LESS files with Grunt

Home Page: http://jgable.github.io/grunt-lesslint

License: MIT License

CoffeeScript 99.97% CSS 0.03%

grunt-lesslint's Introduction

LESS Lint Grunt plugin

Build Status Dependency Status devDependency 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

  • Clone the repository
  • Run npm install
  • Run grunt to compile the CoffeeScript code
  • Run grunt test to run the specs

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 or loading a .csslintrc file, by adding a csslint option value:

lesslint:
  src: ['less/*.less']
  options:
    csslint:
      'known-properties': false
      csslintrc: '.csslintrc'

LESS

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

lesslint:
  src: ['less/*.less']
  options:
    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']
  options:
    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'
    ]

Using custom rules

It is possible to create and use your own custom rules. To create rules, please refer to the official CSSLint guidelines. The only addition is that each custom rule file must import CSSLint using CSSLint = require('grunt-lesslint').CSSLint.

You can enable your custom rules by adding a customRules configuration option:

lesslint:
  options:
    customRules: ['lint-rules/less/**/*.coffee']

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.

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.