tslint-webpack-plugin icon indicating copy to clipboard operation
tslint-webpack-plugin copied to clipboard

Fix option should batch the changes

Open ljani opened this issue 6 years ago • 1 comments

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 avatar Mar 20 '18 14:03 ljani

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.

ljani avatar Mar 21 '18 19:03 ljani