/tslint-webpack-plugin

TSLint plugin for Webpack

Primary LanguageJavaScriptMIT LicenseMIT

tslint-webpack-plugin

npm version license

NPM

This is a webpack plugin that provides a very simple method of running TSLint alongside your webpack builds. This project differs from tslint-loader in that it will lint all specified files instead of only those that are imported by webpack. This is especially useful for interface files that are not always picked up by webpack (due to treeshaking or whatever).

Installation

This plugin also requires TSLint to be installed.

Install the plugin with npm:

$ npm install tslint tslint-webpack-plugin --save-dev

Basic Usage

The plugin will output tslint errors as part of your webpack build process. It will not fail the build, but simply notify you of changes that need to be made. Just add the plugin to your webpack config as follows:

var TSLintPlugin = require('tslint-webpack-plugin');
var webpackConfig = {
  entry: 'index.js',
  output: {
    path: 'dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new TSLintPlugin({
      files: ['./src/**/*.ts']
    })
  ]
};

Configuration

You can pass a hash of configuration options to TSLintWebpackPlugin.

The basic configuration requires the following:

  • files: string | string[] The files to run through the linter.
    • Examples
      • './src/**/*.ts'
      • ['./src/**/*.ts', './test/**/*.spec.ts']
      • './src/main.ts'
      • ['./src/main.ts', './test/main.spec.ts']

The plugin uses a custom formatter by default, but any of the built-in TSLint formatters can be used.

For advanced usage, see the various runner options here.

License

This project is licensed under MIT.