diff --git a/eslint.config.mjs b/eslint.config.mjs index e0c2b8b014e31..16bba1b99fbc5 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -313,6 +313,12 @@ export default [ "template-curly-spacing": ["error", "never"], }, }, + { + files: jsFiles("src"), + rules: { + "no-console": "error", + }, + }, /* ======================================================================== *\ Test-specific rules @@ -354,11 +360,13 @@ export default [ files: jsFiles("test/unit"), rules: { "import/no-unresolved": ["error", { ignore: ["pdfjs/"] }], + "no-console": ["error", { allow: ["warn", "error"] }], }, }, { files: jsFiles("test/integration"), rules: { + "no-console": ["error", { allow: ["warn", "error"] }], "no-restricted-syntax": [ "error", { diff --git a/src/display/display_utils.js b/src/display/display_utils.js index 218a0f33bdd03..16fc7093e8238 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -413,6 +413,7 @@ function noContextMenu(e) { // Deprecated API function -- display regardless of the `verbosity` setting. function deprecated(details) { + // eslint-disable-next-line no-console console.log("Deprecated API usage: " + details); } diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 9d4fd87476720..40b96897babba 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -166,7 +166,7 @@ class ImageManager { } data.refCounter = 1; } catch (e) { - console.error(e); + warn(e); data = null; } this.#cache.set(key, data); diff --git a/src/pdf.sandbox.js b/src/pdf.sandbox.js index adced961f5426..79cb05ec1afff 100644 --- a/src/pdf.sandbox.js +++ b/src/pdf.sandbox.js @@ -84,6 +84,7 @@ class Sandbox { [buf, this._alertOnError] ); } catch (error) { + // eslint-disable-next-line no-console console.error(error); } finally { if (buf) { diff --git a/src/shared/util.js b/src/shared/util.js index 60ce504889c5b..c4752522fcde9 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -363,6 +363,7 @@ function getVerbosityLevel() { // end users. function info(msg) { if (verbosity >= VerbosityLevel.INFOS) { + // eslint-disable-next-line no-console console.log(`Info: ${msg}`); } } @@ -370,6 +371,7 @@ function info(msg) { // Non-fatal warnings. function warn(msg) { if (verbosity >= VerbosityLevel.WARNINGS) { + // eslint-disable-next-line no-console console.log(`Warning: ${msg}`); } } diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 7e6ec548b0f22..84c74ed43541f 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -309,9 +309,11 @@ async function waitForEvent({ const success = await awaitPromise(handle); if (success === null) { - console.log(`waitForEvent: ${eventName} didn't trigger within the timeout`); + console.warn( + `waitForEvent: ${eventName} didn't trigger within the timeout` + ); } else if (!success) { - console.log(`waitForEvent: ${eventName} triggered, but validation failed`); + console.warn(`waitForEvent: ${eventName} triggered, but validation failed`); } }