# gulp-tslint

> TypeScript linter Gulp plugin

Latest version **8.1.4** (published 2019-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-tslint
pnpm add gulp-tslint
yarn add gulp-tslint
bun add gulp-tslint
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.1.4 |
| Published | 2019-02-21 |
| First published | 2014-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 4 |
| Dependencies | 6 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 123 |
| Author | Panu Horsmalahti |
| Maintainers | nawitus |
| Keywords | gulp, typescript, plugin, ts, gulpplugin, gulpfriendly, tslint, linter, lint |

## Links

- npm: https://www.npmjs.com/package/gulp-tslint
- Repository: https://github.com/panuhorsmalahti/gulp-tslint
- Issues: https://github.com/panuhorsmalahti/gulp-tslint/issues
- npm.io page: https://npm.io/package/gulp-tslint

## Dependencies (6)

- [through](https://npm.io/package/through.md) ~2.3.8
- [fancy-log](https://npm.io/package/fancy-log.md) 1.3.3
- [map-stream](https://npm.io/package/map-stream.md) ~0.0.7
- [ansi-colors](https://npm.io/package/ansi-colors.md) ^1.0.1
- [plugin-error](https://npm.io/package/plugin-error.md) 1.0.1
- [@types/fancy-log](https://npm.io/package/@types/fancy-log.md) 1.3.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 8.1.4 (latest) — 2019-02-21
- 8.1.3 — 2018-02-13
- 8.1.2 — 2017-08-08
- 8.1.1 — 2017-06-05
- 8.1.0 — 2017-05-23
- 8.0.0 — 2017-04-10
- 7.1.0 — 2017-02-03
- 7.0.1 — 2016-11-21
- 7.0.0 — 2016-11-20
- 6.1.3 — 2016-11-01
- 6.1.2 — 2016-09-27
- 6.1.1 — 2016-08-22
- 6.1.0 — 2016-08-22
- 6.0.2 — 2016-07-25
- 6.0.1 — 2016-07-09
- … 48 more at https://npm.io/package/gulp-tslint/versions

## README

gulp-tslint
===========

[![Build Status](https://travis-ci.org/panuhorsmalahti/gulp-tslint.svg?branch=master)](https://travis-ci.org/panuhorsmalahti/gulp-tslint)
[![Dependency Status](https://david-dm.org/panuhorsmalahti/gulp-tslint.svg)](https://david-dm.org/panuhorsmalahti/gulp-tslint)

TypeScript linter plugin for Gulp.


First install gulp-tslint
```shell
npm install --save-dev gulp-tslint
```

##### Peer dependencies

The `tslint` module is a peer dependency of `gulp-tslint`, which allows you to update tslint independently from gulp-tslint. gulp-tslint requires TypeScript version >=2 and tslint version >=4.

Usage:
```javascript
// Importing in ES6
import tslint from "gulp-tslint";

// or requiring in ES5
var tslint = require("gulp-tslint");

gulp.task("tslint", () =>
    gulp.src("source.ts")
        .pipe(tslint({
            formatter: "verbose"
        }))
        .pipe(tslint.report())
);
```

Types should work automatically.

**tslint.json** is attempted to be read from near the input file.
It **must be available** or supplied directly through the options.

Failures generated by TSLint are added to `file.tslint`.

The format in which failures are outputted may be controlled by specifying a TSLint formatter.
The default formatter is "prose".
The available formatters include:

* "json" prints stringified JSON to console.log.
* "prose" prints short human-readable failures to console.log.
* "verbose" prints longer human-readable failures to console.log.
* "msbuild" for Visual Studio
* "vso" outputs failures in a format that can be integrated with Visual Studio Online.
* "checkstyle" for the Checkstyle development tool
* "pmd" for the PMD source code analyzer
* "stylish" human-readable formatter which creates stylish messages.

Custom [TSLint formatters](https://palantir.github.io/tslint/develop/custom-formatters/) may also be
used by specifying the `formatter` and `formattersDirectory` properties on the options passed to
`gulp-tslint`.

If upgrading to gulp-tslint v6.0.0 or greater, it should be noted that reporters have been removed
in favour of using TSLint formatters directly. If you were previously specifying a reporter in calls
to `.report()`, these should be removed and instead `formatter` should be specified in calls to
`gulp-tslint`.

If there is at least one failure a PluginError is emitted after execution of the reporters:
```javascript
[gulp] Error in plugin 'gulp-tslint': Failed to lint: input.ts
```

You can prevent emiting the error by setting emitError in report options to false.

```javascript
gulp.task("invalid-noemit", () =>
    gulp.src("input.ts")
        .pipe(tslint({
            formatter: "prose"
        }))
        .pipe(tslint.report({
            emitError: false
        }))
);
```

You can summarize the gulp error message to the number of errors by setting summarizeFailureOutput in report options.

```javascript
gulp.task("invalid-noemit", () =>
    gulp.src("input.ts")
        .pipe(tslint({
            formatter: "prose"
        }))
        .pipe(tslint.report({
            summarizeFailureOutput: true
        }))
);
```

tslint.json can be supplied as a parameter by setting the configuration property.
```javascript
gulp.task("tslint-json", () =>
    gulp.src("input.ts")
        .pipe(tslint({
            configuration: {
              rules: {
                "class-name": true,
                // ...
              }
            }
        }))
        .pipe(tslint.report())
);
```

You can also supply a file path to the configuration option, and the file name
doesn't need to be tslint.json.

```javascript
.pipe(tslint({
    // contains rules in the tslint.json format
    configuration: "source/settings.json"
}))
```

Report limits
-------------

You can optionally specify a report limit in the .report options that will turn off reporting for files after the limit has been reached. If the limit is 0 or less, the limit is ignored, which is the default setting.

```javascript
gulp.task("tslint", () =>
    gulp.src(["input.ts",])
        .pipe(tslint({
            formatter: "prose"
        }))
        .pipe(tslint.report({
            reportLimit: 2
        }))
);
```

Allowing Warnings
-----------------

TSLint 5.0 introduced support for a "warning" severity for linting errors.  By default, warnings cause `gulp-tslint` to emit an error to maintain backwards-compatibility with previous versions.  To let the build succeed in the presence of warnings, use the `allowWarnings` report option.

```javascript
gulp.task("tslint", () =>
    gulp.src("input.ts")
        .pipe(tslint({
            formatter: "prose"
        }))
        .pipe(tslint.report({
            allowWarnings: true
        }))
);
```

Specifying the tslint module
----------------------------

If you want to use a different version of tslint, you can supply it with the `tslint` option.

```bash
npm install tslint@next
```

```javascript
.pipe(tslint({
    tslint: require("tslint")
}));
```

Type checked rules
------------------

Type checked rules require a TypeScript program object to be provided to the linter in the options. For more information see tslint documentation.

```javascript
var gulpTslint = require("gulp-tslint");
var tslint = require("tslint");

// NOTE: Ensure 'Linter.createProgram' is called inside the gulp task else the contents of the files will be cached
// if this tasks is called again (eg. as part of a 'watch' task).
gulp.task('lint', function() {
    var program = tslint.Linter.createProgram("./tsconfig.json");

    return gulp.src('src/**/*.ts', { base: '.' })
        .pipe(gulpTslint({ program }));
}
```

All default tslint options
--------------------------

```javascript
const tslintOptions = {
    configuration: {},
    fix: false,
    formatter: "prose",
    formattersDirectory: null,
    rulesDirectory: null,
    tslint: null,
    program: null
};
```

All default report options
--------------------------

```javascript
const reportOptions = {
    emitError: true,
    reportLimit: 0,
    summarizeFailureOutput: false,
    allowWarnings: false
};
```

Development
===========

Fork this repository, run npm install and send pull requests. The project can be build with ``gulp`` command.

---
_Source: https://npm.io/package/gulp-tslint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
