7

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?

2 Answers 2

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.

1
  • 1
    After using brew i had to add to my .vimrc this let g:syntastic_javascript_checkers = ['jslint']
    – Guillermo
    Oct 22, 2013 at 1:09
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.

1
  • You can also use jshint if you like. npm install -g jshint
    – Noah
    Aug 21, 2013 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.