CSS syntax errors via CSSlint in VIM

In action
CSSlint via syntastic

You gonna need nodejs and then install CSSlint:

sudo npm install -g csslint

CSSlint options:

$ csslint

Usage: csslint-rhino.js [options]* [file|dir]*
 
Global Options
  --help                                   Displays this information.
  --format=                        Indicate which format to use for output.
  --list-rules                             Outputs all of the rules available.
  --quiet                                  Only output when errors are present.
  --errors=<rule[,rule]+>                  Indicate which rules to include as errors.
  --warnings=<rule[,rule]+>                Indicate which rules to include as warnings.
  --ignore=<rule[,rule]+>                  Indicate which rules to ignore completely.
  --exclude-list=<file|dir[,file|dir]+>    Indicate which files/directories to exclude from being linted.
  --version                                Outputs the current version number.


Next comes the VIM plugin Syntastic. The installation process requires a plugin manager. The README uses pathogen so I stayed with it.
So first install pathogen:

$ mkdir -p ~/.vim/autoload ~/.vim/bundle
$ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Next edit and add to ~/.vimrc:

execute pathogen#infect()

Finally download syntastic:

cd ~/.vim/bundle
git clone https://github.com/scrooloose/syntastic.git

I added this line to my ~/.vimrc

let g:syntastic_csslint_args="--ignore=outline-none"

For a complete list of rules execute:

csslint --list-rules
Advertisements

About Michal Zuber

Biker and rollerblader. Owner and developer at http://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/
This entry was posted in cli, css, vim and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s