I\'m using eslint with Sublime Text 3 and I am writing gulpfile.js
.
/*eslint-env node*/
var gulp = require(\'gulp\');
gulp.task(\'default\', fu
Create a .eslintrc.js in the directory of your file, and put the following contents in it:
module.exports = {
rules: {
'no-console': 'off',
},
};
A nicer option is to make the display of console.log and debugger statements conditional based on the node environment.
rules: {
// allow console and debugger in development
'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
},
The following works with ESLint in VSCode if you want to disable the rule for just one line.
To disable the next line:
// eslint-disable-next-line no-console
console.log('hello world');
To disable the current line:
console.log('hello world'); // eslint-disable-line no-console
in my vue
project i fixed this problem like this :
vim package.json
...
"rules": {
"no-console": "off"
},
...
ps : package.json is a configfile in the vue project dir, finally the content shown like this:
{
"name": "metadata-front",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.18.0",
"vue": "^2.5.17",
"vue-router": "^3.0.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.4",
"@vue/cli-plugin-eslint": "^3.0.4",
"@vue/cli-service": "^3.0.4",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-0",
"vue-template-compiler": "^2.5.17"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {
"no-console": "off"
},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
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:
console.log(someThing); /* eslint-disable-line no-console */
... or on the next line:
/* eslint-disable-next-line no-console */
console.log(someThing);
For vue-cli 3 open package.json
and under section eslintConfig
put no-console
under rules
and restart dev server (npm run serve
or yarn serve
)
...
"eslintConfig": {
...
"rules": {
"no-console": "off"
},
...