0

I am using JavaScript Lint for checking JavaScript source code. It's working fine with recursive analysis showing results in command window, but I would like to integrate JavaScript Lint results to Hudson (running JavaScript Lint from batch file). How can I get log of JavaScript Lint saved to XML? There are output format configuration in JavaScript Lint, but those customize format of error message.

Thank you in advance, Andrey

2 Answers2

0

I have found the solution for applying Jslint in Hudson. Instead of JavaScript Lint there is jslint4java which reports in XML format. Here is step by step instructions:

  1. Download jslint4java
  2. Prepare Ant script which prepares list of all JS files in project recursively, example:

    <project name="JSlint" default="jslint" basedir=".">
    <description>
        Verify JS files
    </description>
    <target name="jslint" description="Run the JSLint tool on JS files">
    <fileset dir="ProjectForVerification/js" id="jsfiles.raw">
    <include name="*.js" />
    <exclude name="*.min.js" />
    </fileset>
    <pathconvert pathsep=" " property="jsfiles.clean" refid="jsfiles.raw" />
    <exec executable="java" output="jslint.xml">
    <arg line="-jar jslint4java.jar --report xml ${jsfiles.clean}" />
    </exec>
    </target>
    </project>
    
  3. Apply Ant script in Hudson for a job and select Jslint output file name (jslint.xml) in 'Report Violations'

Credits: Here is useful post which I found on this topic.

Pang
  • 9,564
  • 146
  • 81
  • 122
  • Rather than invoking jslint4java as an executable you may find the [ant task](http://docs.jslint4java.googlecode.com/git/2.0.1/ant.html) more convenient. – Dominic Mitchell Nov 01 '11 at 20:53
0

In case anyone's interested, here's a Maven POM snippet we use to run JSlint:

  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <id>jslint</id>
        <phase>test</phase>
        <goals>
          <goal>run</goal>
        </goals>
        <configuration>
          <tasks>
            <taskdef name="jslint" classname="com.googlecode.jslint4java.ant.JSLintTask" classpathref="maven.plugin.classpath" />
            <jslint encoding="UTF-8" options="indent=4,evil,laxbreak">
              <formatter type="plain" />
              <fileset dir="${basedir}/src/main/javascript" includes="**/*.js" />
            </jslint>
          </tasks>
        </configuration>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>com.googlecode.jslint4java</groupId>
        <artifactId>jslint4java-ant</artifactId>
        <version>1.3.3</version>
      </dependency>
    </dependencies>
  </plugin>
lexicore
  • 42,748
  • 17
  • 132
  • 221