Using jshint-loader with Webpack, how do I make the webpack
mand fail when JSHint emits warnings?
The context being that I wish to fail the CI build if linting detects issues.
Currently, I've simply configured Webpack to run jshint-loader on preload of JS files:
// webpack.config.js
module.exports = {
module: {
preLoaders: [
{
test: /\.js/,
exclude: /node_modules/,
loader: 'jshint-loader',
},
],
},
};
Using jshint-loader with Webpack, how do I make the webpack
mand fail when JSHint emits warnings?
The context being that I wish to fail the CI build if linting detects issues.
Currently, I've simply configured Webpack to run jshint-loader on preload of JS files:
// webpack.config.js
module.exports = {
module: {
preLoaders: [
{
test: /\.js/,
exclude: /node_modules/,
loader: 'jshint-loader',
},
],
},
};
Share
Improve this question
edited Apr 8, 2015 at 9:15
aknuds1
asked Apr 8, 2015 at 9:04
aknuds1aknuds1
68.2k69 gold badges206 silver badges320 bronze badges
1 Answer
Reset to default 5First, jshint-loader must be configured to fail in case issues are found (failOnHint: true
), optionally one can also choose to emit warnings as Webpack errors (emitErrors: true
).
// webpack.config.js
module.exports = {
module: {
preLoaders: [
{
test: /\.js/,
exclude: /node_modules/,
loader: 'jshint-loader',
},
],
},
jshint: {
emitErrors: true,
failOnHint: true,
},
};
Second, Webpack must be told to fail hard, by supplying the --bail
option: webpack --bail
.
Update:
webpack --bail
still doesn't emit a non-zero exit code, argh.