Library
Installation
npm install tslint
npm install typescript
Peer dependencies
The typescript
module is a peer dependency of TSLint, which allows you to update the compiler independently from the
linter. This also means that tslint
will have to use the same version of tsc
used to actually compile your sources.
Breaking changes in the latest dev release of typescript@next
might break something in the linter if we haven’t built against that release yet. If this happens to you, you can try:
- picking up
tslint@next
, which may have some bugfixes not released intslint@latest
(see release notes here). - rolling back
typescript
to a known working version.
Usage
Please ensure that the TypeScript source files compile correctly before running the linter.
```ts var fileName = “Specify file name”;
var configuration = { rules: { “variable-name”: true, “quotemark”: [true, “double”] } };
var options = { formatter: “json”, configuration: configuration, rulesDirectory: “customRules/”, // can be an array of directories formattersDirectory: “customFormatters/” };
var Linter = require(“tslint”); var fs = require(“fs”); var contents = fs.readFileSync(fileName, “utf8”);
var ll = new Linter(fileName, contents, options); var result = ll.lint(); ```