简体   繁体   English

Vue CLI 3 - 构建不会因 lint 错误而失败

[英]Vue CLI 3 - Build not failing on lint errors

I created a project using Vue CLI 3 rc3 and enabled lintOnSave.我使用 Vue CLI 3 rc3 创建了一个项目并启用了 lintOnSave。 When I build my project the linting errors show up as warnings but do not fail the build.当我构建我的项目时,linting 错误显示为警告,但不会使构建失败。 Is this intended?这是故意的吗? If so how do I configure it to stop the build.如果是这样,我如何配置它以停止构建。

I'm not sure if this is the best approach, but I noticed that the CLI generated config has emitWarning: true which throws warnings instead of failing a build.我不确定这是否是最好的方法,但我注意到 CLI 生成的配置有emitWarning: true ,它会抛出警告而不是构建失败。

To change this, inside vue.config.js I added:为了改变这一点,我在vue.config.js添加了:

module.exports = {
    chainWebpack: config => {
        config.module
        .rule('eslint')
        .use('eslint-loader')
        .tap(opts => ({ ...opts, emitWarning: false }))
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM