VIM + JSLint?

ben lemasurier picture ben lemasurier · Jan 23, 2009 · Viewed 39.8k times · Source

I spend my days in vim, currently writing a lot of JavaScript. I've been trying to find a way to integrate JSLint or something similar into vim to improve my coding. Has anyone managed to do something like this?

Edit:

tried this: Javascript Syntax Checking From Vim, unfortunately the output is very crude.

Answer

Ory Band picture Ory Band · May 5, 2011

The best-practice way IMO is:

  1. Install Syntastic Vim plugin - Best syntax-checker around for plenty of languages, plus it integrates with Vim's location-list (==quickfix) window.
  2. Choose one of the two options below:

JSLint

  1. Install jsl (JSLint executable) using your favorite package manager (Ubuntu's apt-get, Mac's home brew, etc.).

Community-driven jshint.com (better than JSLint)

  1. Install node.js using your favorite package manager.
  2. Install Node Package Manager: 'curl https://npmjs.org/install.sh | sh' EDIT: npm IS PART OF node.js NOW
  3. Install jshint globally: 'npm install jshint -g'
  4. Put your jshint config file in your $HOME dir: '~/.jshintrc'
  5. Overwrite Syntastic's syntax_checkers/javascript.vim file with this one - EDIT: NO LONGER NECESSARY WITH NEWEST SYNTASTIC VERSION.

Enjoy! :)