-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sub-option to allow console.warn and friends in no-console #2621
Comments
The rule was create to guard any output to console in production code, as it's considered a bad practice. There is no real difference between |
Agree with @ilyavolodin . console.error("hi") // eslint-disable-line no-console |
The problem is that my project uses Having to to use comment every time I use It's pretty common for a browser extension to dump indexDB error to the console to help users report bugs for example. |
My thought would be to create a custom rule for your project to do this. I don't think it would be something that we'd want to have globally, but it would be really easy to add this exception for your project. Do you want some help setting it up? |
That would be great. Thanks. Does the doc cover it? |
Take a look at the existing no-console rule. You can add the following in order to make it only warn on if (node.object.name === "console" && node.property.name === "log") {
More info here: More advanced docs: Good luck! |
We have a whole section in the documentation dedicated to rule creation here: http://eslint.org/docs/developer-guide/working-with-rules |
@hgl feel free to join the chat room at https://gitter.im/eslint/eslint if you get stuck |
Thanks guys. And thank you @xjamundx for taking the time writing the step by step instructions. I will try it out. |
I agree with @hgl that there should be options that you can allow Of course I also do respect the choice of the main contributors if that is set in stone. |
For what it's worth, I published a plugin that just checks for |
👍 Thanks for reporting back! |
+1 for no-console-log because, console.log cannot be used in production - its almost always developer, who forger remove debugger code. But console.error and .warn can be used, and it used in production. |
+1 for configuring which ones fail |
console.warn
andconsole.error
are pretty useful to help users report errors even in production code.I wonder if it makes sense to add a sub-option to only report error on using
console.log
, which is mainly used for development debugging?The text was updated successfully, but these errors were encountered: