Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.89 KB

README.md

File metadata and controls

51 lines (37 loc) · 1.89 KB

JSHint Java Port

Maven Central Code Climate coverage Code Climate maintainability License

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.

Usage

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();