Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail the webpack build on lint errors #82

Open
hodavidhara opened this issue Jun 29, 2017 · 7 comments
Open

Fail the webpack build on lint errors #82

hodavidhara opened this issue Jun 29, 2017 · 7 comments

Comments

@hodavidhara
Copy link

Is there a way to configure tslint-loader/webpack2 so that the entire webpack build will fail (return a non-0 exit code)? I tried with emitErrors: true and failOnHint: true but neither will fail the whole build.

@0xNacho
Copy link

0xNacho commented Jun 30, 2017

I have the same problem with webpack 1.x. This is how my tslint conf looks:
image

After running the build, it just shows warning messages instead of errors, so the build does not fail.

@apastuhov
Copy link

Same for me, does not work

@andelizondo
Copy link

Any update on this? Mine also doesn't make the build fail.

@decates
Copy link

decates commented Jan 23, 2018

In order to fail the build, I had to modify the code that runs webpack (2.6) to output the compilation errors and throw an error to actually fail the build. I think the point is that webpack simply runs the build, and outputs the results. In my build.js file I have something like the following, which correctly fails the build when emitErrors: true is set in the webpack config for tslint-loader:

const util = require('util');
...

webpack(webpackConfig, function (err, stats) {
  if (err) throw err;
  if (stats.compilation.errors && stats.compilation.errors.length > 0) {
    process.stdout.write(util.inspect(stats.compilation.errors));
    throw new Error('One or more webpack errors occurred, failing build.')
  }
});

@gregkopp
Copy link

Can you elaborate more on this solution, and how you incorporated this into package.json? I'm a webpack newbie but I need the build to fail on lint errors for our CI pipeline.

@apastuhov
Copy link

@gregkopp for CI you can run it as a separate command. And for local development you can run it as "prestart" or something like "lint && build"

@fgerschau
Copy link

In webpack 4, setting the emitErrors option to true was enough for me to fail the travis build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants