Installing scss-lint for grunt
Assuming that you have gruntfile.js/gruntfile.coffee and package.json files, you need to install the package via npm.
npm install grunt-scss-lint --save-dev
Then, it may be enables inside your Gruntfile:
Configuring your task
It's very easy to configure it, you have different options to customize your output. Here are some examples:
- colorizeOutput: Get some nice looking output. The default value is true.
- reporterOutput: The jUnit XML file to save the output to.
- emitError : Emits a Grunt event on scss-lint error called scss-lint-error.
It's important to know that all xml files must be in the same directory of Gruntfile. Thanks @akodde.
Get total automatization with grunt-watch
The above example provides a task that you can use with grunt scsslint command. It's good but not good enough. Grunt watch give us the possibility to automate the code validation when we save the sass file.
To get that, we have to install grunt watch and add this configuration:
Install scss-lint as a ruby gem
If you don't use grunt, you can check your sass code installing the gem:
gem install scss-lint
Then, you can lint your code by typing:
It's really easy to install and use scss-lint, but the really important point is the code validation. In big projects, with lots of contributors and teams, the lint of code is useful to prevent bad quality of scss code. Of course the code validation by other team member is necessary also, but this plugin is a good option to be the first filter.