vue-cli: vue cli eslint no-console error when no prod mode
Version
3.0.0-rc.3
Reproduction link
https://github.com/acgotaku/vue-cli-issue
Node and OS info
yarn 1.9.4 node 8.11.3 Archlinux
Steps to reproduce
First , clone repo and run yarn serve command to start project.
after, uncomment https://github.com/acgotaku/vue-cli-issue/blob/master/src/components/HelloWorld.vue#L35
console.log(msg) the terminal will output error: Unexpected console statement (no-console)
But if you stop yarn serve command and run again, the eslint error will disappear.
What is expected?
Only production mode output on console eslint error.
What is actually happening?
Add console.log to file will trigger eslint error. But if you rerun the command,the eslint error will disappear.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 19 (3 by maintainers)
Make this modification to your package.json file, under “eslintConfig”:
You need to restart “npm run serve” in order for it to honor your new change.
Lazy quickfix for those who don’t want to tamper with anything: just use
window.console.logIs this still unresolved. I have this issue and can’t find a good workaround. Tried to set
lintOnSave: 'error'invue.config.jsand the following in theeslintrc.js(and I tried the same thing with JSON format ineslintrc):I thought this might force vue to inspect it. But inspection only happens on files that I actually change since the last
npm run serve. So if it is cache related, is there a way (manually or in config) to clear the cache so that anpm run servetriggers recompilation and eslint checking of all files?The error is shown because it is in the
eslint:recommendedruleset & you imported it in your ESLint configuration https://github.com/eslint/eslint/blob/a857cd914200c56203a40a42dfbd69d9fe8dc351/conf/eslint-recommended.js#L97If you want to distinguish production env for ESLint rules, please choose “placing config in dedicated config files” as such rule is only possible in a
.jsconfig file:vue.config.js
Emphasizing @mzoe1330 last line… “You need to restart “npm run serve” in order for it to honor your new change.”
// eslint-disable-next-line no-console console.log()
Works perfectly
That’s weird.
I believe it’s a bug in
vue-loaderused in combination withcache-loader. Will open an issue in the upstream library once I figure out a minimum reproduction.