From a2b1a8366359668e867101f4fa2fd51f51654e0a Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 2 Jan 2025 11:57:40 +0000 Subject: [PATCH] Lint plugin --- plugin/src/events/obisidan-event-handler.ts | 6 +----- .../apply-remote-changes-locally.ts | 4 +--- plugin/src/tracing/logger.ts | 12 ++++++------ plugin/src/views/history-view.ts | 3 ++- plugin/src/views/logs-view.ts | 16 +++++++++------- plugin/src/views/status-bar.ts | 2 +- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/plugin/src/events/obisidan-event-handler.ts b/plugin/src/events/obisidan-event-handler.ts index 1eea37ed..200ed8a0 100644 --- a/plugin/src/events/obisidan-event-handler.ts +++ b/plugin/src/events/obisidan-event-handler.ts @@ -1,12 +1,8 @@ import type { TAbstractFile } from "obsidian"; import { TFile } from "obsidian"; import type { FileEventHandler } from "./file-event-handler"; -import type { SyncService } from "src/services/sync-service"; -import type { Database } from "src/database/database"; -import type { FileOperations } from "src/file-operations/file-operations"; import { Logger } from "src/tracing/logger"; -import type { SyncHistory } from "src/tracing/sync-history"; -import { Syncer } from "src/sync-operations/syncer"; +import type { Syncer } from "src/sync-operations/syncer"; export class ObsidianFileEventHandler implements FileEventHandler { public constructor(private readonly syncer: Syncer) {} diff --git a/plugin/src/sync-operations/apply-remote-changes-locally.ts b/plugin/src/sync-operations/apply-remote-changes-locally.ts index b988fd1b..088935b5 100644 --- a/plugin/src/sync-operations/apply-remote-changes-locally.ts +++ b/plugin/src/sync-operations/apply-remote-changes-locally.ts @@ -1,9 +1,7 @@ import type { Database } from "src/database/database"; -import type { FileOperations } from "src/file-operations/file-operations"; import type { SyncService } from "src/services/sync-service"; import { Logger } from "src/tracing/logger"; -import type { SyncHistory } from "src/tracing/sync-history"; -import { Syncer } from "./syncer"; +import type { Syncer } from "./syncer"; let isRunning = false; diff --git a/plugin/src/tracing/logger.ts b/plugin/src/tracing/logger.ts index bc51b742..3eb0101c 100644 --- a/plugin/src/tracing/logger.ts +++ b/plugin/src/tracing/logger.ts @@ -33,14 +33,14 @@ export class Logger { public debug(message: string): void { if (process.env.NODE_ENV !== "production") { - console.debug(`${message}`); + console.debug(message); } this.pushMessage(message, LogLevel.DEBUG); } public info(message: string): void { if (process.env.NODE_ENV !== "production") { - console.info(`${message}`); + console.info(message); } this.pushMessage(message, LogLevel.INFO); @@ -48,7 +48,7 @@ export class Logger { public warn(message: string): void { if (process.env.NODE_ENV !== "production") { - console.warn(`${message}`); + console.warn(message); } this.pushMessage(message, LogLevel.WARNING); @@ -56,7 +56,7 @@ export class Logger { public error(message: string): void { if (process.env.NODE_ENV !== "production") { - console.error(`${message}`); + console.error(message); } this.pushMessage(message, LogLevel.ERROR); @@ -77,7 +77,7 @@ export class Logger { public reset(): void { this.messages.length = 0; - this.onMessageListeners.forEach((listener) => listener(undefined)); + this.onMessageListeners.forEach((listener) => { listener(undefined); }); } private pushMessage(message: string, level: LogLevel): void { @@ -88,6 +88,6 @@ export class Logger { this.messages.shift(); } - this.onMessageListeners.forEach((listener) => listener(logLine)); + this.onMessageListeners.forEach((listener) => { listener(logLine); }); } } diff --git a/plugin/src/views/history-view.ts b/plugin/src/views/history-view.ts index 3b8281ae..481c16d2 100644 --- a/plugin/src/views/history-view.ts +++ b/plugin/src/views/history-view.ts @@ -3,7 +3,7 @@ import { ItemView } from "obsidian"; import type { SyncHistory } from "src/tracing/sync-history"; import { SyncSource, SyncStatus } from "src/tracing/sync-history"; import { intlFormatDistance } from "date-fns"; -import { Database } from "src/database/database"; +import type { Database } from "src/database/database"; export class HistoryView extends ItemView { public static readonly TYPE = "history-view"; @@ -30,6 +30,7 @@ export class HistoryView extends ItemView { return " ⤴️"; case SyncSource.PULL: return " ⤵️"; + case undefined: default: return ""; } diff --git a/plugin/src/views/logs-view.ts b/plugin/src/views/logs-view.ts index b2a58a11..f39ba481 100644 --- a/plugin/src/views/logs-view.ts +++ b/plugin/src/views/logs-view.ts @@ -9,7 +9,13 @@ export class LogsView extends ItemView { public constructor(leaf: WorkspaceLeaf) { super(leaf); this.icon = LogsView.ICON; - Logger.getInstance().addOnMessageListener(() => this.updateView()); + Logger.getInstance().addOnMessageListener(() => { + this.updateView(); + }); + } + + private static formatTimestamp(timestamp: Date): string { + return timestamp.toTimeString().split(" ")[0]; } public getViewType(): string { @@ -21,10 +27,10 @@ export class LogsView extends ItemView { } public async onOpen(): Promise { - await this.updateView(); + this.updateView(); } - private async updateView(): Promise { + private updateView(): void { const container = this.containerEl.children[1]; container.empty(); @@ -44,8 +50,4 @@ export class LogsView extends ItemView { messageContainer.createEl("span", { text: message.message }); }); } - - private static formatTimestamp(timestamp: Date): string { - return timestamp.toTimeString().split(" ")[0]; - } } diff --git a/plugin/src/views/status-bar.ts b/plugin/src/views/status-bar.ts index cc214f45..6b1f0cbb 100644 --- a/plugin/src/views/status-bar.ts +++ b/plugin/src/views/status-bar.ts @@ -1,5 +1,5 @@ import type { Plugin } from "obsidian"; -import { Syncer } from "src/sync-operations/syncer"; +import type { Syncer } from "src/sync-operations/syncer"; import type { HistoryStats, SyncHistory } from "src/tracing/sync-history"; export class StatusBar {