From d5acbbccd3fd499036711556778b6dcd20f8b062 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 15 Oct 2023 11:29:53 +0200 Subject: [PATCH] Update the ESLint `globals` list (PR 17055 follow-up) Given that we only use standard `import`/`export` statements now, after recent PRs, the "exports" global is unused. Instead we add "__non_webpack_import__" to the `globals` to avoid having to sprinkle disable statements throughout the code. Finally, the way that `globals` are defined has changed in ESLint and we should thus explicitly specify them as "readonly"; please find additional details at https://eslint.org/docs/latest/use/configure/language-options#specifying-globals --- .eslintrc | 4 ++-- src/display/api.js | 2 +- src/display/node_stream.js | 1 - src/display/node_utils.js | 1 - test/unit/node_stream_spec.js | 1 - test/unit/test_utils.js | 1 - web/app.js | 4 ++-- web/generic_scripting.js | 2 +- 8 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.eslintrc b/.eslintrc index 3e5732b18..4a05d00ce 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,8 +26,8 @@ }, "globals": { - "PDFJSDev": false, - "exports": false, + "PDFJSDev": "readonly", + "__non_webpack_import__": "readonly", }, "rules": { diff --git a/src/display/api.js b/src/display/api.js index 96f1ee7ea..4cd74a301 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2306,7 +2306,7 @@ class PDFWorker { const worker = typeof PDFJSDev === "undefined" ? await import("pdfjs/pdf.worker.js") - : await __non_webpack_import__(this.workerSrc); // eslint-disable-line no-undef + : await __non_webpack_import__(this.workerSrc); return worker.WorkerMessageHandler; }; diff --git a/src/display/node_stream.js b/src/display/node_stream.js index ea182fff3..185557282 100644 --- a/src/display/node_stream.js +++ b/src/display/node_stream.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals __non_webpack_import__ */ import { AbortException, diff --git a/src/display/node_utils.js b/src/display/node_utils.js index c436a6435..643d3f4d3 100644 --- a/src/display/node_utils.js +++ b/src/display/node_utils.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals __non_webpack_import__ */ import { BaseCanvasFactory, diff --git a/test/unit/node_stream_spec.js b/test/unit/node_stream_spec.js index a538bf1ab..919fc63dd 100644 --- a/test/unit/node_stream_spec.js +++ b/test/unit/node_stream_spec.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals __non_webpack_import__ */ import { AbortException, isNodeJS } from "../../src/shared/util.js"; import { PDFNodeStream } from "../../src/display/node_stream.js"; diff --git a/test/unit/test_utils.js b/test/unit/test_utils.js index 8ff955c2b..111c05006 100644 --- a/test/unit/test_utils.js +++ b/test/unit/test_utils.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals __non_webpack_import__ */ import { NullStream, StringStream } from "../../src/core/stream.js"; import { Page, PDFDocument } from "../../src/core/document.js"; diff --git a/web/app.js b/web/app.js index 876e23490..2749168be 100644 --- a/web/app.js +++ b/web/app.js @@ -2268,7 +2268,7 @@ async function loadFakeWorker() { globalThis.pdfjsWorker = await import("pdfjs/pdf.worker.js"); return; } - await __non_webpack_import__(PDFWorker.workerSrc); // eslint-disable-line no-undef + await __non_webpack_import__(PDFWorker.workerSrc); } async function loadPDFBug(self) { @@ -2276,7 +2276,7 @@ async function loadPDFBug(self) { const { PDFBug } = typeof PDFJSDev === "undefined" ? await import(debuggerScriptPath) // eslint-disable-line no-unsanitized/method - : await __non_webpack_import__(debuggerScriptPath); // eslint-disable-line no-undef + : await __non_webpack_import__(debuggerScriptPath); self._PDFBug = PDFBug; } diff --git a/web/generic_scripting.js b/web/generic_scripting.js index 8b7f33305..600fb4905 100644 --- a/web/generic_scripting.js +++ b/web/generic_scripting.js @@ -45,7 +45,7 @@ class GenericScripting { const sandbox = typeof PDFJSDev === "undefined" ? import(sandboxBundleSrc) // eslint-disable-line no-unsanitized/method - : __non_webpack_import__(sandboxBundleSrc); // eslint-disable-line no-undef + : __non_webpack_import__(sandboxBundleSrc); sandbox .then(pdfjsSandbox => { resolve(pdfjsSandbox.QuickJSSandbox());