jshaptic / jshint-javaport

Straight java port of a javascript linter JSHint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Straight java port of a javascript linter JSHint

License:MIT License


Languages

Language:Java 74.1%Language:JavaScript 25.9%