1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19042 from Snuffleupagus/eslint-no-console

Enable the ESLint `no-console` rule in parts of the code-base
This commit is contained in:
Tim van der Meij 2024-11-17 12:45:50 +01:00 committed by GitHub
commit 15a5e47e64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 3 deletions

View file

@ -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",
{

View file

@ -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);
}

View file

@ -166,7 +166,7 @@ class ImageManager {
}
data.refCounter = 1;
} catch (e) {
console.error(e);
warn(e);
data = null;
}
this.#cache.set(key, data);

View file

@ -84,6 +84,7 @@ class Sandbox {
[buf, this._alertOnError]
);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
} finally {
if (buf) {

View file

@ -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}`);
}
}

View file

@ -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`);
}
}