Skip to content

Commit

Permalink
Bump stylistic-eslint (#3520)
Browse files Browse the repository at this point in the history
updates plugin and adjust docs and config for smooth cleaning :-D

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
rejas and dependabot[bot] authored Aug 12, 2024
1 parent 780e4e2 commit 976c8ae
Show file tree
Hide file tree
Showing 32 changed files with 699 additions and 564 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@stylistic/function-paren-newline": ["error", "consistent"],
"@stylistic/implicit-arrow-linebreak": ["error", "beside"],
"@stylistic/max-statements-per-line": ["error", { "max": 2 }],
"@stylistic/multiline-comment-style": "off",
"@stylistic/multiline-ternary": ["error", "always-multiline"],
"@stylistic/newline-per-chained-call": ["error", { "ignoreChainWithDepth": 4 }],
"@stylistic/no-extra-parens": "off",
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _This release is scheduled to be released on 2024-10-01._
### Updated

- [weather] Updated `apiVersion` default from 2.5 to 3.0 (#3424)
- [core] Updated dependencies
- [core] Updated dependencies including stylistic-eslint
- [core] Allow custom module positions by setting `allowCustomModulePositions` in `config.js` (fixes #3504, related to https://github.com/MagicMirrorOrg/MagicMirror/pull/3445)

### Fixed
Expand Down
21 changes: 14 additions & 7 deletions js/class.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global Class, xyz */

/* Simple JavaScript Inheritance
/*
* Simple JavaScript Inheritance
* By John Resig https://johnresig.com/
*
* Inspired by base2 and Prototype
Expand All @@ -22,8 +23,10 @@
Class.extend = function (prop) {
let _super = this.prototype;

// Instantiate a base class (but only create the instance,
// don't run the init constructor)
/*
* Instantiate a base class (but only create the instance,
* don't run the init constructor)
*/
initializing = true;
const prototype = new this();
initializing = false;
Expand All @@ -42,12 +45,16 @@
return function () {
const tmp = this._super;

// Add a new ._super() method that is the same method
// but on the super-class
/*
* Add a new ._super() method that is the same method
* but on the super-class
*/
this._super = _super[name];

// The method only need to be bound temporarily, so we
// remove it when we're done executing
/*
* The method only need to be bound temporarily, so we
* remove it when we're done executing
*/
const ret = fn.apply(this, arguments);
this._super = tmp;

Expand Down
50 changes: 34 additions & 16 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@ const Log = require("./logger");
let config = process.env.config ? JSON.parse(process.env.config) : {};
// Module to control application life.
const app = electron.app;
// Per default electron is started with --disable-gpu flag, if you want the gpu enabled,
// you must set the env var ELECTRON_ENABLE_GPU=1 on startup.
// See https://www.electronjs.org/docs/latest/tutorial/offscreen-rendering for more info.

/*
* Per default electron is started with --disable-gpu flag, if you want the gpu enabled,
* you must set the env var ELECTRON_ENABLE_GPU=1 on startup.
* See https://www.electronjs.org/docs/latest/tutorial/offscreen-rendering for more info.
*/
if (process.env.ELECTRON_ENABLE_GPU !== "1") {
app.disableHardwareAcceleration();
}

// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
/*
* Keep a global reference of the window object, if you don't, the window will
* be closed automatically when the JavaScript object is garbage collected.
*/
let mainWindow;

/**
*
*/
function createWindow () {
// see https://www.electronjs.org/docs/latest/api/screen
// Create a window that fills the screen's available work area.

/*
* see https://www.electronjs.org/docs/latest/api/screen
* Create a window that fills the screen's available work area.
*/
let electronSize = (800, 600);
try {
electronSize = electron.screen.getPrimaryDisplay().workAreaSize;
Expand All @@ -52,8 +60,10 @@ function createWindow () {
backgroundColor: "#000000"
};

// DEPRECATED: "kioskmode" backwards compatibility, to be removed
// settings these options directly instead provides cleaner interface
/*
* DEPRECATED: "kioskmode" backwards compatibility, to be removed
* settings these options directly instead provides cleaner interface
*/
if (config.kioskmode) {
electronOptionsDefaults.kiosk = true;
} else {
Expand All @@ -69,8 +79,10 @@ function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow(electronOptions);

// and load the index.html of the app.
// If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost
/*
* and load the index.html of the app.
* If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost
*/

let prefix;
if ((config["tls"] !== null && config["tls"]) || config.useHttps) {
Expand Down Expand Up @@ -149,14 +161,18 @@ app.on("window-all-closed", function () {
});

app.on("activate", function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.

/*
* On OS X it's common to re-create a window in the app when the
* dock icon is clicked and there are no other windows open.
*/
if (mainWindow === null) {
createWindow();
}
});

/* This method will be called when SIGINT is received and will call
/*
* This method will be called when SIGINT is received and will call
* each node_helper's stop function if it exists. Added to fix #1056
*
* Note: this is only used if running Electron. Otherwise
Expand Down Expand Up @@ -187,8 +203,10 @@ if (process.env.clientonly) {
});
}

// Start the core application if server is run on localhost
// This starts all node helpers and starts the webserver.
/*
* Start the core application if server is run on localhost
* This starts all node helpers and starts the webserver.
*/
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].includes(config.address)) {
core.start().then((c) => {
config = c;
Expand Down
29 changes: 19 additions & 10 deletions js/module.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* global Class, cloneObject, Loader, MMSocket, nunjucks, Translator */

/* Module Blueprint.
/*
* Module Blueprint.
* @typedef {Object} Module
*/
const Module = Class.extend({

/*********************************************************
/**
********************************************************
* All methods (and properties) below can be subclassed. *
*********************************************************/
********************************************************
*/

// Set the minimum MagicMirror² module version for this module.
requiresVersion: "2.0.0",
Expand All @@ -18,13 +21,17 @@ const Module = Class.extend({
// Timer reference used for showHide animation callbacks.
showHideTimer: null,

// Array to store lockStrings. These strings are used to lock
// visibility when hiding and showing module.
/*
* Array to store lockStrings. These strings are used to lock
* visibility when hiding and showing module.
*/
lockStrings: [],

// Storage of the nunjucks Environment,
// This should not be referenced directly.
// Use the nunjucksEnvironment() to get it.
/*
* Storage of the nunjucks Environment,
* This should not be referenced directly.
* Use the nunjucksEnvironment() to get it.
*/
_nunjucksEnvironment: null,

/**
Expand Down Expand Up @@ -189,9 +196,11 @@ const Module = Class.extend({
Log.log(`${this.name} is resumed.`);
},

/*********************************************
/**
********************************************
* The methods below don't need subclassing. *
*********************************************/
********************************************
*/

/**
* Set the module data.
Expand Down
9 changes: 6 additions & 3 deletions js/node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const NodeHelper = Class.extend({
this.path = path;
},

/* sendSocketNotification(notification, payload)
/*
* sendSocketNotification(notification, payload)
* Send a socket notification to the node helper.
*
* argument notification string - The identifier of the notification.
Expand All @@ -59,7 +60,8 @@ const NodeHelper = Class.extend({
this.io.of(this.name).emit(notification, payload);
},

/* setExpressApp(app)
/*
* setExpressApp(app)
* Sets the express app object for this module.
* This allows you to host files from the created webserver.
*
Expand All @@ -71,7 +73,8 @@ const NodeHelper = Class.extend({
app.use(`/${this.name}`, express.static(`${this.path}/public`));
},

/* setSocketIO(io)
/*
* setSocketIO(io)
* Sets the socket io object for this module.
* Binds message receiver.
*
Expand Down
31 changes: 21 additions & 10 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ Module.register("calendar", {

// Define required translations.
getTranslations () {
// The translations for the default modules are defined in the core translation files.
// Therefore we can just return false. Otherwise we should have returned a dictionary.
// If you're trying to build your own module including translations, check out the documentation.

/*
* The translations for the default modules are defined in the core translation files.
* Therefore we can just return false. Otherwise we should have returned a dictionary.
* If you're trying to build your own module including translations, check out the documentation.
*/
return false;
},

Expand Down Expand Up @@ -148,8 +151,10 @@ Module.register("calendar", {
};
}

// tell helper to start a fetcher for this calendar
// fetcher till cycle
/*
* tell helper to start a fetcher for this calendar
* fetcher till cycle
*/
this.addCalendar(calendar.url, calendar.auth, calendarConfig);
});

Expand Down Expand Up @@ -627,7 +632,8 @@ Module.register("calendar", {
event.tomorrow = !event.today && event.startDate >= today + ONE_DAY && event.startDate < today + 2 * ONE_DAY;
event.dayAfterTomorrow = !event.tomorrow && event.startDate >= today + ONE_DAY * 2 && event.startDate < today + 3 * ONE_DAY;

/* if sliceMultiDayEvents is set to true, multiday events (events exceeding at least one midnight) are sliced into days,
/*
* if sliceMultiDayEvents is set to true, multiday events (events exceeding at least one midnight) are sliced into days,
* otherwise, esp. in dateheaders mode it is not clear how long these events are.
*/
const maxCount = Math.ceil((event.endDate - 1 - moment(event.startDate, "x").endOf("day").format("x")) / ONE_DAY) + 1;
Expand Down Expand Up @@ -677,16 +683,21 @@ Module.register("calendar", {
return events;
}

// Limit the number of days displayed
// If limitDays is set > 0, limit display to that number of days
/*
* Limit the number of days displayed
* If limitDays is set > 0, limit display to that number of days
*/
if (this.config.limitDays > 0) {
let newEvents = [];
let lastDate = today.clone().subtract(1, "days").format("YYYYMMDD");
let days = 0;
for (const ev of events) {
let eventDate = moment(ev.startDate, "x").format("YYYYMMDD");
// if date of event is later than lastdate
// check if we already are showing max unique days

/*
* if date of event is later than lastdate
* check if we already are showing max unique days
*/
if (eventDate > lastDate) {
// if the only entry in the first day is a full day event that day is not counted as unique
if (!this.config.limitDaysNeverSkip && newEvents.length === 1 && days === 1 && newEvents[0].fullDayEvent) {
Expand Down
3 changes: 2 additions & 1 deletion modules/default/calendar/debug.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* CalendarFetcher Tester
/*
* CalendarFetcher Tester
* use this script with `node debug.js` to test the fetcher without the need
* of starting the MagicMirror² core. Adjust the values below to your desire.
*/
Expand Down
3 changes: 2 additions & 1 deletion modules/default/defaultmodules.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Default Modules List
/*
* Default Modules List
* Modules listed below can be loaded without the 'default/' prefix. Omitting the default folder name.
*/
const defaultModules = ["alert", "calendar", "clock", "compliments", "helloworld", "newsfeed", "updatenotification", "weather"];
Expand Down
19 changes: 11 additions & 8 deletions modules/default/updatenotification/update_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const fs = require("node:fs");

const Log = require("logger");

/* class Updater
/*
* class Updater
* Allow to self updating 3rd party modules from command defined in config
*
* [constructor] read value in config:
Expand Down Expand Up @@ -84,13 +85,15 @@ class Updater {
return updater;
}

// module updater with his proper command
// return object as result
//{
// error: <boolean>, // if error detected
// updated: <boolean>, // if updated successfully
// needRestart: <boolean> // if magicmirror restart required
//};
/*
* module updater with his proper command
* return object as result
* {
* error: <boolean>, // if error detected
* updated: <boolean>, // if updated successfully
* needRestart: <boolean> // if magicmirror restart required
* };
*/
updateProcess (module) {
let Result = {
error: false,
Expand Down
Loading

0 comments on commit 976c8ae

Please sign in to comment.