Change the no-console rule value in eslint:recommended
See original GitHub issueThe version of ESLint you are using.
5.12.0
The problem you want to solve.
When using eslint:recommended
in a node environment, eslint records any usage of console as an error even though not using console in Node.js is not a best practice.
Your take on the correct solution to problem.
This problem was already discussed in https://github.com/eslint/eslint/issues/8544 and two possible solutions came out of that discussion:
- Remove/disable the no-console rule from
eslint:recommended
- Change the no-console rule to allow info, warn, and error.
I think the upside is much higher than the downside in either solution since writing to the console is a valid use case in Node.js and the easiest way to do that is with console. I think option 1 is preferable since Node.js has more console methods than just info, warn, and error, so it would be easier/less complex from a maintenance standpoint.
Are you willing to submit a pull request to implement this change?
Yes. I’m not sure where this rule lives but I can work on it.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
I don’t think you can argue using console in Node.js is a bad thing in general. As to the use case you mentioned, that is a specialized use case, not the base. If you want to discourage the use of console because you are using a specialized logging library in your app then you can still set
no-console
to whatever you like but it should not be the default setting. No one should have to install a 3rd-party library just to print to the console, especially when the library uses the same underlying API that console uses.This is one of those rules where what’s best for the browser (removing references to
console
) is not what’s best for Node.js (allowingconsole
), so I’d like to keep those two use cases in mind.Another possible option is split
eslint:recommended
into two: one that is best used for browsers and one that is best used for Node.js.Any change to
eslint:recommended
is breaking, though, so would have to wait until the next major release.