I went with JSHint and I really like the results.
- JSHint also complains about undeclared variables, e.g. L which is declared in leaflet.js and angular which is declared in angular.js These weren't errors at all but are easily permanently silenced... and could have been invaluable if the "undeclared global" were actually a typo.
- JSHint also reports unused variables. In most cases this was a callback that receives an error object, and we don't use the error object. But in a few cases it was dependency injections which were no longer in use. So a second use of JSHint was to check for unused dependencies and for erroneous undeclared dependencies. Very nice.
Step 1, install JSHint via npm. You're used to this if you use Cordova:
npm install -g jshintStep 2, set up this script. Heck, add it to your source archive:
#!/bin/shIt's dead simple, nothing special... but it does keep things a bit tighter, and makes for easy and automated checks for some common goofs.
for js in www/index.js www/controllers/*.js ; do
echo "********** CHECKING $js"
Now, the other tool commonly used here is JSLint. But so far I'm not impressed with it. Reporting unused variables and potential typographical errors is great, but JSLint reports truly stupid stuff such as having a space after the colon in an object literal, stuff which truly has no impact nor potential for impact. Maybe later, but not today.