install a command-line JavaScript interpreter, Rhino
sudo apt-get install rhinoinstall JavaScript checker
mkdir -p ~/src/jslint/cd ~/src/jslint/
wget https://raw.github.com/douglascrockford/JSLint/master/jslint.js
create a little wrapper
mkdir -p ~/bin/echo '#!/bin/bash' >> ~/bin/jslint
echo 'rhino -f ~/src/jslint/jslint.js $*' >> ~/bin/jslint
Add ~/bin/ to your PATH
Test the checker
$ echo 'alert(ding)' >>testme.js
$ jslint !$
jslint testme.js
js: uncaught JavaScript runtime exception: ReferenceError: "ding" is not defined.
It works! In our sample code, we call "alert(ding)" using an undefined variable. The code should be "alert('ding')" -- a quoted string.
No comments:
Post a Comment