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"
};
If you install eslint under your local project, you should have a directory /node_modules/eslint/conf/ and under that directory a file eslint.json. You could edit the file and modify "no-console" entry with the value "off" (although 0 value is supported too):
I hope this "configuration" could help you.
You should update eslint config file to fix this permanently. Else you can temporarily enable or disable eslint check for console like below
I'm using Ember.js which generates a file named
.eslintrc.js
. Adding"no-console": 0
to the rules object did the job for me. The updated file looks like this:If you're still having trouble even after configuring your package.json according to the documentation (if you've opted to use package.json to track rather than separate config files):
And it still isn't working for you, don't forget you need to go back to the command line and do npm install again. :)
Create a .eslintrc.js in the directory of your file, and put the following contents in it:
In package.json you will find an
eslintConfig
line. Your 'rules' line can go in there like this: