Archive for March, 2007

Integrating JavaScript lint with vim

Sunday, March 18th, 2007

After looking for a lint program for JavaScript, I’ve found JavaScript Lint and after a few pokes around the documentation and forum, got it installed and integrated with vim.
I posted this information to the Irish PHP Users’ Group mailing list on Wednesday – thought I’d share it to a wider audience tonight.

This is how I did it, note this process now only works with the downloaded package JavaScript Lint 0.3.0:

I got, compiled and installed javascriptlint:
$ svn co https://svn.sourceforge.net/svnroot/javascriptlint/trunk javascriptlint
$ cd javascriptlint
$ make -f Makefile.ref all
$ cd Linux_All_DBG.OBJ/
$ sudo cp jsl jscpucfg /usr/local/bin/
$ #generate default config file (and edit to taste)
$ jsl -help:conf > /etc/jsl.conf

I added the following lines to the “Defining identifiers” section of jsl.conf, as JavaScript Lint
doesn’t know anything about DOM objects in web browsers.

+define window
+define document
+define alert
+define XMLHttpRequest
+define ActiveXObject
+define Image
+define parent
+define dispatchEvent
+define screen
+define navigator
+define setTimeout

I also turned on the ‘option explicit’ settingÅŸ which causes the linter to catch undeclared variables in the “Defining identifiers” section.

For integrating with vim I added these lines to my ftplugin/javascript.vim file:

set makeprg=jsl\ -nologo\ -nofilelisting\ -nosummary\ -nocontext\ -conf\ '/etc/jsl.conf'\ -process\ %
set errorformat=%f(%l):\ %m
"make F10 call make for linting etc.
inoremap <silent> <F10> <C-O>:make<CR>
map <silent> <F10> :make<CR>

planetilug.linux.ie upgraded

Sunday, March 18th, 2007

Finally got around to update the software running behind planetilug.linux.ie to planetplanet v2.0 – this has solved quite a number of issues that the previous install exhibited. Links to all subscribers blogs should just work and all entries are displayed properly.

fold error in javascript.vim

Saturday, March 17th, 2007

I discovered Yi Zhao’s replacement for javascript.vim which has better syntax highlighting for .js files. One slight problem though – straight after I copied it into my ~/.vim/syntax directory all my fold settings stopped working.
To fix this edit javascript.vim and change “setlocal foldlevel=6″ to “setlocal foldlevel=0″.

Irish PHP Users Group; second meeting

Thursday, March 1st, 2007

The second meeting of the Irish PHP Users Group came and went last night – there wasn’t all that many of us there at all (a sum total of two!) . This has triggered a healthy discussion on the mailing list of what we could to do raise the awareness of the Users Group and what it should be about.

Join in on the discussion here.