From 5c08bde0faac04ecb68793cb5d0ef39faa278d50 Mon Sep 17 00:00:00 2001 From: rejas Date: Wed, 5 Jun 2019 09:32:10 +0200 Subject: [PATCH] More == -> === and != -> !== fixes --- js/class.js | 4 ++-- js/main.js | 2 +- js/module.js | 2 +- modules/default/alert/alert.js | 4 ++-- modules/default/calendar/calendar.js | 9 +++------ modules/default/calendar/calendarfetcher.js | 11 ++++------- modules/default/calendar/vendor/ical.js/test/test.js | 4 ++-- modules/default/clock/clock.js | 4 ++-- modules/default/compliments/compliments.js | 6 +++--- .../default/updatenotification/updatenotification.js | 5 ++--- modules/default/weather/current.njk | 4 ++-- modules/default/weather/providers/openweathermap.js | 6 +++--- modules/default/weatherforecast/weatherforecast.js | 2 +- tests/e2e/fonts.js | 2 +- 14 files changed, 29 insertions(+), 36 deletions(-) diff --git a/js/class.js b/js/class.js index ceccc6f1..947ffb35 100644 --- a/js/class.js +++ b/js/class.js @@ -29,8 +29,8 @@ // Copy the properties over onto the new prototype for (var name in prop) { // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function (name, fn) { + prototype[name] = typeof prop[name] === "function" && + typeof _super[name] === "function" && fnTest.test(prop[name]) ? (function (name, fn) { return function () { var tmp = this._super; diff --git a/js/main.js b/js/main.js index f16f384b..3d42732e 100644 --- a/js/main.js +++ b/js/main.js @@ -557,7 +557,7 @@ var MM = (function() { })(); // Add polyfill for Object.assign. -if (typeof Object.assign != "function") { +if (typeof Object.assign !== "function") { (function() { Object.assign = function(target) { "use strict"; diff --git a/js/module.js b/js/module.js index efd84418..8ddcda7d 100644 --- a/js/module.js +++ b/js/module.js @@ -164,7 +164,7 @@ var Module = Class.extend({ * @returns Nunjucks Environment */ nunjucksEnvironment: function() { - if (this._nunjucksEnvironment != null) { + if (this._nunjucksEnvironment !== null) { return this._nunjucksEnvironment; } diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index 0f47bc3f..b787ba57 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -35,13 +35,13 @@ Module.register("alert",{ }; }, show_notification: function(message) { - if (this.config.effect == "slide") {this.config.effect = this.config.effect + "-" + this.config.position;} + if (this.config.effect === "slide") {this.config.effect = this.config.effect + "-" + this.config.position;} msg = ""; if (message.title) { msg += "" + message.title + ""; } if (message.message){ - if (msg != ""){ + if (msg !== ""){ msg+= "
"; } msg += "" + message.message + ""; diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 2eac086e..8e2e4f85 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -224,7 +224,7 @@ Module.register("calendar", { symbolWrapper.appendChild(symbol); } eventWrapper.appendChild(symbolWrapper); - }else if(this.config.timeFormat === "dateheaders"){ + } else if(this.config.timeFormat === "dateheaders"){ var blankCell = document.createElement("td"); blankCell.innerHTML = "   "; eventWrapper.appendChild(blankCell); @@ -261,7 +261,7 @@ Module.register("calendar", { titleWrapper.colSpan = "2"; titleWrapper.align = "left"; - }else{ + } else { var timeClass = this.timeClassForUrl(event.url); var timeWrapper = document.createElement("td"); @@ -274,7 +274,7 @@ Module.register("calendar", { } eventWrapper.appendChild(titleWrapper); - }else{ + } else { var timeWrapper = document.createElement("td"); eventWrapper.appendChild(titleWrapper); @@ -530,7 +530,6 @@ Module.register("calendar", { return events.slice(0, this.config.maximumEntries); }, - listContainsEvent: function(eventList, event){ for(var evt of eventList){ if(evt.title === event.title && parseInt(evt.startDate) === parseInt(event.startDate)){ @@ -538,7 +537,6 @@ Module.register("calendar", { } } return false; - }, /* createEventList(url) @@ -718,7 +716,6 @@ Module.register("calendar", { * Capitalize the first letter of a string * Return capitalized string */ - capFirst: function (string) { return string.charAt(0).toUpperCase() + string.slice(1); }, diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 3a30aea2..882577bc 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -39,7 +39,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri bearer: auth.pass } - }else{ + } else { opts.auth = { user: auth.user, pass: auth.pass @@ -47,7 +47,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri if(auth.method === "digest"){ opts.auth.sendImmediately = false; - }else{ + } else { opts.auth.sendImmediately = true; } } @@ -107,7 +107,6 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri } } - // calculate the duration f the event for use with recurring events. var duration = parseInt(endDate.format("x")) - parseInt(startDate.format("x")); @@ -176,7 +175,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri var geo = event.geo || false; var description = event.description || false; - if (typeof event.rrule != "undefined" && event.rrule != null && !isFacebookBirthday) { + if (typeof event.rrule !== undefined && event.rrule !== null && !isFacebookBirthday) { var rule = event.rrule; // can cause problems with e.g. birthdays before 1900 @@ -341,7 +340,7 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri } else { return title.includes(filter); } - } + }; /* public methods */ @@ -395,8 +394,6 @@ var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntri this.events = function() { return events; }; - }; - module.exports = CalendarFetcher; diff --git a/modules/default/calendar/vendor/ical.js/test/test.js b/modules/default/calendar/vendor/ical.js/test/test.js index 041a4a13..55616914 100644 --- a/modules/default/calendar/vendor/ical.js/test/test.js +++ b/modules/default/calendar/vendor/ical.js/test/test.js @@ -214,7 +214,7 @@ vows.describe('node-ical').addBatch({ , 'event with rrule' :{ topic: function(events){ return _.select(_.values(events), function(x){ - return x.summary == "foobarTV broadcast starts" + return x.summary === "foobarTV broadcast starts" })[0]; } , "Has an RRULE": function(topic){ @@ -272,7 +272,7 @@ vows.describe('node-ical').addBatch({ }, 'grabbing custom properties': { topic: function(topic) { - + } } }, diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index e4942076..5b796dcf 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -136,7 +136,7 @@ Module.register("clock",{ clockCircle.style.width = this.config.analogSize; clockCircle.style.height = this.config.analogSize; - if (this.config.analogFace != "" && this.config.analogFace != "simple" && this.config.analogFace != "none") { + if (this.config.analogFace !== "" && this.config.analogFace !== "simple" && this.config.analogFace !== "none") { clockCircle.style.background = "url("+ this.data.path + "faces/" + this.config.analogFace + ".svg)"; clockCircle.style.backgroundSize = "100%"; @@ -144,7 +144,7 @@ Module.register("clock",{ // clockCircle.style.border = "1px solid black"; clockCircle.style.border = "rgba(0, 0, 0, 0.1)"; //Updated fix for Issue 611 where non-black backgrounds are used - } else if (this.config.analogFace != "none") { + } else if (this.config.analogFace !== "none") { clockCircle.style.border = "2px solid white"; } var clockFace = document.createElement("div"); diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index bfa85879..0c944f63 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -54,7 +54,7 @@ Module.register("compliments", { this.lastComplimentIndex = -1; var self = this; - if (this.config.remoteFile != null) { + if (this.config.remoteFile !== null) { this.complimentFile(function(response) { self.config.compliments = JSON.parse(response); self.updateDom(); @@ -134,7 +134,7 @@ Module.register("compliments", { xobj.overrideMimeType("application/json"); xobj.open("GET", path, true); xobj.onreadystatechange = function() { - if (xobj.readyState == 4 && xobj.status == "200") { + if (xobj.readyState === 4 && xobj.status === 200) { callback(xobj.responseText); } }; @@ -194,7 +194,7 @@ Module.register("compliments", { // Override notification handler. notificationReceived: function(notification, payload, sender) { - if (notification == "CURRENTWEATHER_DATA") { + if (notification === "CURRENTWEATHER_DATA") { this.setCurrentWeatherType(payload.data); } }, diff --git a/modules/default/updatenotification/updatenotification.js b/modules/default/updatenotification/updatenotification.js index e3e55fc5..14ed7c64 100644 --- a/modules/default/updatenotification/updatenotification.js +++ b/modules/default/updatenotification/updatenotification.js @@ -8,7 +8,6 @@ Module.register("updatenotification", { start: function () { Log.log("Start updatenotification"); - }, notificationReceived: function (notification, payload, sender) { @@ -58,14 +57,14 @@ Module.register("updatenotification", { icon.innerHTML = " "; message.appendChild(icon); - var updateInfoKeyName = this.status.behind == 1 ? "UPDATE_INFO_SINGLE" : "UPDATE_INFO_MULTIPLE"; + var updateInfoKeyName = this.status.behind === 1 ? "UPDATE_INFO_SINGLE" : "UPDATE_INFO_MULTIPLE"; var subtextHtml = this.translate(updateInfoKeyName, { COMMIT_COUNT: this.status.behind, BRANCH_NAME: this.status.current }); var text = document.createElement("span"); - if (this.status.module == "default") { + if (this.status.module === "default") { text.innerHTML = this.translate("UPDATE_NOTIFICATION"); subtextHtml = this.diffLink(subtextHtml); } else { diff --git a/modules/default/weather/current.njk b/modules/default/weather/current.njk index 64d22e7b..718843a8 100644 --- a/modules/default/weather/current.njk +++ b/modules/default/weather/current.njk @@ -9,7 +9,7 @@ {{ current.windSpeed | round }} {% endif %} {% if config.showWindDirection %} - + {% if config.showWindDirectionAsArrow %} {% else %} @@ -24,7 +24,7 @@ {% endif %} - {% if current.nextSunAction() == "sunset" %} + {% if current.nextSunAction() === "sunset" %} {{ current.sunset | formatTime }} {% else %} {{ current.sunrise | formatTime }} diff --git a/modules/default/weather/providers/openweathermap.js b/modules/default/weather/providers/openweathermap.js index f7fe0edc..226e13f7 100644 --- a/modules/default/weather/providers/openweathermap.js +++ b/modules/default/weather/providers/openweathermap.js @@ -86,9 +86,9 @@ WeatherProvider.register("openweathermap", { */ generateWeatherObjectsFromForecast(forecasts) { - if (this.config.weatherEndpoint == "/forecast") { + if (this.config.weatherEndpoint === "/forecast") { return this.fetchForecastHourly(forecasts); - } else if (this.config.weatherEndpoint == "/forecast/daily") { + } else if (this.config.weatherEndpoint === "/forecast/daily") { return this.fetchForecastDaily(forecasts); } // if weatherEndpoint does not match forecast or forecast/daily, what should be returned? @@ -140,7 +140,7 @@ WeatherProvider.register("openweathermap", { weather.weatherType = this.convertWeatherType(forecast.weather[0].icon); } - + if (moment(forecast.dt, "X").format("H") >= 8 && moment(forecast.dt, "X").format("H") <= 17) { weather.weatherType = this.convertWeatherType(forecast.weather[0].icon); } diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 67193696..a59258ab 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -261,7 +261,7 @@ Module.register("weatherforecast",{ } else if (this.status === 401) { self.updateDom(self.config.animationSpeed); - if (self.config.forecastEndpoint == "forecast/daily") { + if (self.config.forecastEndpoint === "forecast/daily") { self.config.forecastEndpoint = "forecast"; Log.warn(self.name + ": Your AppID does not support long term forecasts. Switching to fallback endpoint."); } diff --git a/tests/e2e/fonts.js b/tests/e2e/fonts.js index 9d7aa349..7df36ad8 100644 --- a/tests/e2e/fonts.js +++ b/tests/e2e/fonts.js @@ -13,7 +13,7 @@ describe("All font files from roboto.css should be downloadable", function() { var fileContent = require("fs").readFileSync(__dirname + "/../../fonts/roboto.css", "utf8"); var regex = /\burl\(['"]([^'"]+)['"]\)/g; var match = regex.exec(fileContent); - while (match != null) { + while (match !== null) { // Push 1st match group onto fontFiles stack fontFiles.push(match[1]); // Find the next one