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

[More...] 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




Many Thanks To

http://whereisandy.com/code/jslint/
for hacked jslint and great instructions and jslint cl walkthrough

http://wiki.apache.org/couchdb/Installing_SpiderMonkey
for spidermonkey instructions

http://www.compuspec.net/reference/os/solaris/find/find_and_execute_with_pipe.shtml
for showing me how to pipe inside a find exec

http://www.dartmouth.edu/~rc/classes/ksh/
for unix commands and refresher

Log
Update 1 - 4th May 2010
- fix for absolute path inputs
