Posts tagged lint

Javascript CI: JsLint recipe


Download jslint4java from and extract the archive

To lint your code:

find . -iname "*.js" | xargs java -jar jslint4java.jar

What this command does is it

  1. uses the find command for collecting JS files recursively starting in the current directory:
    find . -iname "*.js"
  2. pipes the resulting list of js files to xargs which will then run jslint4java on those files:
     | xargs java -jar jslint4java.jar
  3. For CI you will also need to generate an xml report. This is easily done by using the —report xml flag:
    java -jar jslint4java.jar --report xml > jslint.xml

In Hudson / Jenkins

  1. Add a new build step:
    find . -iname "*.js" | xargs java -jar jslint4java-2.0.2/jslint4java-2.0.2.jar --report xml > jslint.xml
  2. Visualize the report with help of the Violations plugin

Additional notes:

  1. Use find -print0 together with xargs -0 if you have any directory names containing spaces:
    find . -iname "*.js" -print0 | xargs -0 java -jar jslint4java.jar
  2. Use true or echo “lint completed” to prevent lint errors from breaking your build; it seems that otherwise Hudson / Jenkins will stop at that build step and not even create the violations report.