I'm using eslint with Sublime Text 3 and I am writing gulpfile.js
.
/*eslint-env node*/
var gulp = require('gulp');
gulp.task('default', function(){
console.log('default task');
});
But eslint keeps showing error : "Error: Unexpected console statement. (no-console)"
I found official document here, but I still don't know how to disable it.
/*eslint-env node*/
var gulp = require('gulp');
/*eslint no-console: 2*/
gulp.task('default', function(){
console.log('default task');
});
doesn't work, either.
My Sublime Text 3 plugins: SublimeLinter and SublimeLinter-contrib-eslint.
Here's my .eslintrc.js
file:
module.exports = {
"rules": {
"no-console":0,
"indent": [
2,
"tab"
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
]
},
"env": {
"browser": true,
"node": true
},
"extends": "eslint:recommended"
};
You should add one rule and add your env:
you can add other envs.
A nicer option is to make the display of console.log and debugger statements conditional based on the node environment.
in my
vue
project i fixed this problem like this :ps : package.json is a configfile in the vue project dir, finally the content shown like this:
For vue-cli 3 open
package.json
and under sectioneslintConfig
putno-console
underrules
and restart dev server (npm run serve
oryarn serve
)If you just want to disable the rule once, you want to look at Exception's answer.
You can improve this by only disabling the rule for one line only:
... on the current line:
... or on the next line:
The following works with ESLint in VSCode if you want to disable the rule for just one line.
To disable the next line:
To disable the current line: