1

我不确定问题是什么。我不想打开 emitWarnings = true 因为我希望在 eslint 错误期间发出失败并在 eslint 错误后恢复。

修复 eslint 错误后如何让输出继续写入?

我尝试了以下几种选择:

https://github.com/MoOx/eslint-loader#gotchas

需要注意的一件事:我正在通过 Gulp 运行 webpack。

网络包配置:

const webpack = require('webpack');
const path = require('path');
const glob = require('glob');

const PATHS = {
  scriptApp: path.join(__dirname, '/Scripts/App'),
  script: path.join(__dirname, '/Scripts/')
};

module.exports = {
    entry: {
        index1: [PATHS.scriptApp + '/index'],
    },
    devtool: 'eval-source-map',
    module: {
        preLoaders: [
            { test: /\.js$/, loader: 'eslint', exclude: 'node_modules' },
        ],
        loaders: [
            { test: /\.js$/, loader: 'babel-loader', exclude: 'node_modules' },
            { test: /\.dot$/, loader: "dot-loader" } 
        ]
    },
    output: {
        path: path.join(__dirname, '/scripts/app/build'),
        filename: '[name].bundle.js'
    },
    resolve: {
        extensions: ['', '.js', '.dot']
    },
    'dust-loader-complete': {
      wrapperGenerator: function (name) {return "function( context, callback ) { dust.render( '" + name + "', context, callback ); }";}
    },
    plugins: [
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.PrefetchPlugin('jquery'),
        new webpack.PrefetchPlugin('lodash'),
        new webpack.ProvidePlugin({
            $: 'jquery',
            jquery: 'jQuery',
            'windows.jQuery': 'jquery',
            _: 'lodash',
            toastr: 'toastr',

        }),
        // new webpack.optimize.UglifyJsPlugin
    ],
    debug: true,
    eslint: {
      formatter: require('eslint-friendly-formatter')    
    }
};

Gulp 设置:

gulp.task('build-webpack', function (callback) {
    webpack(webpackConfig, function(err, stats) {
        if(err) throw new gutil.PluginError("webpack", err);
        gutil.log("[webpack]", stats.toString({
            // output options
        }));
        callback();
    });
});
4

1 回答 1

1

事实证明这是由于我的 gulp-configuration with webpack-stream. 当 Gulp 失败时,gulp watcher 会忽略流。我添加Gulp-Plumber以防止失败。

于 2016-08-03T18:52:36.327 回答