WebUI: Disallow console.log() statements with ESlint's no-console check.
console.log() statements are in the vast majority of cases spam that is
forgotten to be removed after done with debugging. ESLint can
automatically detect such statements at PRESUBMIT time and save code
review time.
Turning on the no-console ESLint check by default in the top-level
.eslintrc.js configuration.
Existing violations have been dealt as follows:
- Removed console.log() when it was obvious it was just forgotten.
- Changed to console.info() or console.warn() when it was obvious it
was intentional.
- Turned off checks with eslint-disable or eslint-disable-next-line
comments in a few files.
- Turned off checks using .eslintrc.js in a few folders
(ui/file_manager/, ash/webui/, c/b/r/chromeos/accessibility/) that
have lot of violations. The OWNERS of such folders should decide
separately if they prefer to enable this check and address existing
violations.
Bug: 720034
Change-Id: Ief1aceaf17aa0cc3f29c9adf9b0a7554405814fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3549216
Reviewed-by: Rebekah Potter <[email protected]>
Reviewed-by: Luciano Pacheco <[email protected]>
Reviewed-by: Kyle Horimoto <[email protected]>
Commit-Queue: Demetrios Papadopoulos <[email protected]>
Cr-Commit-Position: refs/heads/main@{#985873}
diff --git a/.eslintrc.js b/.eslintrc.js
index f2f6fbd..fbde0a1 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -16,6 +16,7 @@
// Enabled checks.
'brace-style': ['error', '1tbs'],
'curly': ['error', 'multi-line', 'consistent'],
+ 'no-console': ['error', {allow: ['info', 'warn', 'error', 'assert']}],
'no-extra-boolean-cast': 'error',
'no-extra-semi': 'error',
'no-new-wrappers': 'error',