Thursday, May 10, 2012

Running JSLint Plugin for Grails

As a side project I am currently working on a Javascript heavy application, and I thought it was a good opportunity to see how easily Javascript  testing is brought to a Grails application (which is so good at testing all of the server side components).

I found the JS Lint Grails Plugin but was disheartened when it complained about a missing dependency (which causes me to reflect how spoilt dependency management has made me these days).

Here was my issue:

grails> install-plugin jslint
| Plugin installed.
grails> jslint
| Error Error running script jslint: : taskdef class com.googlecode.jslint4java.ant.JSLintTask cannot be found

Ridiculously easy to solve. I added the following to BuildConfig.groovy:

dependencies {
    compile 'com.googlecode.jslint4java:jslint4java-ant:2.0.2'
}

and voila:

grails> jslint
| Environment set to development.....
Running jslint on:web-app/js
| Error Error running script jslint: : JSLint: 57 errors in 2 files (Use --stacktrace to see the full trace)

No Reports? Make sure you are running version 0.4 or later. At the time of writing you needed to add the grailsRepo 'http://grails.org/plugins' repository in BuildConfig.groovy to see the latest and greatest, which in this case was difference between implemented and unimplemented reporting options.

No comments:

Post a Comment