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.

no-console doesn't work to disable all console statements without an empty "allow" parameter on it.

See original GitHub issue

ESlint version: 7.6.0

Expected to work as follows: no-console: "error"

Actually works only when done as follows: "no-console": [ "error", { "allow": [""] // ¯\_(ツ)_/¯ } ],

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

mdjermanoviccommented, Feb 18, 2021

@DanBoSlice thanks for the details!

The rule itself seems to be working fine: Online Demo

The behavior you’re seeing is due to how overriding rules’ configuration works.

In your example, one of the configurations you’re extending from, plugin:@angular-eslint/ng-cli-compat, enables no-console rule and configures it to allow .log and other methods here.

"no-console": [
        "allow": [

If you reconfigure the rule in your main config file (derived config) by specifying only severity, ESLint will keep the options from the extended configuration (base config). This behavior is explained in Extending Configuration Files:

change an inherited rule’s severity without changing its options:

  • Base config: “eqeqeq”: [“error”, “allow-null”]
  • Derived config: “eqeqeq”: “warn”
  • Resulting actual config: “eqeqeq”: [“warn”, “allow-null”]

So, in your example, "no-console": "error" has no effect as it overrides just severity but not the options. You can double-check the resulting configuration for a file with the –print-config CLI option.

The solution is to specify options in the main config. "no-console": ["error", {"allow": [""]}] or just "no-console": ["error", {}] should do the work. That would entirely override the configuration for no-console from the extended config.

chrispinzarucommented, Mar 9, 2021

Thank you, now I understand the mistake, thanks for your time

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to quickly and conveniently disable all console.log ...
Redefine the console.log function in your script. console.log = function() {}. That's it, no more messages to console. EDIT: Expanding on Cide's idea....
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 >
Global Flags - Rclone
Global Flags. This describes the global flags available to every rclone command split into two groups, non backend and backend flags.
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Windows PowerShell Cheat Sheet
(The pure PS console does not allow shrinking of width). ... Any cmdlet parameter (aka flag) can be truncated to the extent that...
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