Using JSLint with Syntastic in Vim

7

2

I'm using Syntastic for syntax checking in Vim - whenever I save an .rb file, it runs it through a syntax checker and highlights errors for me. Spiffy. Same for several other file types: HAML, HTML, etc. It does this by calling out to external syntax checkers and displaying the errors they return.

Syntastic can be configured various ways, but this is what I added to my .vimrc:

  " When writing a file, if there are errors, have Syntastic plugin mark them
  let g:syntastic_enable_signs=1
  let g:syntastic_auto_loc_list=1

Lately, I've had several elusive Javascript bugs that I eventually found by copying and pasting my code into the web interface of JSLint. I'd really like to have JSLint run on my .js files every time I save them, but searching for "command line JSLint" has mostly gotten me confusion.

Is there an official command-line version of JSLint? Does anybody have clear instructions on getting JSLint to run via Syntastic?

Nathan Long

Posted 2011-02-17T15:50:12.260

Reputation: 20 371

Answers

9

Syntastic is looking for the jsl binary in your path. You can download jsl (command line js lint) from http://www.javascriptlint.com/download.htm

After it is installed I would restart vim and viola, it should work.

If you are on a mac, you can also do brew install jslint and it will install the jsl executable for you.

Adam

Posted 2011-02-17T15:50:12.260

Reputation: 246

1After using brew i had to add to my .vimrc this

let g:syntastic_javascript_checkers = ['jslint']
 – Guillermo Siliceo Trueba  – 2013-10-22T01:09:46.767

9

As noted by Adam the jsl binary is the easiest way to get things set up. I'd like to note, however, that you can also install a jslint in your path via npm (so long as you already have npm and node.js installed):

npm install -g jslint

The -g flag tells npm you want to install the package globally.

Tom

Posted 2011-02-17T15:50:12.260

Reputation: 191

You can also use jshint if you like. npm install -g jshint – Noah – 2013-08-21T04:34:59.750