always use template strings instead of string concatenation

This commit is contained in:
zadam
2022-12-21 15:19:05 +01:00
parent ea006993f6
commit 1b24276a4a
154 changed files with 433 additions and 437 deletions

View File

@@ -38,7 +38,7 @@ function getRecentNotes(activeNoteId) {
const hoistedNoteId = cls.getHoistedNoteId();
if (hoistedNoteId !== 'root') {
extraCondition = `AND recent_notes.notePath LIKE ?`;
params.push('%' + hoistedNoteId + '%');
params.push(`%${hoistedNoteId}%`);
}
const recentNotes = becca.getRecentNotesFromQuery(`

View File

@@ -68,7 +68,7 @@ function addClipping(req) {
const existingContent = clippingNote.getContent();
clippingNote.setContent(existingContent + (existingContent.trim() ? "<br/>" : "") + rewrittenContent);
clippingNote.setContent(`${existingContent}${existingContent.trim() ? "<br/>" : ""}${rewrittenContent}`);
return {
noteId: clippingNote.noteId
@@ -79,7 +79,7 @@ function createNote(req) {
let {title, content, pageUrl, images, clipType} = req.body;
if (!title || !title.trim()) {
title = "Clipped note from " + pageUrl;
title = `Clipped note from ${pageUrl}`;
}
const clipperInbox = getClipperInboxNote();
@@ -123,7 +123,7 @@ function processContent(images, note, content) {
? dataUrl.substr(0, Math.min(100, dataUrl.length))
: "null";
log.info("Image could not be recognized as data URL: " + excerpt);
log.info(`Image could not be recognized as data URL: ${excerpt}`);
continue;
}

View File

@@ -25,7 +25,7 @@ function vacuumDatabase() {
function checkIntegrity() {
const results = sql.getRows("PRAGMA integrity_check");
log.info("Integrity check result: " + JSON.stringify(results));
log.info(`Integrity check result: ${JSON.stringify(results)}`);
return {
results

View File

@@ -18,7 +18,7 @@ function returnImage(req, res) {
}
else if (image.isDeleted || image.data === null) {
res.set('Content-Type', 'image/png');
return res.send(fs.readFileSync(RESOURCE_DIR + '/db/image-deleted.png'));
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
}
/**
@@ -81,7 +81,7 @@ function updateImage(req) {
if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
return {
uploaded: false,
message: "Unknown image type: " + file.mimetype
message: `Unknown image type: ${file.mimetype}`
};
}

View File

@@ -63,7 +63,7 @@ async function importToBranch(req) {
}
}
catch (e) {
const message = "Import failed with following error: '" + e.message + "'. More details might be in the logs.";
const message = `Import failed with following error: '${e.message}'. More details might be in the logs.`;
taskContext.reportError(message);
log.error(message + e.stack);

View File

@@ -138,7 +138,7 @@ function getLinkMap(req) {
}
})
.map(rel => ({
id: rel.noteId + "-" + rel.name + "-" + rel.value,
id: `${rel.noteId}-${rel.name}-${rel.value}`,
sourceNoteId: rel.noteId,
targetNoteId: rel.value,
name: rel.name
@@ -267,7 +267,7 @@ function findExcerpts(sourceNote, referencedNoteId) {
if (prevText.length + excerptLength > EXCERPT_CHAR_LIMIT) {
const prefix = prevText.substr(prevText.length - (EXCERPT_CHAR_LIMIT - excerptLength));
const textNode = document.createTextNode("…" + prefix);
const textNode = document.createTextNode(`${prefix}`);
excerptEls.unshift(textNode);
break;
@@ -287,7 +287,7 @@ function findExcerpts(sourceNote, referencedNoteId) {
if (nextText.length + excerptLength > EXCERPT_CHAR_LIMIT) {
const suffix = nextText.substr(nextText.length - (EXCERPT_CHAR_LIMIT - excerptLength));
const textNode = document.createTextNode(suffix + "…");
const textNode = document.createTextNode(`${suffix}`);
excerptEls.push(textNode);
break;

View File

@@ -52,11 +52,10 @@ function getRevisionFilename(noteRevision) {
.replace(/[^0-9_]/g, '');
if (extension) {
filename = filename.substr(0, filename.length - extension.length)
+ '-' + date + extension;
filename = `${filename.substr(0, filename.length - extension.length)}-${date}${extension}`;
}
else {
filename += '-' + date;
filename += `-${date}`;
}
return filename;
@@ -123,7 +122,7 @@ function getEditedNotesOnDate(req) {
WHERE note_revisions.dateLastEdited LIKE :date
)
ORDER BY isDeleted
LIMIT 50`, {date: req.params.date + '%'});
LIMIT 50`, {date: `${req.params.date}%`});
let notes = becca.getNotes(noteIds, true);

View File

@@ -25,8 +25,7 @@ function getNote(req) {
pojo.content = note.getContent();
if (note.type === 'file' && pojo.content.length > 10000) {
pojo.content = pojo.content.substr(0, 10000)
+ `\r\n\r\n... and ${pojo.content.length - 10000} more characters.`;
pojo.content = `${pojo.content.substr(0, 10000)}\r\n\r\n... and ${pojo.content.length - 10000} more characters.`;
}
}

View File

@@ -10,10 +10,10 @@ function uploadImage(req) {
const file = req.file;
if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
return [400, "Unknown image type: " + file.mimetype];
return [400, `Unknown image type: ${file.mimetype}`];
}
const originalName = "Sender image." + imageType(file.buffer).ext;
const originalName = `Sender image.${imageType(file.buffer).ext}`;
const parentNote = dateNoteService.getDayNote(req.headers['x-local-date']);

View File

@@ -114,7 +114,7 @@ function forceNoteSync(req) {
entityChangesService.moveEntityChangeToTop('note_revision_contents', noteRevisionId);
}
log.info("Forcing note sync for " + noteId);
log.info(`Forcing note sync for ${noteId}`);
// not awaiting for the job to finish (will probably take a long time)
syncService.sync();