jslint4java can be run as an executable jar file:
$ java -jar jslint4java-2.0.5.jar
Usage: jslint4java [options] file.js ...
--ass If assignment expressions should be allowed
--bitwise If bitwise operators should be allowed
--browser If the standard browser globals should be predefined
--closure If google closure idioms should be tolerated
--continue If the continuation statement should be tolerated
--debug If debugger statements should be allowed
--devel If logging should be allowed (console, alert, etc.)
--encoding Specify the input encoding
--eqeq If == should be allowed
--es5 If es5 syntax should be allowed
--evil If eval should be allowed
--forin If for in statements need not filter
--help Display usage information
--indent The indentation factor
--jslint Specify an alternative version of jslint.js
--maxerr The maximum number of errors to allow
--maxlen The maximum length of a source line
--newcap If constructor names capitalization is ignored
--node If node.js globals should be predefined
--nomen If names may have dangling _
--passfail If the scan should stop on first error
--plusplus If increment/decrement should be allowed
--predef The names of predefined global variables
--properties If all property names must be declared with /*properties*/
--regexp If the . should be allowed in regexp literals
--report Display report in different formats: plain, xml, junit, checkstyle and report
--rhino If the rhino environment globals should be predefined
--sloppy If the 'use strict'; pragma is optional
--stupid If really stupid practices are tolerated
--sub If all forms of subscript notation are tolerated
--timeout Maximum number of seconds JSLint can run for
--todo If todo comments are tolerated
--unparam If unused parameters should be tolerated
--vars If multiple var statements per function should be allowed
--version Show the version of JSLint in use.
--warnings Unused
--white If sloppy whitespace is tolerated
--windows If ms windows-specific globals should be predefined
using jslint version 2013-05-01
The list of options is (mostly) derived from the Option enum. For fuller documentation of each option, see the jslint web site.
You must pass a number of javascript files on the command line. For each one, jslint4java will produce a list of errors on stdout. If any errors are found, an exit code of 1 will be returned.
If -
is specified as a filename, stdin will be read instead.
Sample error output:
$ cat dodgy.js
someVar = 42
$ java -jar jslint4java-2.0.5.jar dodgy.js
jslint:dodgy.js:0:12:Missing semicolon.
$
The fields are colon separated and consist of:
Most command line flags are boolean. If you wish to pass a value to a flag
(e.g. --indent
), it must be separated by whitespace. For example:
$ cat happy.js
var x;
if (x) {
x = 42;
}
$ java -jar jslint4java-2.0.5.jar --white happy.js
jslint:happy.js:2:2:Expected 'x' to have an indentation of 4 instead of 2.
$ java -jar jslint4java-2.0.5.jar --white --indent 2 happy.js
$
To pass a list of predefined global variables, give a comma separated
list of names to --predef
, e.g.
$ cat globals.js
foo(bar(42));
$ java -jar jslint4java-2.0.5.jar globals.js
jslint:globals.js:1:1:'foo' is not defined.
jslint:globals.js:1:5:'bar' is not defined.
$ java -jar jslint4java-2.0.5.jar --predef foo,bar globals.js
$
--help
produces the usual display of information.
If your file is in an alternative encoding, that can be specified
with the --encoding
flag. This value is passed directly
to Charset.forName(),
so any encoding supported by your Java VM is allowed. If no encoding
is specified, the platform default is used.
<subliminal>Use UTF-8! Use UTF-8!</subliminal>
You may request an alternative form of reporting using the
--report
flag.
--report |
Description |
---|---|
plain | A more verbose plain text format, which shows the line of code on which the error occurs, as well as highlighting the position of the error within that line. |
junit | Produce an XML file similar to that of the ant junit task. This is a good choice for integrating with third-party systems. |
report | JSLint will produce an HTML report on your code, including a list of all functions. |
xml | A custom XML format, with one element per error. You should prefer the JUnit output format if possible. |
You can specify an alternative jslint.js
in case the version
supplied doesn't suit you (for example there is a newer version available).
To use another jslint, specify --jslint /some/where/jslint.js
on the command line.