报错信息:

error: Unexpected console statement (no-console) at src\components

eslint 5.16.0 no-console问题
新创建了一个vue/cli 4.x 版本的项目,eslint在create时候集成,然后就出现了这个报错。
随后,在 node_modules/eslint/lib 文件下发现了no-console.js:
eslint 5.16.0 no-console问题
然后去官网查看:
eslint 5.16.0 no-console问题
看字面意思仿佛是大写C就可以,然而,没有用,依旧报错。。。:
eslint 5.16.0 no-console问题
气急败坏,在官网全局搜索 no-console:
发现,eslint6.0.0开始“抛弃”console.log规则了!然而迷惑行为就是我的eslint版本明明是5.16.0!!!
eslint 5.16.0 no-console问题
但好在找到了解决方法,如上图最后一行代码,‘error’表示 no-console继续作用。
在配置文件package.json中加 no-console: "off",就实现了:
eslint 5.16.0 no-console问题

相关文章: