Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven plugins to analyze javascript code quality

Tags:

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 ?

like image 740
Alexandre Victoor Avatar asked Sep 18 '08 13:09

Alexandre Victoor


2 Answers

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

like image 146
Justin Searls Avatar answered Oct 28 '22 08:10

Justin Searls


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>
like image 23
Gian Marco Avatar answered Oct 28 '22 07:10

Gian Marco