jrparish / tslint-webpack-plugin

TSLint plugin for Webpack
MIT License
20 stars 9 forks source link

Fix option should batch the changes #12

Open ljani opened 6 years ago

ljani commented 6 years ago

Enabling the fix option for the plugin with webpack-dev-server's watch mode seems to cause tslint to fix the issues one-by-one-ish while webpack compiles everything after each change. This is painful if you have multiple mistakes when doing eg. save all with your editor.

To reproduce this, enable fix for the plugin and start webpack-dev-server in watch mode. To enable fix, change your webpack configuration file to:

new TslintWebpackPlugin({
    // ...
    fix: true
})

The log looks like this:

webpack: Compiled successfully.
[tslint-plugin] Starting linter in separate process...
webpack: Compiling...
...
webpack: Compiled successfully.
[tslint-plugin] Starting linter in separate process...
webpack: Compiling...
...
webpack: Compiled successfully.
[tslint-plugin] Starting linter in separate process...
webpack: Compiling...
...
webpack: Compiled successfully.
[tslint-plugin] Starting linter in separate process...
webpack: Compiling...
...

(Notice how tslint-plugin never completes.)

It seems that this happens because:

  1. Webpack compilation finishes
  2. tslint starts
  3. tslint fixes an issue and continues to the next file
  4. webpack detects the change and starts compiling
  5. tslint-webpack-plugin kills tslint
  6. Go to step 1.

I have no idea how to fix this properly, but the hooks in plugin.js seem to support my theory.

I'm still using webpack@3 if that matters.

EDIT: Changed the loop to illustrate the problem better

ljani commented 6 years ago

Turns out there are other issues related to fix: true in addition to the behavior of tslint-webpack-plugin: https://github.com/palantir/tslint/issues/3786.