TSLint 4.0 Released

TSLint 4.0 has been released! With this release comes a few exciting changes. Some of the highlights:

Create your own fixer

To create your own fixer, instantiate a Fix object and pass it in as an argument to addFailure.

This snippet updates the sample custom rule by adding a fixer which replaces the offending import statement with an empty string:

// create a fixer for this failure
const replacement = new Lint.Replacement(node.getStart(), node.getWidth(), "");
const fix = new Lint.Fix("no-imports", [replacement]);

this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING, fix));

Also Read...