In this post I will shortly describe configuration process of JSLint SBT plugin and then TeamCity build config that reacts on errors/warnings raised by this plugin.


In my current project we are working with rather non-standard technologies for a decent Java developer. Our backend runs on Scala and Scalatra and serves pure JSON to the frontend written in JavaScript and AngularJS. And as we are far from being seasoned JS developers, we want to have quality our JS codebase guarded by some automatic tool.


After some research it appeared that JSLint is for JS the same as FindBugs for Java so we decided to try it out in our project. Luckily there is a JSLint SBT plugin so we weren’t forced to carve our own solution.


SBT-JSLint plugin

According to the documentation to configure plugin we have to perform two following steps:

1. Add plugin declaration to Plugins.scala file

2. Include plugin settings in Build.scala:

But as usual these steps are not enough. First of all, when we run sbt jslint we will see that it scans some default directory looking for JS files to analyse. And of course our JavaScript lies in a completely different place. Secondly, we want to add jslint step to build process so it is executed every time. So simply, we need lintCustomSettings with declared custom JS location and jslint step process added to test step in our build:

Now after running sbt test we will see that JavaScript code is checked and report is printed to the console and also written in target/jslint/results.xml file.

When you analyse report.xml you might be overwhelmed by the number of warnings raised by the plugin. Some of them are quite useful, but some might be ignored or, even better, disabled by custom flags. In our project we use something like:

added to lintCustomSettings. For more flags and their descriptions please visit plugin documentation.

Team City config

Now, as we have our plugin running and generating report.xml, we could configure TeamCity build to react on JS errors and warnings.

Simply go to Edit Configuration Settings of your build and then choose “Build Step: Command Line”:


And in the section Additional Build Features click “Add build feature”, choose “XML report processing”, then “JSLint” and specify path to the report.xml file. Personally I also check “Verbose output” to see more details in the build log.


After saving we can go next build step named “Build failure conditions” and define two new rules there so we end up with something similar to screen presented below:


And finally our build is fully configured to report and react on problems in JavaScript files:


Reference commits from my current project: