tslint-webpack-plugin

raw JSON →
2.1.1 verified Sat Apr 25 auth: no javascript maintenance

TSLint plugin for Webpack that lints all specified files, not only those imported by Webpack, making it useful for interface files missed due to tree-shaking. Version 2.1.1 is the latest stable release. The plugin is in maintenance mode due to TSLint being deprecated in favor of @typescript-eslint. Key differentiator vs tslint-loader: it lints all files matching a glob pattern instead of only files in the dependency graph.

error Error: Cannot find module 'tslint-webpack-plugin'
cause Missing npm install of the plugin
fix
npm install tslint-webpack-plugin --save-dev
error TypeError: TSLintPlugin is not a constructor
cause Using ES import syntax (import TSLintPlugin from ...) which doesn't work with CJS module
fix
Replace with const TSLintPlugin = require('tslint-webpack-plugin');
error Error: 'format' is not a supported option
cause Plugin v2+ removed the 'format' option
fix
Remove 'format' from plugin options
deprecated TSLint is deprecated in favor of @typescript-eslint
fix Migrate to @typescript-eslint/eslint-plugin and eslint-webpack-plugin or fork-ts-checker-webpack-plugin with ESLint
breaking v2 removed the 'format' option for formatters
fix Remove 'format' option; use custom formatter via TSLint API if needed
gotcha Plugin does not fail the build by default; errors are warnings
fix Set 'waitForLinting: true' and 'warningsAsError: true' to fail on lint errors
gotcha Requires both tslint and webpack as peer dependencies; not automatically installed
fix npm install tslint webpack --save-dev
npm install tslint-webpack-plugin
yarn add tslint-webpack-plugin
pnpm add tslint-webpack-plugin

Sets up Webpack with ts-loader and tslint-webpack-plugin to lint all .ts files in src/

const TSLintPlugin = require('tslint-webpack-plugin');
const path = require('path');
module.exports = {
  entry: './src/index.ts',
  output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' },
  resolve: { extensions: ['.ts', '.js'] },
  module: { rules: [{ test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/ }] },
  plugins: [
    new TSLintPlugin({ files: ['./src/**/*.ts'] })
  ]
};