一个使用vue cli 3.2建立的项目,建立时未开启 lintOnSave,后来但愿开启并设置为 lintOnSave: 'error',但配置不生效。vue
解决方法1:新建立项目(此时vue cli 版本为 3.4)并开启 lintOnSave,而后删除其中全部文件,将旧有项目全部代码(包括node_modules)移动到新项目文件夹,发现lintOnSave报错页面提示有。node
解决方法2:在 vue.config.js 中配置:webpack
module.exports = { devServer: { overlay: { warnings: true, errors: true } }, lintOnSave: 'error', chainWebpack: config => { config.module.rule('eslint').use('eslint-loader').loader('eslint-loader').tap(opt => { opt.emitWarning = opt.emitError = opt.failOnWarning = opt.failOnError = true; return opt; }); } };
参考:【eslint-loader:Errors and Warning】web