How to allow console.log() in .eslint?
I tried
"rules": {
"comma-dangle": 0,
"no-console": 2
}
but don't work.
no-console would need to be set to 0 to disable it. See http://eslint.org/docs/rules/no-console.html
http://eslint.org/docs/user-guide/getting-started#configuration
"off" or 0 - turn the rule off
"warn" or 1 - turn the rule on as a warning (doesn鈥檛 affect exit code)
"error" or 2 - turn the rule on as an error (exit code will be 1)
@xgqfrms-gildata I did
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"no-console": 1,
"max-line-length": [true, {"limit": 80, "ignore-pattern": "^import"}],
"indent": [true, 2],
"quotemark": [true, "single", "avoid-escape", "avoid-template"],
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
"prefer-const": true,
"no-duplicate-switch-case": true,
"interface-name": [true, "never-prefix"],
"max-classes-per-file": false,
"no-unused-variable": true,
"object-literal-sort-keys": false
},
"rulesDirectory": []
}
and a npm clean and then run but I had Calls to 'console.warn' are not allowed anyways...
...so it seems it works using
{
"no-console": false
}
@loretoparisi that might be coming from tslint, which is an entirely different tool than eslint.
For those looking for the exact solution:
"rules": {
...
"no-console": 0,
...
}
For those looking for the exact solution:
"rules": { ... "no-console": 0, ... }It does not appear to be an _exact_ solution. I tried
no-consolewith both the defaultoffsetting and 0. Neither hide the linter error on log statements
I'm still searching for a fix. It's not a blocker for my work. Just annoying because 1. it's a false positive, and 2. apparently simple solutions like this one don't work.
@mjstelly it certainly works; often editors have to be restarted for any config change to be picked up, and you might have other configs applying to that file.
I don't doubt that it works for some. I did restart and retest. So, that's not the issue. But it's possible that something else may be overriding it. I don't have any idea at this point. I'll have to revisit the issue when I get time.
I've got same problem, did you fix it somehow?
@mstosio No, I have not. Since it wasn't a blocker, I didn't have time to pursue it. It's just annoying AF.
Make sure your editor is configured to use a local eslint only (if you have a global eslint, remove it).
@ljharb What you mean about global and local eslint ? Could you explain ?
@cyb3rsalih npm install -g eslint vs npm install eslint; you never want the former.
adding extends airbnb solve this problem, but i dont now how
{
"env": {
"node": true,
"browser": true,
"es6": true
},
"parser": "babel-eslint",
"extends": [
"airbnb",
"plugin:import/errors",
"plugin:import/warnings"
]
}
_This is not just an issue with editor/IDE state._ Setting no_console to "off" or 0 does on work using a locally installed eslint module in the following environment, _from the command line_...
bash; 5.0.9(1)-release (x86_64-apple-darwin18.6.0)
node; v12.9.1
eslint; v6.3.0
env:
browser: false
commonjs: true
es6: true
extends: 'eslint:recommended'
globals:
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaVersion: 2018
rules : BLAH, BLAH...
@tbrophy in that example, you鈥檙e not using the airbnb config, so you may want to file an issue on eslint itself.
Oh yea, _riiiight_. That's what I get for coding with sunglasses on.
during the "hello world !" program in (JavaScript) BRACKETS I am unable to run it and it was showing error that...... (console) was used before it was defined..... please anybody help me out!!!!! It's really urgent.
Not sure what program that is, but you do have to set the browser and/or node envs with the airbnb config for it to work properly.
Most helpful comment
eslint 0, 1, 2 means
http://eslint.org/docs/user-guide/getting-started#configuration