net.happygiraffe.jslint.ant
Class JSLintTask

java.lang.Object
  extended by Task
      extended by net.happygiraffe.jslint.ant.JSLintTask

public class JSLintTask
extends Task

Run JSLint over a tree of files in order to pick holes in your JavaScript.

Example build.xml usage:

 <project name="build-test" xmlns:jsl="antlib:net.happygiraffe.jslint">
   <target name="jslint">
     <jsl:jslint options="undef">
       <formatter type="plain" />
       <fileset dir="." includes="*.js" excludes="*.pack.js" />
     </jsl:jslint>
   </target>
 </project
 

You have to specify one or more nested fileset elements. You may optionally specify a formatter element in order to generate output (as opposed to just a build failed message). Usually, you will want the plain formatter, but in case you want to generate a report, the xml formatter mighht be useful.

Attributes

encoding
Optional. The encoding of the JavaScript files. Defaults to system encoding.
haltOnFailure
Optional. Specify if the build should fail if there are files which do not pass JSLint. Defaults to true.
options
Optional. A comma separated list of Option names. No default.

Version:
$Id$
Author:
dom
See Also:
jslint.com, FormatterElement

Constructor Summary
JSLintTask()
           
 
Method Summary
 void addConfiguredFormatter(FormatterElement fe)
          Add in a ResultFormatter through the medium of a FormatterElement.
 void addFileset(FileSet fileset)
          Check the contents of this FileSet.
 void execute()
          Scan the specified directories for JavaScript files and lint them.
 void init()
          Create a new JSLint object.
 void setEncoding(String encoding)
          Set the encoding of the source files that JSLint will read.
 void setHaltOnFailure(boolean haltOnFailure)
          Should the build stop if JSLint fails? Defaults to true.
 void setOptions(String optionList)
          Set the options for running JSLint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSLintTask

public JSLintTask()
Method Detail

addConfiguredFormatter

public void addConfiguredFormatter(FormatterElement fe)
Add in a ResultFormatter through the medium of a FormatterElement.

Parameters:
fe -

addFileset

public void addFileset(FileSet fileset)
Check the contents of this FileSet.

Parameters:
fileset -

execute

public void execute()
             throws BuildException
Scan the specified directories for JavaScript files and lint them.

Throws:
BuildException

init

public void init()
          throws BuildException
Create a new JSLint object.

Throws:
BuildException

setHaltOnFailure

public void setHaltOnFailure(boolean haltOnFailure)
Should the build stop if JSLint fails? Defaults to true.

Parameters:
haltOnFailure -

setEncoding

public void setEncoding(String encoding)
Set the encoding of the source files that JSLint will read. If not specified, the default is the system encoding (via the file.encoding property). If that isn't present, default to UTF-8.

Parameters:
encoding - a valid charset identifier.

setOptions

public void setOptions(String optionList)
                throws BuildException
Set the options for running JSLint. This is a comma separated list of Option names. The names are case-insensitive.

Throws:
BuildException