Merge pull request #3818 from soulsands/fix-lint

Fix lint
This commit is contained in:
zadam 2023-04-09 22:54:02 +02:00 committed by GitHub
commit fbc79eae62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 38 deletions

View File

@ -168,7 +168,6 @@ function trimMime(mime) {
} }
mimeCache[mime] = str; mimeCache[mime] = str;
mimeCache[mime] = str;
} }
return mimeCache[mime]; return mimeCache[mime];

View File

@ -20,7 +20,7 @@ function register(router) {
const {date} = req.params; const {date} = req.params;
if (!isValidDate(date)) { if (!isValidDate(date)) {
throw getDateInvalidError(res, date); throw getDateInvalidError(date);
} }
const note = specialNotesService.getInboxNote(date); const note = specialNotesService.getInboxNote(date);
@ -31,7 +31,7 @@ function register(router) {
const {date} = req.params; const {date} = req.params;
if (!isValidDate(date)) { if (!isValidDate(date)) {
throw getDateInvalidError(res, date); throw getDateInvalidError(date);
} }
const note = dateNotesService.getDayNote(date); const note = dateNotesService.getDayNote(date);
@ -42,7 +42,7 @@ function register(router) {
const {date} = req.params; const {date} = req.params;
if (!isValidDate(date)) { if (!isValidDate(date)) {
throw getDateInvalidError(res, date); throw getDateInvalidError(date);
} }
const note = dateNotesService.getWeekNote(date); const note = dateNotesService.getWeekNote(date);
@ -53,7 +53,7 @@ function register(router) {
const {month} = req.params; const {month} = req.params;
if (!/[0-9]{4}-[0-9]{2}/.test(month)) { if (!/[0-9]{4}-[0-9]{2}/.test(month)) {
throw getMonthInvalidError(res, month); throw getMonthInvalidError(month);
} }
const note = dateNotesService.getMonthNote(month); const note = dateNotesService.getMonthNote(month);
@ -64,7 +64,7 @@ function register(router) {
const {year} = req.params; const {year} = req.params;
if (!/[0-9]{4}/.test(year)) { if (!/[0-9]{4}/.test(year)) {
throw getYearInvalidError(res, year); throw getYearInvalidError(year);
} }
const note = dateNotesService.getYearNote(year); const note = dateNotesService.getYearNote(year);

View File

@ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = filterRootNote(branchIdsToMove); branchIdsToMove = filterRootNote(branchIdsToMove);
branchIdsToMove = filterSearchBranches(branchIdsToMove); branchIdsToMove = filterSearchBranches(branchIdsToMove);
const beforeBranch = await froca.getBranch(beforeBranchId); const beforeBranch = froca.getBranch(beforeBranchId);
if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranch.noteId)) { if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranch.noteId)) {
toastService.showError('Cannot move notes here.'); toastService.showError('Cannot move notes here.');
@ -31,7 +31,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
branchIdsToMove = filterRootNote(branchIdsToMove); branchIdsToMove = filterRootNote(branchIdsToMove);
branchIdsToMove = filterSearchBranches(branchIdsToMove); branchIdsToMove = filterSearchBranches(branchIdsToMove);
const afterNote = await froca.getBranch(afterBranchId).getNote(); const afterNote = froca.getBranch(afterBranchId).getNote();
const forbiddenNoteIds = [ const forbiddenNoteIds = [
'root', 'root',
@ -59,7 +59,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
} }
async function moveToParentNote(branchIdsToMove, newParentBranchId) { async function moveToParentNote(branchIdsToMove, newParentBranchId) {
const newParentBranch = await froca.getBranch(newParentBranchId); const newParentBranch = froca.getBranch(newParentBranchId);
if (newParentBranch.noteId === '_lbRoot') { if (newParentBranch.noteId === '_lbRoot') {
toastService.showError('Cannot move notes here.'); toastService.showError('Cannot move notes here.');

View File

@ -10,7 +10,6 @@ export async function uploadFiles(parentNoteId, files, options) {
} }
const taskId = utils.randomString(10); const taskId = utils.randomString(10);
let noteId;
let counter = 0; let counter = 0;
for (const file of files) { for (const file of files) {
@ -25,7 +24,7 @@ export async function uploadFiles(parentNoteId, files, options) {
formData.append(key, options[key]); formData.append(key, options[key]);
} }
({noteId} = await $.ajax({ await $.ajax({
url: `${baseApiUrl}notes/${parentNoteId}/import`, url: `${baseApiUrl}notes/${parentNoteId}/import`,
headers: await server.getHeaders(), headers: await server.getHeaders(),
data: formData, data: formData,
@ -37,7 +36,7 @@ export async function uploadFiles(parentNoteId, files, options) {
}, },
contentType: false, // NEEDED, DON'T REMOVE THIS contentType: false, // NEEDED, DON'T REMOVE THIS
processData: false, // NEEDED, DON'T REMOVE THIS processData: false, // NEEDED, DON'T REMOVE THIS
})); });
} }
} }
@ -74,4 +73,4 @@ ws.subscribeToMessages(async message => {
export default { export default {
uploadFiles uploadFiles
} };

View File

@ -45,7 +45,7 @@ function formatDateTime(date) {
} }
function localNowDateTime() { function localNowDateTime() {
return dayjs().format('YYYY-MM-DD HH:mm:ss.SSSZZ') return dayjs().format('YYYY-MM-DD HH:mm:ss.SSSZZ');
} }
function now() { function now() {
@ -101,7 +101,7 @@ async function stopWatch(what, func) {
} }
function formatValueWithWhitespace(val) { function formatValueWithWhitespace(val) {
return /[^\w_-]/.test(val) ? `"${val}"` : val; return /[^\w-]/.test(val) ? `"${val}"` : val;
} }
function formatLabel(label) { function formatLabel(label) {
@ -318,7 +318,7 @@ function initHelpDropdown($el) {
initHelpButtons($dropdownMenu); initHelpButtons($dropdownMenu);
} }
const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/" const wikiBaseUrl = "https://github.com/zadam/trilium/wiki/";
function openHelp(e) { function openHelp(e) {
window.open(wikiBaseUrl + $(e.target).attr("data-help-page"), '_blank'); window.open(wikiBaseUrl + $(e.target).attr("data-help-page"), '_blank');
@ -329,7 +329,7 @@ function initHelpButtons($el) {
// so we do it manually // so we do it manually
$el.on("click", e => { $el.on("click", e => {
if ($(e.target).attr("data-help-page")) { if ($(e.target).attr("data-help-page")) {
openHelp(e) openHelp(e);
} }
}); });
} }

View File

@ -1,4 +1,4 @@
"use strict" "use strict";
function formatAttrForSearch(attr, searchWithValue) { function formatAttrForSearch(attr, searchWithValue) {
let searchStr = ''; let searchStr = '';
@ -28,7 +28,7 @@ function formatAttrForSearch(attr, searchWithValue) {
} }
function formatValue(val) { function formatValue(val) {
if (!/[^\w_]/.test(val)) { if (!/[^\w]/.test(val)) {
return val; return val;
} }
else if (!val.includes('"')) { else if (!val.includes('"')) {
@ -47,4 +47,4 @@ function formatValue(val) {
module.exports = { module.exports = {
formatAttrForSearch formatAttrForSearch
} };

View File

@ -122,7 +122,7 @@ function isAttributeType(type) {
function isAttributeDangerous(type, name) { function isAttributeDangerous(type, name) {
return BUILTIN_ATTRIBUTES.some(attr => return BUILTIN_ATTRIBUTES.some(attr =>
attr.type === attr.type && attr.type === type &&
attr.name.toLowerCase() === name.trim().toLowerCase() && attr.name.toLowerCase() === name.trim().toLowerCase() &&
attr.isDangerous attr.isDangerous
); );

View File

@ -389,7 +389,7 @@ function getExpression(tokens, searchContext, level = 0) {
else if (token === 'note') { else if (token === 'note') {
i++; i++;
expressions.push(parseNoteProperty(tokens)); expressions.push(parseNoteProperty());
continue; continue;
} }

View File

@ -288,7 +288,7 @@ function searchNotesForAutocomplete(query) {
noteTitle: beccaService.getNoteTitle(result.noteId), noteTitle: beccaService.getNoteTitle(result.noteId),
notePathTitle: result.notePathTitle, notePathTitle: result.notePathTitle,
highlightedNotePathTitle: result.highlightedNotePathTitle highlightedNotePathTitle: result.highlightedNotePathTitle
} };
}); });
} }
@ -370,7 +370,7 @@ function formatAttribute(attr) {
let label = `#${utils.escapeHtml(attr.name)}`; let label = `#${utils.escapeHtml(attr.name)}`;
if (attr.value) { if (attr.value) {
const val = /[^\w_-]/.test(attr.value) ? `"${attr.value}"` : attr.value; const val = /[^\w-]/.test(attr.value) ? `"${attr.value}"` : attr.value;
label += `=${utils.escapeHtml(val)}`; label += `=${utils.escapeHtml(val)}`;
} }

View File

@ -217,7 +217,7 @@ function wrap(query, func) {
// in these cases error should be simply ignored. // in these cases error should be simply ignored.
console.log(e.message); console.log(e.message);
return null return null;
} }
throw e; throw e;
@ -281,7 +281,7 @@ function fillParamList(paramIds, truncate = true) {
} }
// doing it manually to avoid this showing up on the sloq query list // doing it manually to avoid this showing up on the sloq query list
const s = stmt(`INSERT INTO param_list VALUES ${paramIds.map(paramId => `(?)`).join(',')}`, paramIds); const s = stmt(`INSERT INTO param_list VALUES ${paramIds.map(paramId => `(?)`).join(',')}`);
s.run(paramIds); s.run(paramIds);
} }