Javascript code can be tough to maintain.
I am looking for tools that will help me ensure a reasonable quality level.
So far I have found JsUNit, a very nice unit test framework for javascript. Tests can be run automatically from ant on any browser available.
I have not found yet some javascript equivalent of PMD, checkstyle, Findbug...
Do you know any static code analysis tool for javascript ?
This is an old thread, but if you're interested in running Jasmine for BDD testing in your maven project, I wrote this jasmine-maven-plugin for exactly this purpose (that is, improving JS quality by encouraging TDD of it).
http://github.com/searls/jasmine-maven-plugin
I've used the following code to run JSLint as part of the COMPILE phase in Maven.
It downloads jslint4java from maven repository so you don't need anything else.
If JSLint found problems in javascript files, the build will fail.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef name="jslint" classname="com.googlecode.jslint4java.ant.JSLintTask" classpath="${settings.localRepository}/com/googlecode/jslint4java/jslint4java-ant/1.4.2/jslint4java-ant-1.4.2.jar" />
<jslint options="white,browser,devel,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed">
<predef>Ext,Utils</predef>
<formatter type="plain" />
<fileset dir="${basedir}/src/main/resources/META-INF/resources/js" includes="**/*.js" />
</jslint>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.googlecode.jslint4java</groupId>
<artifactId>jslint4java-ant</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With