From 6ebcc0284df05fb38db9cd0af270c0e877d7aa71 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Sun, 13 Sep 2020 22:46:43 +0200 Subject: [PATCH] correct eslint errors --- public/trivabble.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/trivabble.js b/public/trivabble.js index 7172b68..ec9f352 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -35,7 +35,7 @@ if (typeof Conf[parameterName] === "undefined") { Conf[parameterName] = defaultValue; } else if (typeof Conf[parameterName] !== typeof defaultValue) { - alert("Head's up - configuration " + parameterName + " does not have the right type. It should be a " + (typeof defaultValue) + ", it is a " + (typeof Conf[parameterName])); + myAlert("Head's up - configuration " + parameterName + " does not have the right type. It should be a " + (typeof defaultValue) + ", it is a " + (typeof Conf[parameterName])); throw new Error("Wrong type for configuration " + parameterName + ", expected " + (typeof defaultValue) + ", got " + (typeof Conf[parameterName])); } } @@ -58,8 +58,8 @@ } function getSetting(key) { - let type = undefined; - let value = undefined; + let type; + let value; /* get default value from configuration */ if (Object.prototype.hasOwnProperty.call(Conf, key)) { @@ -72,7 +72,7 @@ value = localStorage.getItem(key); /* get type from localStorage if no default is set */ - if (type === undefined) { + if (typeof type === "undefined") { if (Object.prototype.hasOwnProperty.call(localStorage, key + "_key")) { type = localStorage.getItem(key + "_type"); } else { @@ -98,7 +98,7 @@ } function setSetting(key, value) { - let type = undefined; + let type; /* try to retrieve type from configuration */ if (Object.prototype.hasOwnProperty.call(Conf, key)) { @@ -106,21 +106,19 @@ } /* try to retrieve type from localstorage */ - if (type === undefined) { + if (typeof type === "undefined") { if (Object.prototype.hasOwnProperty.call(localStorage, key)) { type = localStorage.getItem(key + "_type"); } } /* if not set type is defined from value */ - if (type === undefined) { + if (typeof type === "undefined") { type = typeof value; } /* storage value in localstorage */ - if (type !== typeof value) { - console.error("incoherent type"); - } else { + if (type === typeof value) { if (type === "object") { value = JSON.stringify(value); } @@ -137,6 +135,8 @@ } else { console.error("Unsupported type"); } + } else { + console.error("incoherent type"); } } -- 2.30.2