From 1391d6fe5e063d4d3c78eebeda9d06259e0697b1 Mon Sep 17 00:00:00 2001 From: Nico <47644445+nicotsx@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:04:37 +0100 Subject: [PATCH] refactor: move from biome to oxlint/oxformat (#311) * chore: install and configure oxlint * chore: fix liniting issues * chore: install and configure oxfmt * ci: add oxlint action instead of biome * chore: pr feedbacks * Revert "chore: pr feedbacks" This reverts commit 525dcd8d9f54e897b7c0208d02b1c561009dcdc1. --- .github/workflows/checks.yml | 7 +- .oxfmtrc.json | 5 + .oxlintrc.json | 150 ++++++++++++++++++ app/client/components/directory-browser.tsx | 2 +- app/client/components/layout.tsx | 2 +- app/client/components/restore-form.tsx | 4 +- app/client/components/snapshots-table.tsx | 6 +- app/client/components/volume-file-browser.tsx | 2 +- app/client/hooks/use-server-events.ts | 10 +- .../auth/routes/download-recovery-key.tsx | 2 +- app/client/modules/auth/routes/login.tsx | 4 +- app/client/modules/auth/routes/onboarding.tsx | 2 +- .../components/create-schedule-form.tsx | 2 +- .../components/snapshot-file-browser.tsx | 2 +- .../modules/backups/routes/backup-details.tsx | 2 +- .../modules/backups/routes/create-backup.tsx | 2 +- .../routes/create-notification.tsx | 2 +- .../routes/notification-details.tsx | 4 +- .../repositories/routes/create-repository.tsx | 2 +- .../routes/repository-details.tsx | 4 +- .../modules/settings/routes/settings.tsx | 2 +- .../modules/volumes/routes/create-volume.tsx | 2 +- .../modules/volumes/routes/volume-details.tsx | 2 +- app/client/modules/volumes/tabs/info.tsx | 2 +- app/root.tsx | 4 +- app/server/core/scheduler.ts | 4 +- app/server/index.ts | 4 +- app/server/jobs/cleanup-sessions.ts | 2 +- .../backups/__tests__/backups.service.test.ts | 2 +- app/server/modules/backups/backups.service.ts | 2 +- .../modules/events/events.controller.ts | 32 ++-- app/server/utils/logger.ts | 4 +- app/server/utils/rclone.ts | 7 +- app/server/utils/restic.ts | 18 +-- app/test/setup.ts | 2 +- biome.json | 43 ----- bun.lock | 74 ++++++--- components.json | 10 +- package.json | 7 +- tsconfig.json | 1 - 40 files changed, 294 insertions(+), 146 deletions(-) create mode 100644 .oxfmtrc.json create mode 100644 .oxlintrc.json delete mode 100644 biome.json diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ba422b66..3c88d2ca 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -25,9 +25,10 @@ jobs: - name: Install dependencies uses: "./.github/actions/install-dependencies" - - name: Run lint - shell: bash - run: bun run lint:ci + - uses: oxc-project/oxlint-action@latest + with: + config: .oxlintrc.json + deny-warnings: true - name: Run type checks shell: bash diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 00000000..98859c34 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,5 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "printWidth": 120, + "useTabs": true +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 00000000..634c4b7c --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,150 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["unicorn", "typescript", "oxc"], + "categories": {}, + "rules": { + "constructor-super": "warn", + "for-direction": "warn", + "no-async-promise-executor": "warn", + "no-caller": "warn", + "no-class-assign": "warn", + "no-compare-neg-zero": "warn", + "no-cond-assign": "warn", + "no-const-assign": "warn", + "no-constant-binary-expression": "warn", + "no-constant-condition": "warn", + "no-control-regex": "warn", + "no-debugger": "warn", + "no-delete-var": "warn", + "no-dupe-class-members": "warn", + "no-dupe-else-if": "warn", + "no-dupe-keys": "warn", + "no-duplicate-case": "warn", + "no-empty-character-class": "warn", + "no-empty-pattern": "warn", + "no-empty-static-block": "warn", + "no-eval": "warn", + "no-ex-assign": "warn", + "no-extra-boolean-cast": "warn", + "no-func-assign": "warn", + "no-global-assign": "warn", + "no-import-assign": "warn", + "no-invalid-regexp": "warn", + "no-irregular-whitespace": "warn", + "no-loss-of-precision": "warn", + "no-new-native-nonconstructor": "warn", + "no-nonoctal-decimal-escape": "warn", + "no-obj-calls": "warn", + "no-self-assign": "warn", + "no-setter-return": "warn", + "no-shadow-restricted-names": "warn", + "no-sparse-arrays": "warn", + "no-this-before-super": "warn", + "no-unassigned-vars": "warn", + "no-unsafe-finally": "warn", + "no-unsafe-negation": "warn", + "no-unsafe-optional-chaining": "warn", + "no-unused-expressions": "warn", + "no-unused-labels": "warn", + "no-unused-private-class-members": "warn", + "no-unused-vars": [ + "warn", + { + "caughtErrorsIgnorePattern": "^_", + "argsIgnorePattern": "^_" + } + ], + "no-useless-backreference": "warn", + "no-useless-catch": "warn", + "no-useless-escape": "warn", + "no-useless-rename": "warn", + "no-with": "warn", + "require-yield": "warn", + "use-isnan": "warn", + "valid-typeof": "warn", + "oxc/bad-array-method-on-arguments": "warn", + "oxc/bad-char-at-comparison": "warn", + "oxc/bad-comparison-sequence": "warn", + "oxc/bad-min-max-func": "warn", + "oxc/bad-object-literal-comparison": "warn", + "oxc/bad-replace-all-arg": "warn", + "oxc/const-comparisons": "warn", + "oxc/double-comparisons": "warn", + "oxc/erasing-op": "warn", + "oxc/missing-throw": "warn", + "oxc/number-arg-out-of-range": "warn", + "oxc/only-used-in-recursion": "warn", + "oxc/uninvoked-array-callback": "warn", + "typescript/await-thenable": "warn", + "typescript/no-array-delete": "warn", + "typescript/no-base-to-string": "warn", + "typescript/no-duplicate-enum-values": "warn", + "typescript/no-duplicate-type-constituents": "warn", + "typescript/no-extra-non-null-assertion": "warn", + "typescript/no-floating-promises": "warn", + "typescript/no-for-in-array": "warn", + "typescript/no-implied-eval": "warn", + "typescript/no-meaningless-void-operator": "warn", + "typescript/no-misused-new": "warn", + "typescript/no-misused-spread": "warn", + "typescript/no-non-null-asserted-optional-chain": "warn", + "typescript/no-redundant-type-constituents": "warn", + "typescript/no-this-alias": "warn", + "typescript/no-unnecessary-parameter-property-assignment": "warn", + "typescript/no-unsafe-declaration-merging": "warn", + "typescript/no-unsafe-unary-minus": "warn", + "typescript/no-useless-empty-export": "warn", + "typescript/no-wrapper-object-types": "warn", + "typescript/prefer-as-const": "warn", + "typescript/require-array-sort-compare": "warn", + "typescript/restrict-template-expressions": "warn", + "typescript/triple-slash-reference": "warn", + "typescript/unbound-method": "warn", + "unicorn/no-await-in-promise-methods": "warn", + "unicorn/no-empty-file": "warn", + "unicorn/no-invalid-fetch-options": "warn", + "unicorn/no-invalid-remove-event-listener": "warn", + "unicorn/no-new-array": "warn", + "unicorn/no-single-promise-in-promise-methods": "warn", + "unicorn/no-thenable": "warn", + "unicorn/no-unnecessary-await": "warn", + "unicorn/no-useless-fallback-in-spread": "warn", + "unicorn/no-useless-length-check": "warn", + "unicorn/no-useless-spread": "warn", + "unicorn/prefer-set-size": "warn", + "unicorn/prefer-string-starts-ends-with": "warn" + }, + "settings": { + "jsx-a11y": { + "polymorphicPropName": null, + "components": {}, + "attributes": {} + }, + "next": { + "rootDir": [] + }, + "react": { + "formComponents": [], + "linkComponents": [], + "version": null + }, + "jsdoc": { + "ignorePrivate": false, + "ignoreInternal": false, + "ignoreReplacesDocs": true, + "overrideReplacesDocs": true, + "augmentsExtendsReplacesDocs": false, + "implementsReplacesDocs": false, + "exemptDestructuredRootsFromChecks": false, + "tagNamePreference": {} + }, + "vitest": { + "typecheck": false + } + }, + "env": { + "builtin": true + }, + "globals": {}, + "ignorePatterns": ["**/api-client/**"] +} diff --git a/app/client/components/directory-browser.tsx b/app/client/components/directory-browser.tsx index 002b8a47..bfea00b3 100644 --- a/app/client/components/directory-browser.tsx +++ b/app/client/components/directory-browser.tsx @@ -23,7 +23,7 @@ export const DirectoryBrowser = ({ onSelectPath, selectedPath }: Props) => { return await queryClient.ensureQueryData(browseFilesystemOptions({ query: { path } })); }, prefetchFolder: (path) => { - queryClient.prefetchQuery(browseFilesystemOptions({ query: { path } })); + void queryClient.prefetchQuery(browseFilesystemOptions({ query: { path } })); }, }); diff --git a/app/client/components/layout.tsx b/app/client/components/layout.tsx index 6030391d..3868bd9e 100644 --- a/app/client/components/layout.tsx +++ b/app/client/components/layout.tsx @@ -30,7 +30,7 @@ export default function Layout({ loaderData }: Route.ComponentProps) { const logout = useMutation({ ...logoutMutation(), onSuccess: async () => { - navigate("/login", { replace: true }); + void navigate("/login", { replace: true }); }, onError: (error) => { console.error(error); diff --git a/app/client/components/restore-form.tsx b/app/client/components/restore-form.tsx index 55a6d0ce..37d6d55e 100644 --- a/app/client/components/restore-form.tsx +++ b/app/client/components/restore-form.tsx @@ -83,7 +83,7 @@ export function RestoreForm({ snapshot, repository, snapshotId, returnPath }: Re ); }, prefetchFolder: (path) => { - queryClient.prefetchQuery( + void queryClient.prefetchQuery( listSnapshotFilesOptions({ path: { id: repository.id, snapshotId }, query: { path }, @@ -102,7 +102,7 @@ export function RestoreForm({ snapshot, repository, snapshotId, returnPath }: Re toast.success("Restore completed", { description: `Successfully restored ${data.filesRestored} file(s). ${data.filesSkipped} file(s) skipped.`, }); - navigate(returnPath); + void navigate(returnPath); }, onError: (error) => { toast.error("Restore failed", { description: error.message || "Failed to restore snapshot" }); diff --git a/app/client/components/snapshots-table.tsx b/app/client/components/snapshots-table.tsx index 0f8574bb..2e3b7f79 100644 --- a/app/client/components/snapshots-table.tsx +++ b/app/client/components/snapshots-table.tsx @@ -50,7 +50,7 @@ export const SnapshotsTable = ({ snapshots, repositoryId, backups }: Props) => { const deleteSnapshots = useMutation({ ...deleteSnapshotsMutation(), onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ["listSnapshots"] }); + void queryClient.invalidateQueries({ queryKey: ["listSnapshots"] }); setShowBulkDeleteConfirm(false); setSelectedIds(new Set()); }, @@ -62,7 +62,7 @@ export const SnapshotsTable = ({ snapshots, repositoryId, backups }: Props) => { setShowReTagDialog(false); }, onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ["listSnapshots"] }); + void queryClient.invalidateQueries({ queryKey: ["listSnapshots"] }); setShowReTagDialog(false); setSelectedIds(new Set()); setTargetScheduleId(""); @@ -70,7 +70,7 @@ export const SnapshotsTable = ({ snapshots, repositoryId, backups }: Props) => { }); const handleRowClick = (snapshotId: string) => { - navigate(`/repositories/${repositoryId}/${snapshotId}`); + void navigate(`/repositories/${repositoryId}/${snapshotId}`); }; const toggleSelectAll = () => { diff --git a/app/client/components/volume-file-browser.tsx b/app/client/components/volume-file-browser.tsx index 6e9cd53e..78327270 100644 --- a/app/client/components/volume-file-browser.tsx +++ b/app/client/components/volume-file-browser.tsx @@ -46,7 +46,7 @@ export const VolumeFileBrowser = ({ ); }, prefetchFolder: (path) => { - queryClient.prefetchQuery( + void queryClient.prefetchQuery( listFilesOptions({ path: { name: volumeName }, query: { path }, diff --git a/app/client/hooks/use-server-events.ts b/app/client/hooks/use-server-events.ts index d7c03777..211d33dc 100644 --- a/app/client/hooks/use-server-events.ts +++ b/app/client/hooks/use-server-events.ts @@ -87,8 +87,8 @@ export function useServerEvents() { const data = JSON.parse(e.data) as BackupEvent; console.log("[SSE] Backup completed:", data); - queryClient.invalidateQueries(); - queryClient.refetchQueries(); + void queryClient.invalidateQueries(); + void queryClient.refetchQueries(); handlersRef.current.get("backup:completed")?.forEach((handler) => { handler(data); @@ -117,7 +117,7 @@ export function useServerEvents() { const data = JSON.parse(e.data) as VolumeEvent; console.log("[SSE] Volume updated:", data); - queryClient.invalidateQueries(); + void queryClient.invalidateQueries(); handlersRef.current.get("volume:updated")?.forEach((handler) => { handler(data); @@ -128,7 +128,7 @@ export function useServerEvents() { const data = JSON.parse(e.data) as VolumeEvent; console.log("[SSE] Volume status updated:", data); - queryClient.invalidateQueries(); + void queryClient.invalidateQueries(); handlersRef.current.get("volume:updated")?.forEach((handler) => { handler(data); @@ -149,7 +149,7 @@ export function useServerEvents() { console.log("[SSE] Mirror copy completed:", data); // Invalidate queries to refresh mirror status in the UI - queryClient.invalidateQueries(); + void queryClient.invalidateQueries(); handlersRef.current.get("mirror:completed")?.forEach((handler) => { handler(data); diff --git a/app/client/modules/auth/routes/download-recovery-key.tsx b/app/client/modules/auth/routes/download-recovery-key.tsx index 5235702a..af29dd05 100644 --- a/app/client/modules/auth/routes/download-recovery-key.tsx +++ b/app/client/modules/auth/routes/download-recovery-key.tsx @@ -42,7 +42,7 @@ export default function DownloadRecoveryKeyPage() { window.URL.revokeObjectURL(url); toast.success("Recovery key downloaded successfully!"); - navigate("/volumes", { replace: true }); + void navigate("/volumes", { replace: true }); }, onError: (error) => { toast.error("Failed to download recovery key", { description: error.message }); diff --git a/app/client/modules/auth/routes/login.tsx b/app/client/modules/auth/routes/login.tsx index b62e0cca..984d8130 100644 --- a/app/client/modules/auth/routes/login.tsx +++ b/app/client/modules/auth/routes/login.tsx @@ -49,9 +49,9 @@ export default function LoginPage() { ...loginMutation(), onSuccess: async (data) => { if (data.user && !data.user.hasDownloadedResticPassword) { - navigate("/download-recovery-key"); + void navigate("/download-recovery-key"); } else { - navigate("/volumes"); + void navigate("/volumes"); } }, onError: (error) => { diff --git a/app/client/modules/auth/routes/onboarding.tsx b/app/client/modules/auth/routes/onboarding.tsx index cb72ed60..f95356f9 100644 --- a/app/client/modules/auth/routes/onboarding.tsx +++ b/app/client/modules/auth/routes/onboarding.tsx @@ -56,7 +56,7 @@ export default function OnboardingPage() { ...registerMutation(), onSuccess: async () => { toast.success("Admin user created successfully!"); - navigate("/download-recovery-key"); + void navigate("/download-recovery-key"); }, onError: (error) => { console.error(error); diff --git a/app/client/modules/backups/components/create-schedule-form.tsx b/app/client/modules/backups/components/create-schedule-form.tsx index 63d3a8e0..8e2a088b 100644 --- a/app/client/modules/backups/components/create-schedule-form.tsx +++ b/app/client/modules/backups/components/create-schedule-form.tsx @@ -728,7 +728,7 @@ export const CreateScheduleForm = ({ initialValues, formId, onSubmit, volume }: .filter(([key, value]) => key.startsWith("keep") && Boolean(value)) .map(([key, value]) => { const label = key.replace("keep", "").toLowerCase(); - return `${value} ${label}`; + return `${value.toString()} ${label}`; }) .join(", ") || "-"}
diff --git a/app/client/modules/backups/components/snapshot-file-browser.tsx b/app/client/modules/backups/components/snapshot-file-browser.tsx index 6935c8e6..185b0ed3 100644 --- a/app/client/modules/backups/components/snapshot-file-browser.tsx +++ b/app/client/modules/backups/components/snapshot-file-browser.tsx @@ -68,7 +68,7 @@ export const SnapshotFileBrowser = (props: Props) => { ); }, prefetchFolder: (path) => { - queryClient.prefetchQuery( + void queryClient.prefetchQuery( listSnapshotFilesOptions({ path: { id: repositoryId, snapshotId: snapshot.short_id }, query: { path }, diff --git a/app/client/modules/backups/routes/backup-details.tsx b/app/client/modules/backups/routes/backup-details.tsx index d7b6b841..1e218979 100644 --- a/app/client/modules/backups/routes/backup-details.tsx +++ b/app/client/modules/backups/routes/backup-details.tsx @@ -120,7 +120,7 @@ export default function ScheduleDetailsPage({ params, loaderData }: Route.Compon ...deleteBackupScheduleMutation(), onSuccess: () => { toast.success("Backup schedule deleted successfully"); - navigate("/backups"); + void navigate("/backups"); }, onError: (error) => { toast.error("Failed to delete backup schedule", { description: parseError(error)?.message }); diff --git a/app/client/modules/backups/routes/create-backup.tsx b/app/client/modules/backups/routes/create-backup.tsx index a7a12e1d..9fc686bb 100644 --- a/app/client/modules/backups/routes/create-backup.tsx +++ b/app/client/modules/backups/routes/create-backup.tsx @@ -59,7 +59,7 @@ export default function CreateBackup({ loaderData }: Route.ComponentProps) { ...createBackupScheduleMutation(), onSuccess: (data) => { toast.success("Backup job created successfully"); - navigate(`/backups/${data.id}`); + void navigate(`/backups/${data.id}`); }, onError: (error) => { toast.error("Failed to create backup job", { diff --git a/app/client/modules/notifications/routes/create-notification.tsx b/app/client/modules/notifications/routes/create-notification.tsx index 72268a6b..c6db625c 100644 --- a/app/client/modules/notifications/routes/create-notification.tsx +++ b/app/client/modules/notifications/routes/create-notification.tsx @@ -33,7 +33,7 @@ export default function CreateNotification() { ...createNotificationDestinationMutation(), onSuccess: () => { toast.success("Notification destination created successfully"); - navigate(`/notifications`); + void navigate(`/notifications`); }, }); diff --git a/app/client/modules/notifications/routes/notification-details.tsx b/app/client/modules/notifications/routes/notification-details.tsx index ba6ea340..3aae456b 100644 --- a/app/client/modules/notifications/routes/notification-details.tsx +++ b/app/client/modules/notifications/routes/notification-details.tsx @@ -24,7 +24,7 @@ import { getNotificationDestination } from "~/client/api-client/sdk.gen"; import type { Route } from "./+types/notification-details"; import { cn } from "~/client/lib/utils"; import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card"; -import { Bell, Save, TestTube2, Trash2, X } from "lucide-react"; +import { Bell, Save, TestTube2, Trash2 } from "lucide-react"; import { Alert, AlertDescription } from "~/client/components/ui/alert"; import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form"; @@ -66,7 +66,7 @@ export default function NotificationDetailsPage({ loaderData }: Route.ComponentP ...deleteNotificationDestinationMutation(), onSuccess: () => { toast.success("Notification destination deleted successfully"); - navigate("/notifications"); + void navigate("/notifications"); }, onError: (error) => { toast.error("Failed to delete notification destination", { diff --git a/app/client/modules/repositories/routes/create-repository.tsx b/app/client/modules/repositories/routes/create-repository.tsx index 9d65b084..cad73dc4 100644 --- a/app/client/modules/repositories/routes/create-repository.tsx +++ b/app/client/modules/repositories/routes/create-repository.tsx @@ -36,7 +36,7 @@ export default function CreateRepository() { ...createRepositoryMutation(), onSuccess: (data) => { toast.success("Repository created successfully"); - navigate(`/repositories/${data.repository.shortId}`); + void navigate(`/repositories/${data.repository.shortId}`); }, }); diff --git a/app/client/modules/repositories/routes/repository-details.tsx b/app/client/modules/repositories/routes/repository-details.tsx index cfd52963..53f61a77 100644 --- a/app/client/modules/repositories/routes/repository-details.tsx +++ b/app/client/modules/repositories/routes/repository-details.tsx @@ -67,14 +67,14 @@ export default function RepositoryDetailsPage({ loaderData }: Route.ComponentPro }); useEffect(() => { - queryClient.prefetchQuery(listSnapshotsOptions({ path: { id: data.id } })); + void queryClient.prefetchQuery(listSnapshotsOptions({ path: { id: data.id } })); }, [queryClient, data.id]); const deleteRepo = useMutation({ ...deleteRepositoryMutation(), onSuccess: () => { toast.success("Repository deleted successfully"); - navigate("/repositories"); + void navigate("/repositories"); }, onError: (error) => { toast.error("Failed to delete repository", { diff --git a/app/client/modules/settings/routes/settings.tsx b/app/client/modules/settings/routes/settings.tsx index aca29aaf..19b1f022 100644 --- a/app/client/modules/settings/routes/settings.tsx +++ b/app/client/modules/settings/routes/settings.tsx @@ -54,7 +54,7 @@ export default function Settings({ loaderData }: Route.ComponentProps) { const logout = useMutation({ ...logoutMutation(), onSuccess: () => { - navigate("/login", { replace: true }); + void navigate("/login", { replace: true }); }, }); diff --git a/app/client/modules/volumes/routes/create-volume.tsx b/app/client/modules/volumes/routes/create-volume.tsx index e2faf6a6..46bbec06 100644 --- a/app/client/modules/volumes/routes/create-volume.tsx +++ b/app/client/modules/volumes/routes/create-volume.tsx @@ -33,7 +33,7 @@ export default function CreateVolume() { ...createVolumeMutation(), onSuccess: (data) => { toast.success("Volume created successfully"); - navigate(`/volumes/${data.name}`); + void navigate(`/volumes/${data.name}`); }, }); diff --git a/app/client/modules/volumes/routes/volume-details.tsx b/app/client/modules/volumes/routes/volume-details.tsx index 61131a9f..f2b3da4a 100644 --- a/app/client/modules/volumes/routes/volume-details.tsx +++ b/app/client/modules/volumes/routes/volume-details.tsx @@ -75,7 +75,7 @@ export default function VolumeDetails({ loaderData }: Route.ComponentProps) { ...deleteVolumeMutation(), onSuccess: () => { toast.success("Volume deleted successfully"); - navigate("/volumes"); + void navigate("/volumes"); }, onError: (error) => { toast.error("Failed to delete volume", { diff --git a/app/client/modules/volumes/tabs/info.tsx b/app/client/modules/volumes/tabs/info.tsx index 79a9c200..c960ba6c 100644 --- a/app/client/modules/volumes/tabs/info.tsx +++ b/app/client/modules/volumes/tabs/info.tsx @@ -37,7 +37,7 @@ export const VolumeInfoTabContent = ({ volume, statfs }: Props) => { setPendingValues(null); if (data.name !== volume.name) { - navigate(`/volumes/${data.name}`); + void navigate(`/volumes/${data.name}`); } }, onError: (error) => { diff --git a/app/root.tsx b/app/root.tsx index 85ac9b95..2bb3ac81 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -27,11 +27,11 @@ export const links: Route.LinksFunction = () => [ const queryClient = new QueryClient({ mutationCache: new MutationCache({ onSuccess: () => { - queryClient.invalidateQueries(); + void queryClient.invalidateQueries(); }, onError: (error) => { console.error("Mutation error:", error); - queryClient.invalidateQueries(); + void queryClient.invalidateQueries(); }, }), }); diff --git a/app/server/core/scheduler.ts b/app/server/core/scheduler.ts index bb066c51..d115fbeb 100644 --- a/app/server/core/scheduler.ts +++ b/app/server/core/scheduler.ts @@ -34,7 +34,7 @@ class SchedulerClass { async stop() { for (const task of this.tasks) { - task.stop(); + await task.stop(); } this.tasks = []; logger.info("Scheduler stopped"); @@ -42,7 +42,7 @@ class SchedulerClass { async clear() { for (const task of this.tasks) { - task.destroy(); + await task.destroy(); } this.tasks = []; logger.info("Scheduler cleared all tasks"); diff --git a/app/server/index.ts b/app/server/index.ts index 205180e0..52beea7c 100644 --- a/app/server/index.ts +++ b/app/server/index.ts @@ -22,9 +22,7 @@ runDbMigrations(); await retagSnapshots(); await validateRequiredMigrations(REQUIRED_MIGRATIONS); -startup(); - -logger.info(`Server is running at http://localhost:${config.port}`); +await startup(); export type AppType = typeof app; diff --git a/app/server/jobs/cleanup-sessions.ts b/app/server/jobs/cleanup-sessions.ts index 09ec34c9..e457f1ce 100644 --- a/app/server/jobs/cleanup-sessions.ts +++ b/app/server/jobs/cleanup-sessions.ts @@ -3,7 +3,7 @@ import { authService } from "../modules/auth/auth.service"; export class CleanupSessionsJob extends Job { async run() { - authService.cleanupExpiredSessions(); + await authService.cleanupExpiredSessions(); return { done: true, timestamp: new Date() }; } diff --git a/app/server/modules/backups/__tests__/backups.service.test.ts b/app/server/modules/backups/__tests__/backups.service.test.ts index 75933fc1..2c70f82e 100644 --- a/app/server/modules/backups/__tests__/backups.service.test.ts +++ b/app/server/modules/backups/__tests__/backups.service.test.ts @@ -101,7 +101,7 @@ describe("execute backup", () => { }); // act - backupsService.executeBackup(schedule.id); + void backupsService.executeBackup(schedule.id); await new Promise((resolve) => setTimeout(resolve, 10)); await backupsService.executeBackup(schedule.id); diff --git a/app/server/modules/backups/backups.service.ts b/app/server/modules/backups/backups.service.ts index 6c29f739..d18e507b 100644 --- a/app/server/modules/backups/backups.service.ts +++ b/app/server/modules/backups/backups.service.ts @@ -28,7 +28,7 @@ const calculateNextRun = (cronExpression: string): number => { return interval.next().getTime(); } catch (error) { - logger.error(`Failed to parse cron expression "${cronExpression}": ${error}`); + logger.error(`Failed to parse cron expression "${cronExpression}": ${toMessage(error)}`); const fallback = new Date(); fallback.setMinutes(fallback.getMinutes() + 1); return fallback.getTime(); diff --git a/app/server/modules/events/events.controller.ts b/app/server/modules/events/events.controller.ts index 4661e133..f7991735 100644 --- a/app/server/modules/events/events.controller.ts +++ b/app/server/modules/events/events.controller.ts @@ -13,14 +13,14 @@ export const eventsController = new Hono().use(requireAuth).get("/", (c) => { event: "connected", }); - const onBackupStarted = (data: { scheduleId: number; volumeName: string; repositoryName: string }) => { - stream.writeSSE({ + const onBackupStarted = async (data: { scheduleId: number; volumeName: string; repositoryName: string }) => { + await stream.writeSSE({ data: JSON.stringify(data), event: "backup:started", }); }; - const onBackupProgress = (data: { + const onBackupProgress = async (data: { scheduleId: number; volumeName: string; repositoryName: string; @@ -32,60 +32,60 @@ export const eventsController = new Hono().use(requireAuth).get("/", (c) => { bytes_done: number; current_files: string[]; }) => { - stream.writeSSE({ + await stream.writeSSE({ data: JSON.stringify(data), event: "backup:progress", }); }; - const onBackupCompleted = (data: { + const onBackupCompleted = async (data: { scheduleId: number; volumeName: string; repositoryName: string; status: "success" | "error" | "stopped" | "warning"; }) => { - stream.writeSSE({ + await stream.writeSSE({ data: JSON.stringify(data), event: "backup:completed", }); }; - const onVolumeMounted = (data: { volumeName: string }) => { - stream.writeSSE({ + const onVolumeMounted = async (data: { volumeName: string }) => { + await stream.writeSSE({ data: JSON.stringify(data), event: "volume:mounted", }); }; - const onVolumeUnmounted = (data: { volumeName: string }) => { - stream.writeSSE({ + const onVolumeUnmounted = async (data: { volumeName: string }) => { + await stream.writeSSE({ data: JSON.stringify(data), event: "volume:unmounted", }); }; - const onVolumeUpdated = (data: { volumeName: string }) => { - stream.writeSSE({ + const onVolumeUpdated = async (data: { volumeName: string }) => { + await stream.writeSSE({ data: JSON.stringify(data), event: "volume:updated", }); }; - const onMirrorStarted = (data: { scheduleId: number; repositoryId: string; repositoryName: string }) => { - stream.writeSSE({ + const onMirrorStarted = async (data: { scheduleId: number; repositoryId: string; repositoryName: string }) => { + await stream.writeSSE({ data: JSON.stringify(data), event: "mirror:started", }); }; - const onMirrorCompleted = (data: { + const onMirrorCompleted = async (data: { scheduleId: number; repositoryId: string; repositoryName: string; status: "success" | "error"; error?: string; }) => { - stream.writeSSE({ + await stream.writeSSE({ data: JSON.stringify(data), event: "mirror:completed", }); diff --git a/app/server/utils/logger.ts b/app/server/utils/logger.ts index ecc323b2..6d106f60 100644 --- a/app/server/utils/logger.ts +++ b/app/server/utils/logger.ts @@ -3,7 +3,7 @@ import { sanitizeSensitiveData } from "./sanitize"; const { printf, combine, colorize } = format; -const printConsole = printf((info) => `${info.level} > ${info.message}`); +const printConsole = printf((info) => `${info.level} > ${String(info.message)}`); const consoleFormat = combine(colorize(), printConsole); const getDefaultLevel = () => { @@ -27,7 +27,7 @@ const log = (level: "info" | "warn" | "error" | "debug", messages: unknown[]) => return sanitizeSensitiveData(JSON.stringify(m, null, 2)); } - return sanitizeSensitiveData(String(m)); + return sanitizeSensitiveData(String(JSON.stringify(m))); }); winstonLogger.log(level, stringMessages.join(" ")); diff --git a/app/server/utils/rclone.ts b/app/server/utils/rclone.ts index 92beeccc..4e6470d0 100644 --- a/app/server/utils/rclone.ts +++ b/app/server/utils/rclone.ts @@ -1,5 +1,6 @@ import { $ } from "bun"; import { logger } from "./logger"; +import { toMessage } from "./errors"; /** * List all configured rclone remotes @@ -9,7 +10,7 @@ export async function listRcloneRemotes(): Promise