From b272d3b32fe6ef382298755f1fdabbd486faa85e Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 5 Jul 2019 12:36:15 +0100 Subject: [PATCH] Linted to satisfy new rules --- src/web/waiters/InputWaiter.mjs | 9 +++++---- src/web/waiters/OutputWaiter.mjs | 4 ++-- src/web/waiters/WorkerWaiter.mjs | 4 ++-- src/web/workers/InputWorker.mjs | 10 +++++----- src/web/workers/ZipWorker.mjs | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/web/waiters/InputWaiter.mjs b/src/web/waiters/InputWaiter.mjs index 90f52bbb..e3328d7d 100644 --- a/src/web/waiters/InputWaiter.mjs +++ b/src/web/waiters/InputWaiter.mjs @@ -219,13 +219,14 @@ class InputWaiter { handleLoaderMessage(e) { const r = e.data; - if (r.hasOwnProperty("progress") && r.hasOwnProperty("inputNum")) { + if (Object.prototype.hasOwnProperty.call(r, "progress") && + Object.prototype.hasOwnProperty.call(r, "inputNum")) { this.manager.tabs.updateInputTabProgress(r.inputNum, r.progress, 100); - } else if (r.hasOwnProperty("fileBuffer")) { + } else if (Object.prototype.hasOwnProperty.call(r, "fileBuffer")) { this.manager.tabs.updateInputTabProgress(r.inputNum, 100, 100); } - const transferable = r.hasOwnProperty("fileBuffer") ? [r.fileBuffer] : undefined; + const transferable = Object.prototype.hasOwnProperty.call(r, "fileBuffer") ? [r.fileBuffer] : undefined; this.inputWorker.postMessage({ action: "loaderWorkerMessage", data: r @@ -241,7 +242,7 @@ class InputWaiter { handleInputWorkerMessage(e) { const r = e.data; - if (!r.hasOwnProperty("action")) { + if (!("action" in r)) { log.error("A message was received from the InputWorker with no action property. Ignoring message."); return; } diff --git a/src/web/waiters/OutputWaiter.mjs b/src/web/waiters/OutputWaiter.mjs index bc0e202d..29cbc1b4 100755 --- a/src/web/waiters/OutputWaiter.mjs +++ b/src/web/waiters/OutputWaiter.mjs @@ -651,12 +651,12 @@ class OutputWaiter { */ handleZipWorkerMessage(e) { const r = e.data; - if (!r.hasOwnProperty("zippedFile")) { + if (!("zippedFile" in r)) { log.error("No zipped file was sent in the message."); this.terminateZipWorker(); return; } - if (!r.hasOwnProperty("filename")) { + if (!("filename" in r)) { log.error("No filename was sent in the message."); this.terminateZipWorker(); return; diff --git a/src/web/waiters/WorkerWaiter.mjs b/src/web/waiters/WorkerWaiter.mjs index ec2a8f64..943813c7 100644 --- a/src/web/waiters/WorkerWaiter.mjs +++ b/src/web/waiters/WorkerWaiter.mjs @@ -178,7 +178,7 @@ class WorkerWaiter { let inputNum = 0; log.debug(`Receiving ${r.action} from ChefWorker.`); - if (r.data.hasOwnProperty("inputNum")) { + if ("inputNum" in r.data) { inputNum = r.data.inputNum; } @@ -440,7 +440,7 @@ class WorkerWaiter { // Remove all breakpoints from the recipe up to progress if (nextInput.progress !== false) { for (let i = 0; i < nextInput.progress; i++) { - if (recipeConfig[i].hasOwnProperty("breakpoint")) { + if ("breakpoint" in recipeConfig[i]) { delete recipeConfig[i].breakpoint; } } diff --git a/src/web/workers/InputWorker.mjs b/src/web/workers/InputWorker.mjs index 9f3eb338..9ad420c7 100644 --- a/src/web/workers/InputWorker.mjs +++ b/src/web/workers/InputWorker.mjs @@ -30,7 +30,7 @@ self.loadingInputs = 0; */ self.addEventListener("message", function(e) { const r = e.data; - if (!r.hasOwnProperty("action")) { + if (!("action" in r)) { log.error("No action"); return; } @@ -639,11 +639,11 @@ self.loaderWorkerReady = function(workerData) { self.handleLoaderMessage = function(r) { let inputNum = 0; - if (r.hasOwnProperty("inputNum")) { + if ("inputNum" in r) { inputNum = r.inputNum; } - if (r.hasOwnProperty("error")) { + if ("error" in r) { self.updateInputProgress(r.inputNum, 0); self.updateInputStatus(r.inputNum, "error"); @@ -657,7 +657,7 @@ self.handleLoaderMessage = function(r) { return; } - if (r.hasOwnProperty("fileBuffer")) { + if ("fileBuffer" in r) { log.debug(`Input file ${inputNum} loaded.`); self.loadingInputs--; self.updateInputValue({ @@ -667,7 +667,7 @@ self.handleLoaderMessage = function(r) { const idx = self.getLoaderWorkerIdx(r.id); self.loadNextFile(idx); - } else if (r.hasOwnProperty("progress")) { + } else if ("progress" in r) { self.updateInputProgress(r); } }; diff --git a/src/web/workers/ZipWorker.mjs b/src/web/workers/ZipWorker.mjs index 58e6db19..f4c11c29 100644 --- a/src/web/workers/ZipWorker.mjs +++ b/src/web/workers/ZipWorker.mjs @@ -18,11 +18,11 @@ const Zlib = zip.Zlib; */ self.addEventListener("message", function(e) { const r = e.data; - if (!r.hasOwnProperty("outputs")) { + if (!("outputs" in r)) { log.error("No files were passed to the ZipWorker."); return; } - if (!r.hasOwnProperty("filename")) { + if (!("filename" in r)) { log.error("No filename was passed to the ZipWorker"); return; }