npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sportsbet/gulp-tslint

v8.1.1

Published

TypeScript linter Gulp plugin

Downloads

2

Readme

gulp-tslint

Build Status Dependency Status

TypeScript linter plugin for Gulp.

First install gulp-tslint

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:

// 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 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:

[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.

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.

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.

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.

.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.

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.

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.

npm install tslint@next
.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.

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

gulp.src('src/**/*.ts', { base: '.' })
  .pipe(gulpTslint({ program }))

All default tslint options

const tslintOptions = {
    configuration: {},
    fix: false,
    formatter: "prose",
    formattersDirectory: null,
    rulesDirectory: null,
    tslint: null,
    program: null
};

All default report options

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.