mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Use template literals instead of string concatenation (#3066)
We have used it inconsistently till now. Template literals are more modern and easier to maintain in my opinion. Because that's a large amount of changes, here's a way to reproduce it: I added the rule `"prefer-template": "error"` to the `.eslintrc.json` and did an autofix. Since this caused a new problem in line 409 of `newsfeed.js`, I reversed it in that line and also removed the rule from the eslint config file. The rule is described here: https://eslint.org/docs/latest/rules/prefer-template Note: I've played around with some other linter rules as well, and some seem to point to some specific, non-cosmetic, issues. But before I dive even deeper and then introduce even bigger and hardly understandable changes at once, I thought I'd start with this simple cosmetic rule.
This commit is contained in:
committed by
GitHub
parent
8f8945d418
commit
d276a7ddb9
10
js/main.js
10
js/main.js
@@ -29,7 +29,7 @@ const MM = (function () {
|
||||
dom.className = module.name;
|
||||
|
||||
if (typeof module.data.classes === "string") {
|
||||
dom.className = "module " + dom.className + " " + module.data.classes;
|
||||
dom.className = `module ${dom.className} ${module.data.classes}`;
|
||||
}
|
||||
|
||||
dom.opacity = 0;
|
||||
@@ -243,7 +243,7 @@ const MM = (function () {
|
||||
|
||||
const moduleWrapper = document.getElementById(module.identifier);
|
||||
if (moduleWrapper !== null) {
|
||||
moduleWrapper.style.transition = "opacity " + speed / 1000 + "s";
|
||||
moduleWrapper.style.transition = `opacity ${speed / 1000}s`;
|
||||
moduleWrapper.style.opacity = 0;
|
||||
moduleWrapper.classList.add("hidden");
|
||||
|
||||
@@ -291,7 +291,7 @@ const MM = (function () {
|
||||
// Check if there are no more lockstrings set, or the force option is set.
|
||||
// Otherwise cancel show action.
|
||||
if (module.lockStrings.length !== 0 && options.force !== true) {
|
||||
Log.log("Will not show " + module.name + ". LockStrings active: " + module.lockStrings.join(","));
|
||||
Log.log(`Will not show ${module.name}. LockStrings active: ${module.lockStrings.join(",")}`);
|
||||
if (typeof options.onError === "function") {
|
||||
options.onError(new Error("LOCK_STRING_ACTIVE"));
|
||||
}
|
||||
@@ -302,13 +302,13 @@ const MM = (function () {
|
||||
|
||||
// If forced show, clean current lockstrings.
|
||||
if (module.lockStrings.length !== 0 && options.force === true) {
|
||||
Log.log("Force show of module: " + module.name);
|
||||
Log.log(`Force show of module: ${module.name}`);
|
||||
module.lockStrings = [];
|
||||
}
|
||||
|
||||
const moduleWrapper = document.getElementById(module.identifier);
|
||||
if (moduleWrapper !== null) {
|
||||
moduleWrapper.style.transition = "opacity " + speed / 1000 + "s";
|
||||
moduleWrapper.style.transition = `opacity ${speed / 1000}s`;
|
||||
// Restore the position. See hideModule() for more info.
|
||||
moduleWrapper.style.position = "static";
|
||||
moduleWrapper.classList.remove("hidden");
|
||||
|
Reference in New Issue
Block a user