最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I make Webpack exit with an error when jshint emits warnings? - Stack Overflow

programmeradmin4浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 5

First, 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.

发布评论

评论列表(0)

  1. 暂无评论