Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.js.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* which will be converted to `config.js` while starting. For more information
* see https://docs.magicmirror.builders/configuration/introduction.html#enviromnent-variables
*/
let config = {
const config = {
address: "localhost", // Address to listen on, can be:
// - "localhost", "127.0.0.1", "::1" to listen on loopback interface
// - another specific IPv4/6 to listen on a specific interface
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/alert/notificationFx.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @returns {object} The merged object
*/
function extend (a, b) {
for (let key in b) {
for (const key in b) {
if (b.hasOwnProperty(key)) {
a[key] = b[key];
}
Expand Down
26 changes: 13 additions & 13 deletions defaultmodules/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Module.register("calendar", {
return;
}
} else if (notification === "CALENDAR_ERROR") {
let error_message = this.translate(payload.error_type);
const error_message = this.translate(payload.error_type);
this.error = this.translate("MODULE_CONFIG_ERROR", { MODULE_NAME: this.name, ERROR: error_message });
this.loaded = true;
}
Expand Down Expand Up @@ -350,8 +350,8 @@ Module.register("calendar", {

// Color events if custom color or eventClass are specified, transform title if required
if (this.config.customEvents.length > 0) {
for (let ev in this.config.customEvents) {
let needle = new RegExp(this.config.customEvents[ev].keyword, "gi");
for (const ev in this.config.customEvents) {
const needle = new RegExp(this.config.customEvents[ev].keyword, "gi");
if (needle.test(event.title)) {
if (typeof this.config.customEvents[ev].transform === "object") {
transformedTitle = CalendarUtils.titleTransform(transformedTitle, [this.config.customEvents[ev].transform]);
Expand Down Expand Up @@ -471,16 +471,16 @@ Module.register("calendar", {
* @returns {object[]} Array with events.
*/
createEventList (limitNumberOfEntries) {
let now = moment();
let future = now.clone().startOf("day").add(this.config.maximumNumberOfDays, "days");
const now = moment();
const future = now.clone().startOf("day").add(this.config.maximumNumberOfDays, "days");

let events = [];

for (const calendarUrl in this.calendarData) {
const calendar = this.calendarData[calendarUrl].events;
let remainingEntries = this.maximumEntriesForUrl(calendarUrl);
let maxPastDaysCompare = now.clone().subtract(this.maximumPastDaysForUrl(calendarUrl), "days");
let by_url_calevents = [];
const remainingEntries = this.maximumEntriesForUrl(calendarUrl);
const maxPastDaysCompare = now.clone().subtract(this.maximumPastDaysForUrl(calendarUrl), "days");
const by_url_calevents = [];
for (const e in calendar) {
const event = JSON.parse(JSON.stringify(calendar[e])); // clone object
const eventStartDateMoment = this.timestampToMoment(event.startDate);
Expand Down Expand Up @@ -541,7 +541,7 @@ Module.register("calendar", {
event.tomorrow = this.timestampToMoment(event.startDate).isSame(now.clone().add(1, "days"), "d");
splitEvents.push(event);

for (let splitEvent of splitEvents) {
for (const splitEvent of splitEvents) {
if (this.timestampToMoment(splitEvent.endDate).isAfter(now) && this.timestampToMoment(splitEvent.endDate).isSameOrBefore(future)) {
by_url_calevents.push(splitEvent);
}
Expand Down Expand Up @@ -579,7 +579,7 @@ Module.register("calendar", {
// Group all events by date, events on the same date will be in a list with the key being the date.
const eventsByDate = Object.groupBy(events, (ev) => this.timestampToMoment(ev.startDate).format("YYYY-MM-DD"));
const newEvents = [];
let currentDate = moment();
const currentDate = moment();
let daysCollected = 0;

while (daysCollected < this.config.limitDays) {
Expand Down Expand Up @@ -650,9 +650,9 @@ Module.register("calendar", {
}

// If custom symbol is set, replace event symbol
for (let ev of this.config.customEvents) {
for (const ev of this.config.customEvents) {
if (typeof ev.symbol !== "undefined" && ev.symbol !== "") {
let needle = new RegExp(ev.keyword, "gi");
const needle = new RegExp(ev.keyword, "gi");
if (needle.test(event.title)) {
// Get the default prefix for this class name and add to the custom symbol provided
const className = this.getCalendarProperty(event.url, "symbolClassName", this.config.defaultSymbolClassName);
Expand Down Expand Up @@ -988,7 +988,7 @@ Module.register("calendar", {
if (property === "symbol" || property === "recurringSymbol" || property === "fullDaySymbol") {
const className = this.getCalendarProperty(url, "symbolClassName", this.config.defaultSymbolClassName);
if (p instanceof Array) {
let t = [];
const t = [];
p.forEach((n) => { t.push(className + n); });
p = t;
}
Expand Down
10 changes: 5 additions & 5 deletions defaultmodules/calendar/calendarutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ const CalendarUtils = {
*/
titleTransform (title, titleReplace) {
let transformedTitle = title;
for (let tr in titleReplace) {
let transform = titleReplace[tr];
for (const tr in titleReplace) {
const transform = titleReplace[tr];
if (typeof transform === "object") {
if (typeof transform.search !== "undefined" && transform.search !== "" && typeof transform.replace !== "undefined") {
let regParts = transform.search.match(/^\/(.+)\/([gim]*)$/);
const regParts = transform.search.match(/^\/(.+)\/([gim]*)$/);
let needle = new RegExp(transform.search, "g");
if (regParts) {
// the parsed pattern is a regexp with flags.
Expand All @@ -110,8 +110,8 @@ const CalendarUtils = {
if (typeof transform.yearmatchgroup !== "undefined" && transform.yearmatchgroup !== "") {
const yearmatch = [...title.matchAll(needle)];
if (yearmatch[0].length >= transform.yearmatchgroup + 1 && yearmatch[0][transform.yearmatchgroup] * 1 >= 1900) {
let calcage = new Date().getFullYear() - yearmatch[0][transform.yearmatchgroup] * 1;
let searchstr = `$${transform.yearmatchgroup}`;
const calcage = new Date().getFullYear() - yearmatch[0][transform.yearmatchgroup] * 1;
const searchstr = `$${transform.yearmatchgroup}`;
replacement = replacement.replace(searchstr, calcage);
}
}
Expand Down
8 changes: 4 additions & 4 deletions defaultmodules/compliments/compliments.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Module.register("compliments", {
}
let minute_sync_delay = 1;
// loop thru all the configured when events
for (let m of Object.keys(this.config.compliments)) {
for (const m of Object.keys(this.config.compliments)) {
// if it is a cron entry
if (this.isCronEntry(m)) {
// we need to synch our interval cycle to the minute
Expand Down Expand Up @@ -165,14 +165,14 @@ Module.register("compliments", {
Array.prototype.push.apply(compliments, this.config.compliments.anytime);

// get the list of just date entry keys
let temp_list = Object.keys(this.config.compliments).filter((k) => {
const temp_list = Object.keys(this.config.compliments).filter((k) => {
if (this.pre_defined_types.includes(k)) return false;
else return true;
});

let date_compliments = [];
const date_compliments = [];
// Add compliments for special day/times
for (let entry of temp_list) {
for (const entry of temp_list) {
// check if this could be a cron type entry
if (this.isCronEntry(entry)) {
// make sure the regex is valid
Expand Down
20 changes: 10 additions & 10 deletions defaultmodules/newsfeed/newsfeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Module.register("newsfeed", {
* Registers the feeds to be used by the backend.
*/
registerFeeds () {
for (let feed of this.config.feeds) {
for (const feed of this.config.feeds) {
this.sendSocketNotification("ADD_FEED", {
feed: feed,
config: this.config
Expand All @@ -239,10 +239,10 @@ Module.register("newsfeed", {
*/
generateFeed (feeds) {
let newsItems = [];
for (let feed in feeds) {
for (const feed in feeds) {
const feedItems = feeds[feed];
if (this.subscribedToFeed(feed)) {
for (let item of feedItems) {
for (const item of feedItems) {
item.sourceTitle = this.titleForFeed(feed);
if (!(this.getFeedProperty(feed, "ignoreOldItems") && Date.now() - new Date(item.pubdate) > this.getFeedProperty(feed, "ignoreOlderThan"))) {
newsItems.push(item);
Expand All @@ -262,7 +262,7 @@ Module.register("newsfeed", {

if (this.config.prohibitedWords.length > 0) {
newsItems = newsItems.filter(function (item) {
for (let word of this.config.prohibitedWords) {
for (const word of this.config.prohibitedWords) {
if (item.title.toLowerCase().indexOf(word.toLowerCase()) > -1) {
return false;
}
Expand All @@ -273,7 +273,7 @@ Module.register("newsfeed", {
newsItems.forEach((item) => {
//Remove selected tags from the beginning of rss feed items (title or description)
if (this.config.removeStartTags === "title" || this.config.removeStartTags === "both") {
for (let startTag of this.config.startTags) {
for (const startTag of this.config.startTags) {
if (item.title.slice(0, startTag.length) === startTag) {
item.title = item.title.slice(startTag.length, item.title.length);
}
Expand All @@ -282,7 +282,7 @@ Module.register("newsfeed", {

if (this.config.removeStartTags === "description" || this.config.removeStartTags === "both") {
if (this.isShowingDescription) {
for (let startTag of this.config.startTags) {
for (const startTag of this.config.startTags) {
if (item.description.slice(0, startTag.length) === startTag) {
item.description = item.description.slice(startTag.length, item.description.length);
}
Expand All @@ -292,14 +292,14 @@ Module.register("newsfeed", {

//Remove selected tags from the end of rss feed items (title or description)
if (this.config.removeEndTags) {
for (let endTag of this.config.endTags) {
for (const endTag of this.config.endTags) {
if (item.title.slice(-endTag.length) === endTag) {
item.title = item.title.slice(0, -endTag.length);
}
}

if (this.isShowingDescription) {
for (let endTag of this.config.endTags) {
for (const endTag of this.config.endTags) {
if (item.description.slice(-endTag.length) === endTag) {
item.description = item.description.slice(0, -endTag.length);
}
Expand Down Expand Up @@ -331,7 +331,7 @@ Module.register("newsfeed", {
* @returns {boolean} True if it is subscribed, false otherwise
*/
subscribedToFeed (feedUrl) {
for (let feed of this.config.feeds) {
for (const feed of this.config.feeds) {
if (feed.url === feedUrl) {
return true;
}
Expand All @@ -345,7 +345,7 @@ Module.register("newsfeed", {
* @returns {string} The title of the feed
*/
titleForFeed (feedUrl) {
for (let feed of this.config.feeds) {
for (const feed of this.config.feeds) {
if (feed.url === feedUrl) {
return feed.title || "";
}
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/updatenotification/git_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GitHelper {
}

async getStatusInfo (repo) {
let gitInfo = {
const gitInfo = {
module: repo.module,
behind: 0, // commits behind
current: "", // branch name
Expand Down
4 changes: 2 additions & 2 deletions defaultmodules/updatenotification/update_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Updater {
});

await Promise.all(parser);
let updater = Object.values(this.moduleList);
const updater = Object.values(this.moduleList);
Log.debug("Update Result:", updater);
return updater;
}
Expand All @@ -92,7 +92,7 @@ class Updater {
* };
*/
updateProcess (module) {
let Result = {
const Result = {
error: false,
updated: false,
needRestart: false
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/providers/envcanada.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class EnvCanadaProvider {
// Check if first forecast is Today or Tonight
const isToday = forecasts[0].includes("textForecastName=\"Today\"");

let nextDay = isToday ? 2 : 1;
const nextDay = isToday ? 2 : 1;
const lastDay = isToday ? 12 : 11;

// Process first day
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Module.register("weather", {
const senderClasses = sender.data.classes.toLowerCase().split(" ");
if (senderClasses.indexOf(this.config.calendarClass.toLowerCase()) !== -1) {
this.firstEvent = null;
for (let event of payload) {
for (const event of payload) {
if (event.location || event.geo) {
this.firstEvent = event;
Log.debug("[weather] First upcoming event with location: ", event);
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/weatherobject.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class WeatherObject {
*/
simpleClone () {
const toFlat = ["date", "sunrise", "sunset"];
let clone = { ...this };
const clone = { ...this };
for (const prop of toFlat) {
clone[prop] = clone?.[prop]?.valueOf() ?? clone?.[prop];
}
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/weather/weatherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const WeatherUtils = {
convertWeatherObjectToImperial (weatherObject) {
if (!weatherObject || Object.keys(weatherObject).length === 0) return null;

let imperialWeatherObject = { ...weatherObject };
const imperialWeatherObject = { ...weatherObject };

if ("feelsLikeTemp" in imperialWeatherObject) imperialWeatherObject.feelsLikeTemp = this.convertTemp(imperialWeatherObject.feelsLikeTemp, "imperial");
if ("maxTemperature" in imperialWeatherObject) imperialWeatherObject.maxTemperature = this.convertTemp(imperialWeatherObject.maxTemperature, "imperial");
Expand Down
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default defineConfig([
"no-warning-comments": "off",
"object-shorthand": ["error", "methods"],
"one-var": "off",
"prefer-const": "error",
"prefer-template": "error",
"require-await": "error",
"sort-keys": "off"
Expand Down
12 changes: 6 additions & 6 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ process.on("uncaughtException", function (err) {
* @class
*/
function App () {
let nodeHelpers = [];
const nodeHelpers = [];
let httpServer;
let defaultModules;
let env;
Expand Down Expand Up @@ -118,7 +118,7 @@ function App () {
Log.error(`Error when loading ${moduleName}:`, e.message);
return;
}
let m = new Module();
const m = new Module();

if (m.requiresVersion) {
Log.log(`Check MagicMirror² version for node helper '${moduleName}' - Minimum version: ${m.requiresVersion} - Current version: ${global.version}`);
Expand Down Expand Up @@ -146,7 +146,7 @@ function App () {
async function loadModules (modules) {
Log.log("Loading module helpers ...");

for (let module of modules) {
for (const module of modules) {
await loadModule(module);
}

Expand Down Expand Up @@ -211,7 +211,7 @@ function App () {
// get the used module positions
Utils.getModulePositions();

let modules = [];
const modules = [];
for (const module of config.modules) {
if (module.disabled) continue;
if (module.module) {
Expand All @@ -237,7 +237,7 @@ function App () {
Log.log("Server started ...");

const nodePromises = [];
for (let nodeHelper of nodeHelpers) {
for (const nodeHelper of nodeHelpers) {
nodeHelper.setExpressApp(app);
nodeHelper.setSocketIO(io);

Expand Down Expand Up @@ -284,7 +284,7 @@ function App () {
*/
this.stop = async function () {
const nodePromises = [];
for (let nodeHelper of nodeHelpers) {
for (const nodeHelper of nodeHelpers) {
try {
if (typeof nodeHelper.stop === "function") {
nodePromises.push(nodeHelper.stop());
Expand Down
4 changes: 2 additions & 2 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function createWindow () {
}

applyElectronSwitches(app.commandLine, config.electronSwitches);
let electronOptionsDefaults = {
const electronOptionsDefaults = {
width: electronSize.width,
height: electronSize.height,
icon: "favicon.svg",
Expand Down Expand Up @@ -100,7 +100,7 @@ function createWindow () {
prefix = "http://";
}

let address = (config.address === void 0) | (config.address === "") | (config.address === "0.0.0.0") | (config.address === "::") ? (config.address = "localhost") : config.address;
const address = (config.address === void 0) | (config.address === "") | (config.address === "0.0.0.0") | (config.address === "::") ? (config.address = "localhost") : config.address;
const port = process.env.MM_PORT || config.port;
mainWindow.loadURL(`${prefix}${address}:${port}`);

Expand Down
3 changes: 1 addition & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,14 @@ function moduleNeedsUpdate (module, newHeader, newContent) {
const headerWrapper = moduleWrapper.getElementsByClassName("module-header");

let headerNeedsUpdate = false;
let contentNeedsUpdate;

if (headerWrapper.length > 0) {
headerNeedsUpdate = newHeader !== headerWrapper[0].innerHTML;
}

const tempContentWrapper = document.createElement("div");
tempContentWrapper.appendChild(newContent);
contentNeedsUpdate = tempContentWrapper.innerHTML !== contentWrapper[0].innerHTML;
const contentNeedsUpdate = tempContentWrapper.innerHTML !== contentWrapper[0].innerHTML;

return headerNeedsUpdate || contentNeedsUpdate;
}
Expand Down
Loading