Enabling ESLint rule no-console on production code

376 views
Skip to first unread message

Mark Banner

unread,
Mar 5, 2024, 12:28:47 PMMar 5
to firefox-dev list, dev-pl...@mozilla.org

I have just triggered landing for the ESLint rule no-console on our production code.

As the name suggests, this disallows the use of `console.*` in JavaScript code and will reject uses. However, for our production code, we will allow:

  • console.error
  • console.warn
  • console.createInstance

We are enabling this so that we are more intentional in our logging, and in reducing unnecessary console logging. This should also help to reduce accidental cases of committing redundant console.log statements.

The error and warn functions can still be used for appropriate exception situations.

For general debug logging that should be landed in the tree, please use a console instance created by console.createInstance, with an appropriate default level of logging.


We have currently disabled the rule on files that are using the disallowed functions. We will address them over time.

For test code we have not made a decision yet - there are some inconsistencies in test logging between info() and console.* that we'd like to look.

Mark.

Reply all
Reply to author
Forward
0 new messages