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:
Kristjan ESPERANTO
2023-03-19 14:32:23 +01:00
committed by GitHub
parent 8f8945d418
commit d276a7ddb9
45 changed files with 222 additions and 237 deletions

View File

@@ -44,7 +44,7 @@ const Loader = (function () {
// Starting modules also hides any modules that have requested to be initially hidden
for (const thisModule of moduleObjects) {
if (thisModule.data.hiddenOnStartup) {
Log.info("Initially hiding " + thisModule.name);
Log.info(`Initially hiding ${thisModule.name}`);
thisModule.hide();
}
}
@@ -73,10 +73,10 @@ const Loader = (function () {
const elements = module.split("/");
const moduleName = elements[elements.length - 1];
let moduleFolder = config.paths.modules + "/" + module;
let moduleFolder = `${config.paths.modules}/${module}`;
if (defaultModules.indexOf(moduleName) !== -1) {
moduleFolder = config.paths.modules + "/default/" + module;
moduleFolder = `${config.paths.modules}/default/${module}`;
}
if (moduleData.disabled === true) {
@@ -85,16 +85,16 @@ const Loader = (function () {
moduleFiles.push({
index: index,
identifier: "module_" + index + "_" + module,
identifier: `module_${index}_${module}`,
name: moduleName,
path: moduleFolder + "/",
file: moduleName + ".js",
path: `${moduleFolder}/`,
file: `${moduleName}.js`,
position: moduleData.position,
hiddenOnStartup: moduleData.hiddenOnStartup,
header: moduleData.header,
configDeepMerge: typeof moduleData.configDeepMerge === "boolean" ? moduleData.configDeepMerge : false,
config: moduleData.config,
classes: typeof moduleData.classes !== "undefined" ? moduleData.classes + " " + module : module
classes: typeof moduleData.classes !== "undefined" ? `${moduleData.classes} ${module}` : module
});
});
@@ -136,17 +136,17 @@ const Loader = (function () {
* @param {Module} mObj Modules instance.
*/
const bootstrapModule = async function (module, mObj) {
Log.info("Bootstrapping module: " + module.name);
Log.info(`Bootstrapping module: ${module.name}`);
mObj.setData(module);
await mObj.loadScripts();
Log.log("Scripts loaded for: " + module.name);
Log.log(`Scripts loaded for: ${module.name}`);
await mObj.loadStyles();
Log.log("Styles loaded for: " + module.name);
Log.log(`Styles loaded for: ${module.name}`);
await mObj.loadTranslations();
Log.log("Translations loaded for: " + module.name);
Log.log(`Translations loaded for: ${module.name}`);
moduleObjects.push(mObj);
};
@@ -164,7 +164,7 @@ const Loader = (function () {
switch (extension.toLowerCase()) {
case "js":
return new Promise((resolve) => {
Log.log("Load script: " + fileName);
Log.log(`Load script: ${fileName}`);
script = document.createElement("script");
script.type = "text/javascript";
script.src = fileName;
@@ -179,7 +179,7 @@ const Loader = (function () {
});
case "css":
return new Promise((resolve) => {
Log.log("Load stylesheet: " + fileName);
Log.log(`Load stylesheet: ${fileName}`);
stylesheet = document.createElement("link");
stylesheet.rel = "stylesheet";
@@ -236,7 +236,7 @@ const Loader = (function () {
*/
loadFileForModule: async function (fileName, module) {
if (loadedFiles.indexOf(fileName.toLowerCase()) !== -1) {
Log.log("File already loaded: " + fileName);
Log.log(`File already loaded: ${fileName}`);
return;
}
@@ -251,7 +251,7 @@ const Loader = (function () {
// This file is available in the vendor folder.
// Load it from this vendor folder.
loadedFiles.push(fileName.toLowerCase());
return loadFile(config.paths.vendor + "/" + vendor[fileName]);
return loadFile(`${config.paths.vendor}/${vendor[fileName]}`);
}
// File not loaded yet.