Replace prettier by stylistic to lint JavaScript (#3303)

In the latest versions of ESLint, more and more formatting rules were
removed or declared deprecated. These rules have been integrated into
the new Stylistic package (https://eslint.style/guide/why) and expanded.

Stylistic acts as a better formatter  for JavaScript as Prettier.

With this PR there are many changes that make the code more uniform, but
it may be difficult to review due to the large amount. Even if I have no
worries about the changes, perhaps this would be something for the
release after next.

Let me know what you think.
This commit is contained in:
Kristjan ESPERANTO
2023-12-25 08:17:11 +01:00
committed by GitHub
parent 4e7b68a69d
commit 0b70274a1a
64 changed files with 954 additions and 942 deletions

View File

@@ -479,7 +479,6 @@ const MM = (function () {
*/
const loadConfig = function () {
// FIXME: Think about how to pass config around without breaking tests
/* eslint-disable */
if (typeof config === "undefined") {
config = defaults;
Log.error("Config file is missing! Please create a config file.");
@@ -487,7 +486,6 @@ const MM = (function () {
}
config = Object.assign({}, defaults, config);
/* eslint-enable */
};
/**
@@ -495,6 +493,7 @@ const MM = (function () {
* @param {Module[]} modules Array of modules.
*/
const setSelectionMethodsForModules = function (modules) {
/**
* Filter modules with the specified classes.
* @param {string|string[]} className one or multiple classnames (array or space divided).
@@ -580,12 +579,13 @@ const MM = (function () {
};
return {
/* Public Methods */
/**
* Main init method.
*/
init: async function () {
async init () {
Log.info("Initializing MagicMirror².");
loadConfig();
@@ -599,7 +599,7 @@ const MM = (function () {
* Gets called when all modules are started.
* @param {Module[]} moduleObjects All module instances.
*/
modulesStarted: function (moduleObjects) {
modulesStarted (moduleObjects) {
modules = [];
let startUp = "";
@@ -636,7 +636,7 @@ const MM = (function () {
* @param {*} payload The payload of the notification.
* @param {Module} sender The module that sent the notification.
*/
sendNotification: function (notification, payload, sender) {
sendNotification (notification, payload, sender) {
if (arguments.length < 3) {
Log.error("sendNotification: Missing arguments.");
return;
@@ -661,7 +661,7 @@ const MM = (function () {
* @param {Module} module The module that needs an update.
* @param {object|number} [updateOptions] The (optional) number of microseconds for the animation or object with updateOptions (speed/animates)
*/
updateDom: function (module, updateOptions) {
updateDom (module, updateOptions) {
if (!(module instanceof Module)) {
Log.error("updateDom: Sender should be a module.");
return;
@@ -680,7 +680,7 @@ const MM = (function () {
* Returns a collection of all modules currently active.
* @returns {Module[]} A collection of all modules currently active.
*/
getModules: function () {
getModules () {
setSelectionMethodsForModules(modules);
return modules;
},
@@ -692,7 +692,7 @@ const MM = (function () {
* @param {Function} callback Called when the animation is done.
* @param {object} [options] Optional settings for the hide method.
*/
hideModule: function (module, speed, callback, options) {
hideModule (module, speed, callback, options) {
module.hidden = true;
hideModule(module, speed, callback, options);
},
@@ -704,12 +704,12 @@ const MM = (function () {
* @param {Function} callback Called when the animation is done.
* @param {object} [options] Optional settings for the show method.
*/
showModule: function (module, speed, callback, options) {
showModule (module, speed, callback, options) {
// do not change module.hidden yet, only if we really show it later
showModule(module, speed, callback, options);
}
};
})();
}());
// Add polyfill for Object.assign.
if (typeof Object.assign !== "function") {
@@ -732,7 +732,7 @@ if (typeof Object.assign !== "function") {
}
return output;
};
})();
}());
}
MM.init();