diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts index b06e19c6e..68af11651 100644 --- a/apps/client/src/services/utils.ts +++ b/apps/client/src/services/utils.ts @@ -816,6 +816,14 @@ export function mapToKeyValueArray(map: R return values; } +export function getErrorMessage(e: unknown) { + if (e && typeof e === "object" && "message" in e && typeof e.message === "string") { + return e.message; + } else { + return "Unknown error"; + } +} + export default { reloadFrontendApp, restartDesktopApp, diff --git a/apps/client/src/widgets/bulk_actions/note/move_note.tsx b/apps/client/src/widgets/bulk_actions/note/move_note.tsx index ac5829305..4290726ce 100644 --- a/apps/client/src/widgets/bulk_actions/note/move_note.tsx +++ b/apps/client/src/widgets/bulk_actions/note/move_note.tsx @@ -1,11 +1,11 @@ import { t } from "../../../services/i18n.js"; -import AbstractBulkAction, { ActionDefinition } from "../abstract_bulk_action.js"; +import AbstractBulkAction from "../abstract_bulk_action.js"; import BulkAction, { BulkActionText } from "../BulkAction.jsx"; import NoteAutocomplete from "../../react/NoteAutocomplete.jsx"; import { useEffect, useState } from "preact/hooks"; import { useSpacedUpdate } from "../../react/hooks.jsx"; -function MoveNoteBulkActionComponent({ bulkAction, actionDef }: { bulkAction: AbstractBulkAction, actionDef: ActionDefinition }) { +function MoveNoteBulkActionComponent({ bulkAction }: { bulkAction: AbstractBulkAction }) { const [ targetParentNoteId, setTargetParentNoteId ] = useState(); const spacedUpdate = useSpacedUpdate(() => { return bulkAction.saveAction({ targetParentNoteId: targetParentNoteId }) @@ -45,6 +45,6 @@ export default class MoveNoteBulkAction extends AbstractBulkAction { } doRender() { - return + return } } diff --git a/apps/client/src/widgets/bulk_actions/note/rename_note.tsx b/apps/client/src/widgets/bulk_actions/note/rename_note.tsx index 5fe9b8912..682494cd2 100644 --- a/apps/client/src/widgets/bulk_actions/note/rename_note.tsx +++ b/apps/client/src/widgets/bulk_actions/note/rename_note.tsx @@ -1,4 +1,3 @@ -import SpacedUpdate from "../../../services/spaced_update.js"; import AbstractBulkAction, { ActionDefinition } from "../abstract_bulk_action.js"; import { t } from "../../../services/i18n.js"; import BulkAction from "../BulkAction.jsx"; diff --git a/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx b/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx index 5e10933a8..59d222ee8 100644 --- a/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx +++ b/apps/client/src/widgets/bulk_actions/relation/add_relation.tsx @@ -1,6 +1,4 @@ -import SpacedUpdate from "../../../services/spaced_update.js"; import AbstractBulkAction, { ActionDefinition } from "../abstract_bulk_action.js"; -import noteAutocompleteService from "../../../services/note_autocomplete.js"; import { t } from "../../../services/i18n.js"; import BulkAction, { BulkActionText } from "../BulkAction.jsx"; import NoteAutocomplete from "../../react/NoteAutocomplete.jsx"; diff --git a/apps/client/src/widgets/dialogs/about.tsx b/apps/client/src/widgets/dialogs/about.tsx index 2d0d67316..3a13ce869 100644 --- a/apps/client/src/widgets/dialogs/about.tsx +++ b/apps/client/src/widgets/dialogs/about.tsx @@ -10,8 +10,8 @@ import type { AppInfo } from "@triliumnext/commons"; import { useTriliumEvent } from "../react/hooks.jsx"; export default function AboutDialog() { - let [appInfo, setAppInfo] = useState(null); - let [shown, setShown] = useState(false); + const [appInfo, setAppInfo] = useState(null); + const [shown, setShown] = useState(false); const forceWordBreak: CSSProperties = { wordBreak: "break-all" }; useTriliumEvent("openAboutDialog", () => setShown(true)); diff --git a/apps/client/src/widgets/dialogs/delete_notes.tsx b/apps/client/src/widgets/dialogs/delete_notes.tsx index 500737560..b16fafd0a 100644 --- a/apps/client/src/widgets/dialogs/delete_notes.tsx +++ b/apps/client/src/widgets/dialogs/delete_notes.tsx @@ -139,7 +139,7 @@ function BrokenRelations({ brokenRelations }: { brokenRelations: DeleteNotesPrev const noteIds = brokenRelations .map(relation => relation.noteId) .filter(noteId => noteId) as string[]; - froca.getNotes(noteIds).then(async (notes) => { + froca.getNotes(noteIds).then(async () => { const notesWithBrokenRelations: BrokenRelationData[] = []; for (const attr of brokenRelations) { notesWithBrokenRelations.push({ diff --git a/apps/client/src/widgets/dialogs/jump_to_note.tsx b/apps/client/src/widgets/dialogs/jump_to_note.tsx index 6bb9c81a5..cb13e078e 100644 --- a/apps/client/src/widgets/dialogs/jump_to_note.tsx +++ b/apps/client/src/widgets/dialogs/jump_to_note.tsx @@ -25,7 +25,7 @@ export default function JumpToNoteDialogComponent() { async function openDialog(commandMode: boolean) { let newMode: Mode; - let initialText: string = ""; + let initialText = ""; if (commandMode) { newMode = "commands"; diff --git a/apps/client/src/widgets/dialogs/markdown_import.tsx b/apps/client/src/widgets/dialogs/markdown_import.tsx index 5fc8584ad..d14d6fb11 100644 --- a/apps/client/src/widgets/dialogs/markdown_import.tsx +++ b/apps/client/src/widgets/dialogs/markdown_import.tsx @@ -14,8 +14,8 @@ interface RenderMarkdownResponse { export default function MarkdownImportDialog() { const markdownImportTextArea = useRef(null); - let [ text, setText ] = useState(""); - let [ shown, setShown ] = useState(false); + const [ text, setText ] = useState(""); + const [ shown, setShown ] = useState(false); const triggerImport = useCallback(() => { if (appContext.tabManager.getActiveContextNoteType() !== "text") { diff --git a/apps/client/src/widgets/dialogs/note_type_chooser.tsx b/apps/client/src/widgets/dialogs/note_type_chooser.tsx index 19430b2cb..12db7f0c7 100644 --- a/apps/client/src/widgets/dialogs/note_type_chooser.tsx +++ b/apps/client/src/widgets/dialogs/note_type_chooser.tsx @@ -41,7 +41,7 @@ export default function NoteTypeChooserDialogComponent() { note_types.getNoteTypeItems().then(noteTypes => { let index = -1; - setNoteTypes((noteTypes ?? []).map((item, _index) => { + setNoteTypes((noteTypes ?? []).map((item) => { if (item.title === "----") { index++; return { diff --git a/apps/client/src/widgets/dialogs/recent_changes.tsx b/apps/client/src/widgets/dialogs/recent_changes.tsx index 6c8b1fa9d..48222f02c 100644 --- a/apps/client/src/widgets/dialogs/recent_changes.tsx +++ b/apps/client/src/widgets/dialogs/recent_changes.tsx @@ -17,7 +17,7 @@ import { useTriliumEvent } from "../react/hooks"; export default function RecentChangesDialog() { const [ ancestorNoteId, setAncestorNoteId ] = useState(); - const [ groupedByDate, setGroupedByDate ] = useState>(); + const [ groupedByDate, setGroupedByDate ] = useState>(); const [ needsRefresh, setNeedsRefresh ] = useState(false); const [ shown, setShown ] = useState(false); @@ -78,7 +78,7 @@ export default function RecentChangesDialog() { ) } -function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map, setShown: Dispatch> }) { +function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map, setShown: Dispatch> }) { return ( <> { Array.from(groupedByDate.entries()).map(([dateDay, dayChanges]) => { @@ -156,16 +156,18 @@ function DeletedNoteLink({ change, setShown }: { change: RecentChangeRow, setSho } function groupByDate(rows: RecentChangeRow[]) { - const groupedByDate = new Map(); + const groupedByDate = new Map(); for (const row of rows) { const dateDay = row.date.substr(0, 10); - if (!groupedByDate.has(dateDay)) { - groupedByDate.set(dateDay, []); + let dateDayArray = groupedByDate.get(dateDay); + if (!dateDayArray) { + dateDayArray = []; + groupedByDate.set(dateDay, dateDayArray); } - groupedByDate.get(dateDay)!.push(row); + dateDayArray.push(row); } return groupedByDate; diff --git a/apps/client/src/widgets/react/CKEditor.tsx b/apps/client/src/widgets/react/CKEditor.tsx index a9f49d887..27985fda5 100644 --- a/apps/client/src/widgets/react/CKEditor.tsx +++ b/apps/client/src/widgets/react/CKEditor.tsx @@ -1,4 +1,4 @@ -import { CKTextEditor, type AttributeEditor, type EditorConfig, type ModelPosition } from "@triliumnext/ckeditor5"; +import type { CKTextEditor, AttributeEditor, EditorConfig, ModelPosition } from "@triliumnext/ckeditor5"; import { useEffect, useImperativeHandle, useRef } from "preact/compat"; import { MutableRef } from "preact/hooks"; diff --git a/apps/client/src/widgets/react/FormGroup.tsx b/apps/client/src/widgets/react/FormGroup.tsx index 400a2ef7f..701b53c23 100644 --- a/apps/client/src/widgets/react/FormGroup.tsx +++ b/apps/client/src/widgets/react/FormGroup.tsx @@ -8,6 +8,7 @@ interface FormGroupProps { label?: string; title?: string; className?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any children: VNode; description?: string | ComponentChildren; disabled?: boolean; diff --git a/apps/client/src/widgets/react/FormSelect.tsx b/apps/client/src/widgets/react/FormSelect.tsx index 5b38a4c92..6c2340543 100644 --- a/apps/client/src/widgets/react/FormSelect.tsx +++ b/apps/client/src/widgets/react/FormSelect.tsx @@ -65,6 +65,7 @@ function FormSelectBody({ id, name, children, onChange, style, className }: { id return (