Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change the no-console rule value in eslint:recommended

See original GitHub issue

The version of ESLint you are using.


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 and two possible solutions came out of that discussion:

  1. Remove/disable the no-console rule from eslint:recommended
  2. 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

ianwaltercommented, Jan 17, 2019

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.

nzakascommented, Jan 15, 2019

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 (allowing console), 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable "unexpected console statement" in Node.js ...
Create a .eslintrc.js in the directory of your file, and put the following contents in it: module.exports = { rules: { 'no-console': 'off',...
Read more >
no-console - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint/eslint - Gitter
Hello, I was wondering how come the no-console rule added from eslint:recommended is still enabled when env.node = true?
Read more >
How to use ESLint with TypeScript | Khalil Stemmler
We want to add the no-console rule, so here is an example of how we can make the linter ... "plugin:@typescript-eslint/eslint-recommended", ...
Read more >
Configuring ESLint - ESLint - Pluggable JavaScript linter
To change a rule setting, you must set the rule ID equal to one of these values: ... An extends property value "eslint:recommended"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found