For what ever reason I decided I’m doing too much js to not being using the Excellent JSLint as such I’ve decided it’s time to use it in anger, no more bespoke copy and pasting, automated stylee, here how to do it
$bash – ./scripts/jslintchecker.sh iplayer/ report.txt scripts/jslint.js
Files here ->
JSLINT AUTOMATOR_SHELL_SCRIPT ZIP HERE
update 4th May – fix script for absolute paths agruments
Basic solution ->
Shell script Grabs files gives them to running JSLint on spidermonkey
Core bash command is
$bash – find . -name *.js
-exec sh -c ‘
cat $1 | jslint.js;’ {} {}
> report.txt ;
So broken down thats
$bash – find . -name *.js # get all the js files in . folder
-exec sh -c ‘echo $1′ {} {} # run a shell command with the js file as the $1 variable
echo -e “B:AH”# print some nice stuff
cat $1 | jslint.js; # pipe the file $1 = /balh/balh,js, into jslint pass on the stdOut from that
> report.txt ; # chuck in a file called report.txt
Steps ->
1. Install Spidermonkey
linux command I used
$bash – yum clean all;
$bash – yum –noplugins install js-devel
more helpful instructions found here
2. Copy and unzip .sh/.js script files
js file from this excellent blog on the matter, and this guy cheers to him for writing an excellent post of using pipes within find exec commands,cheers you guys are the best
3. Chmod jslintchecker.sh and jslint.js so they execute, incase the zip file breaks it
$bash – chmod 777 jslintchecker.sh
$bash – chmod 777 jslint.js
4. Run jslintchecker.sh on the folder you wanta jslint check
USEAGE jslintchecker.sh <JS_FOLDER> <REPORT_FILE_NAME> <JSLINT_LOCATION>
$bash – ./scripts/jslintchecker.sh iplayer/ report.txt scripts/jslint.js
Zap
