Just a straight port of a javascript linter JSHint. Almost everything is ported to a native Java code, except regexps validation - it is done using Java internal Nashorn engine.
Code linting with default options:
JSHint jshint = new JSHint();
jshint.lint("var a = 123");
System.out.println(jshint.generateSummary());
Code linting with custom options (for list of all options check JSHint website):
JSHint jshint = new JSHint();
jshint.lint("var a = 123", new LinterOptions().set("esversion", 6).set("asi", true));
System.out.println(jshint.generateSummary());
Code linting with custom globals:
JSHint jshint = new JSHint();
jshint.lint("var a = test(source)", new LinterOptions(), new LinterGlobals(true, "test", "source"));
System.out.println(jshint.generateSummary());
Reading linting summary:
JSHint jshint = new JSHint();
jshint.lint("var a = test(source)");
DataSummary report = jshint.generateSummary();
// List of all warnings and errors
report.getErrors();
// List of all methods, objects, variables etc, which are used in the code, but defined anywhere
report.getImplieds();
// List of all unused variables
report.getUnused();