Often when I use Javascript it is to improve functionality of a website and does not require many lines of code. It is difficult to remember all the nuances of Javascript and often it is not worthwhile to try to write good Javascript. But I have been writing longer Javascript scripts and wanted to try a lint for Javascript. I had to search around before I could get something working so these are some notes so I do not have to search around for the information again.
I ended up using Javascript Lint 0.3.0. The installation directions were incomplete and I finally found Ken Guest's blog much more helpful.
tar xzvf jsl-0.3.0-src.tar.gz cd jsl-0.3.0/src make -f Makefile.ref all cd Linux_All_DBG.OBJ sudo cp jsl jscpucfg /usr/local/bin/ jsl -help:conf >jsl.conf sudo mv jsl.conf /etc/
Ken also recommends the inclusion of the following lines in the jsl.conf Defining Identifiers section:
+define ActiveXObject +define addEventListener +define alert +define attributes +define blur +define childNodes +define click +define clearTimeout +define dispatchEvent +define document +define firstChild +define focus +define Image +define item +define lastChild +define localName +define namespaceURI +define navigator +define nextSibling +define nodeName +define nodeType +define nodeValue +define ownerDocument +define parent +define parentNode +define prefix +define previousSibling +define removeEventListener +define screen +define scrollIntoView +define setTimeout +define tagName +define window +define XMLHttpRequest
To integrate Javascript Lint with Vim, I found Joe Stelmach's plugin works well and uses a split terminal to show the errors when the buffer is written without exiting Vim.
Add new comment