Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eslint: How to disable "unexpected console statement" in Node.js?

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)" eslint error

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" }; 
like image 775
Jean Y.C. Yang Avatar asked Dec 11 '15 03:12

Jean Y.C. Yang


People also ask

How do I disable ESLint console log?

To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console. log('JavaScript debug log'); console. log('eslint is disabled now');

How do I disable ESLint?

disable eslint directoryUse /* eslint-disable */ to ignore all warnings in a file. how to turn off eslint-disable no-undef in eslintrc.

What is ESLint used for in node JS?

ESLint is a JavaScript and TypeScript linting tool, that means it analyses source code and identifies possible programming problems and errors. It underlines errors in red and warnings in yellow. It is very useful to cover coding styles issues.


1 Answers

Create a .eslintrc.js in the directory of your file, and put the following contents in it:

module.exports = {     rules: {         'no-console': 'off',     }, }; 
like image 56
markasoftware Avatar answered Oct 16 '22 19:10

markasoftware