-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vue cli eslint no-console error when no prod mode #2266
Comments
The error is shown because it is in the If 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
|
@sodatea But in here
cli-plugin-eslint set the rule, why no effect? |
@acgotaku It's |
@sodatea Thanks. But can you tell why rerun command the error disappear? If the rules form |
That's weird. I believe it's a bug in |
I have the same problem, (vue cli 3.0.4) eslint config put in package.json is not good way. package.json is just meta data of the package. |
Is this still unresolved. I have this issue and can't find a good workaround. Tried to set
I thought this might force vue to inspect it. But inspection only happens on files that I actually change since the last |
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 |
Emphasizing @mzoe1330 last line... |
Brilliant idea @mzoe1330 , I made your recommendation and it worked. Thanks. |
eslint recommends that we should ship without console statement. |
Works perfectly |
vue.config.js const TerserPlugin = require('terser-webpack-plugin')
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
configureWebpack: {
optimization: {
minimize: true,
minimizer: isProd ? [
new TerserPlugin({
terserOptions: {
ecma: 6,
compress: { drop_console: true },
output: { comments: false, beautify: false }
}
})
] : []
}
}
} |
// eslint-disable-next-line no-console |
Wonder why no one likes this one, as it's by far the best solution. All others are just ugly quickfixes. |
Still having a problem with this! The bug I'm seeing is that I get the "no-console" warnings the FIRST time I do Any ideas? Here's my files-- .eslintrc.jsmodule.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/essential',
'eslint:recommended'
],
parser: 'vue-eslint-parser',
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.VUE_APP_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.VUE_APP_ENV === 'production' ? 'error' : 'off'
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
env: {
jest: true
}
}
]
} package.json
|
@acgotaku can you edit your comment to provide a permalink? the link you provided is referencing HEAD which has evidently changed since you commented. |
Updated~ |
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 outputerror: 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.
The text was updated successfully, but these errors were encountered: