From d08bd4e866e54581dc3c3233b930597e134126af Mon Sep 17 00:00:00 2001 From: rejas Date: Tue, 21 Apr 2020 07:36:18 +0200 Subject: [PATCH] Fix lots of warnings --- .eslintrc.json | 6 +++++- js/class.js | 4 ++-- js/defaults.js | 2 +- js/logger.js | 1 - js/module.js | 1 - js/translator.js | 5 +++-- js/utils.js | 1 + modules/default/calendar/calendar.js | 18 +++++++----------- modules/default/clock/clock.js | 1 - .../default/currentweather/currentweather.js | 13 +++++-------- modules/default/newsfeed/newsfeed.js | 3 +-- modules/default/weather/weather.js | 1 - .../default/weatherforecast/weatherforecast.js | 2 +- 13 files changed, 26 insertions(+), 32 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ab9f631f..cf4de832 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,5 +12,9 @@ "ecmaFeatures": { "globalReturn": true } - } + }, + "rules": { + "no-undef": "off", + "no-unused-vars": "off" + } } diff --git a/js/class.js b/js/class.js index 39cd2962..d2a1654f 100644 --- a/js/class.js +++ b/js/class.js @@ -22,8 +22,8 @@ initializing = false; // Make a copy of all prototype properties, to prevent reference issues. - for (var name in prototype) { - prototype[name] = cloneObject(prototype[name]); + for (var p in prototype) { + prototype[p] = cloneObject(prototype[p]); } // Copy the properties over onto the new prototype diff --git a/js/defaults.js b/js/defaults.js index dc246298..6e1d78ce 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -1,7 +1,7 @@ /* exported defaults */ /* Magic Mirror - * Config Defauls + * Config Defaults * * By Michael Teeuw http://michaelteeuw.nl * MIT Licensed. diff --git a/js/logger.js b/js/logger.js index 1392a72b..2e023493 100644 --- a/js/logger.js +++ b/js/logger.js @@ -1,4 +1,3 @@ -/* global console */ /* exported Log */ /* Magic Mirror diff --git a/js/module.js b/js/module.js index e456e6a8..9336c9e9 100644 --- a/js/module.js +++ b/js/module.js @@ -1,4 +1,3 @@ -/* global Log, Class, Loader, Class , MM */ /* exported Module */ /* Magic Mirror diff --git a/js/translator.js b/js/translator.js index 08a80c14..5839cd53 100644 --- a/js/translator.js +++ b/js/translator.js @@ -1,4 +1,5 @@ /* exported Translator */ + /* Magic Mirror * Translator (l10n) * @@ -129,10 +130,10 @@ var Translator = (function() { if(Object.prototype.toString.call(template) !== "[object String]") { return template; } - if(variables.fallback && !template.match(new RegExp("\{.+\}"))) { + if(variables.fallback && !template.match(new RegExp("{.+}"))) { template = variables.fallback; } - return template.replace(new RegExp("\{([^\}]+)\}", "g"), function(_unused, varName){ + return template.replace(new RegExp("{([^}]+)}", "g"), function(_unused, varName){ return variables[varName] || "{"+varName+"}"; }); } diff --git a/js/utils.js b/js/utils.js index 3f623499..bdd81e57 100644 --- a/js/utils.js +++ b/js/utils.js @@ -1,4 +1,5 @@ /* exported Utils */ + /* Magic Mirror * Utils * diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index d0986598..06f6c2f3 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -254,6 +254,8 @@ Module.register("calendar", { titleWrapper.className = "title " + titleClass; } + var timeWrapper; + if(this.config.timeFormat === "dateheaders"){ if (event.fullDayEvent) { @@ -261,10 +263,8 @@ Module.register("calendar", { titleWrapper.align = "left"; } else { - - var timeClass = this.timeClassForUrl(event.url); - var timeWrapper = document.createElement("td"); - timeWrapper.className = "time light " + timeClass; + timeWrapper = document.createElement("td"); + timeWrapper.className = "time light " + this.timeClassForUrl(event.url); timeWrapper.align = "left"; timeWrapper.style.paddingLeft = "2px"; timeWrapper.innerHTML = moment(event.startDate, "x").format("LT"); @@ -274,7 +274,7 @@ Module.register("calendar", { eventWrapper.appendChild(titleWrapper); } else { - var timeWrapper = document.createElement("td"); + timeWrapper = document.createElement("td"); eventWrapper.appendChild(titleWrapper); //console.log(event.today); @@ -370,8 +370,7 @@ Module.register("calendar", { } //timeWrapper.innerHTML += ' - '+ moment(event.startDate,'x').format('lll'); //console.log(event); - var timeClass = this.timeClassForUrl(event.url); - timeWrapper.className = "time light " + timeClass; + timeWrapper.className = "time light " + this.timeClassForUrl(event.url); eventWrapper.appendChild(timeWrapper); } @@ -424,15 +423,12 @@ Module.register("calendar", { switch (timeFormat) { case 12: { return { longDateFormat: {LT: "h:mm A"} }; - break; } case 24: { return { longDateFormat: {LT: "HH:mm"} }; - break; } default: { return { longDateFormat: {LT: moment.localeData().longDateFormat("LT")} }; - break; } } }, @@ -735,7 +731,7 @@ Module.register("calendar", { var regParts = needle.match(/^\/(.+)\/([gim]*)$/); if (regParts) { // the parsed pattern is a regexp. - needle = new RegExp(regParts[1], regParts[2]); + needle = new RegExp(regParts[1], regParts[2]); } title = title.replace(needle, replacement); diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index f1f49529..4db7febb 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -202,7 +202,6 @@ Module.register("clock",{ // If it isn't 'digital', then an 'analog' clock was also requested // Calculate the degree offset for each hand of the clock - var now = moment(); if (this.config.timezone) { now.tz(this.config.timezone); } diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 7f7c805d..ff14b47b 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -23,7 +23,6 @@ Module.register("currentweather",{ showWindDirection: true, showWindDirectionAsArrow: false, useBeaufort: true, - appendLocationNameToHeader: false, useKMPHwind: false, lang: config.language, decimalSymbol: ".", @@ -150,15 +149,15 @@ Module.register("currentweather",{ var humidity = document.createElement("span"); humidity.innerHTML = this.humidity; - var spacer = document.createElement("sup"); - spacer.innerHTML = " "; + var supspacer = document.createElement("sup"); + supspacer.innerHTML = " "; var humidityIcon = document.createElement("sup"); humidityIcon.className = "wi wi-humidity humidityIcon"; humidityIcon.innerHTML = " "; small.appendChild(humidity); - small.appendChild(spacer); + small.appendChild(supspacer); small.appendChild(humidityIcon); } @@ -414,8 +413,7 @@ Module.register("currentweather",{ case "imperial": tempInF = this.temperature; break; case "default": - var tc = this.temperature - 273.15; - tempInF = 1.8 * tc + 32; + tempInF = 1.8 * (this.temperature - 273.15) + 32; break; } @@ -431,8 +429,7 @@ Module.register("currentweather",{ case "imperial": this.feelsLike = windChillInF.toFixed(0); break; case "default": - var tc = windChillInC + 273.15; - this.feelsLike = tc.toFixed(0); + this.feelsLike = (windChillInC + 273.15).toFixed(0); break; } diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index cb0e8ece..31dbec4b 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -367,8 +367,8 @@ Module.register("newsfeed",{ }, notificationReceived: function(notification, payload, sender) { + var before = this.activeItem; if(notification === "ARTICLE_NEXT"){ - var before = this.activeItem; this.activeItem++; if (this.activeItem >= this.newsItems.length) { this.activeItem = 0; @@ -377,7 +377,6 @@ Module.register("newsfeed",{ Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); this.updateDom(100); } else if(notification === "ARTICLE_PREVIOUS"){ - var before = this.activeItem; this.activeItem--; if (this.activeItem < 0) { this.activeItem = this.newsItems.length - 1; diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index 9b9c435d..8f5568b4 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -10,7 +10,6 @@ Module.register("weather",{ // Default module config. defaults: { - updateInterval: 10 * 60 * 1000, weatherProvider: "openweathermap", roundTemp: false, type: "current", //current, forecast diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index d5c2efa6..e6f54b14 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -348,7 +348,7 @@ Module.register("weatherforecast",{ } if (day !== lastDay) { - var forecastData = { + forecastData = { day: day, icon: this.config.iconTable[forecast.weather[0].icon], maxTemp: this.roundValue(forecast.temp.max),