diff --git a/frontend/deterministic-tests/src/deterministic-agent.ts b/frontend/deterministic-tests/src/deterministic-agent.ts index f253186a..da1435b0 100644 --- a/frontend/deterministic-tests/src/deterministic-agent.ts +++ b/frontend/deterministic-tests/src/deterministic-agent.ts @@ -192,6 +192,10 @@ export class DeterministicAgent extends debugging.InMemoryFileSystem { const isNew = !this.files.has(path); await super.write(path, content); + if (!this.isSyncEnabled) { + return; + } + if (isNew) { this.enqueueSync(async () => { this.client.syncLocallyCreatedFile(path); @@ -208,9 +212,11 @@ export class DeterministicAgent extends debugging.InMemoryFileSystem { updater: (current: TextWithCursors) => TextWithCursors ): Promise { const result = await super.atomicUpdateText(path, updater); - this.enqueueSync(async () => { - this.client.syncLocallyUpdatedFile({ relativePath: path }); - }); + if (this.isSyncEnabled) { + this.enqueueSync(async () => { + this.client.syncLocallyUpdatedFile({ relativePath: path }); + }); + } return result; } @@ -228,12 +234,14 @@ export class DeterministicAgent extends debugging.InMemoryFileSystem { newPath: RelativePath ): Promise { await super.rename(oldPath, newPath); - this.enqueueSync(async () => { - this.client.syncLocallyUpdatedFile({ - oldPath, - relativePath: newPath + if (this.isSyncEnabled) { + this.enqueueSync(async () => { + this.client.syncLocallyUpdatedFile({ + oldPath, + relativePath: newPath + }); }); - }); + } } private async waitForWebSocket(): Promise { diff --git a/frontend/deterministic-tests/src/parse-concurrency.ts b/frontend/deterministic-tests/src/parse-concurrency.ts index a6622a04..3250f7cf 100644 --- a/frontend/deterministic-tests/src/parse-concurrency.ts +++ b/frontend/deterministic-tests/src/parse-concurrency.ts @@ -8,7 +8,7 @@ export function parseConcurrency(): number { i + 1 < args.length ) { const n = parseInt(args[i + 1], 10); - if (!isNaN(n) && n > 0) return n; + if (!isNaN(n) && n > 0) {return n;} } } return os.cpus().length; diff --git a/frontend/deterministic-tests/src/server-manager.ts b/frontend/deterministic-tests/src/server-manager.ts index e9ca3d57..68174c56 100644 --- a/frontend/deterministic-tests/src/server-manager.ts +++ b/frontend/deterministic-tests/src/server-manager.ts @@ -19,7 +19,7 @@ export class ServerManager { } public async stopAll(): Promise { - if (this.isShuttingDown) return; + if (this.isShuttingDown) {return;} this.isShuttingDown = true; const servers = Array.from(this.activeServers); diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs index 61a8bade..eed30760 100644 --- a/frontend/eslint.config.mjs +++ b/frontend/eslint.config.mjs @@ -19,6 +19,7 @@ export default [ rules: { "no-console": "error", "no-unused-vars": "off", + "curly": ["error", "all"], "@typescript-eslint/restrict-template-expressions": "off", "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-floating-promises": [ diff --git a/frontend/obsidian-plugin/src/views/cursors/file-explorer.ts b/frontend/obsidian-plugin/src/views/cursors/file-explorer.ts index fa8e0803..cddad54d 100644 --- a/frontend/obsidian-plugin/src/views/cursors/file-explorer.ts +++ b/frontend/obsidian-plugin/src/views/cursors/file-explorer.ts @@ -14,7 +14,7 @@ export function renderCursorsInFileExplorer( app: App ): void { const fileExplorers = app.workspace.getLeavesOfType("file-explorer"); - if (fileExplorers.length == 0) return; + if (fileExplorers.length == 0) {return;} const [fileExplorer] = fileExplorers; diff --git a/frontend/sync-client/src/services/sync-service.ts b/frontend/sync-client/src/services/sync-service.ts index 228cc2f2..faada477 100644 --- a/frontend/sync-client/src/services/sync-service.ts +++ b/frontend/sync-client/src/services/sync-service.ts @@ -70,7 +70,7 @@ export class SyncService { response: Response, operation: string ): Promise { - if (response.ok) return; + if (response.ok) {return;} const message = `Failed to ${operation}: ${await SyncService.errorFromResponse(response)}`; // 429 is the only 4xx the server uses for *transient* contention // (`WriteBusyError` → HTTP 429). Every other 4xx means the request diff --git a/frontend/sync-client/src/sync-operations/conflict-path.ts b/frontend/sync-client/src/sync-operations/conflict-path.ts index adc1bea1..84efbfe2 100644 --- a/frontend/sync-client/src/sync-operations/conflict-path.ts +++ b/frontend/sync-client/src/sync-operations/conflict-path.ts @@ -17,7 +17,7 @@ function truncateFileNameToByteLimit( maxBytes: number ): string { const encoder = new TextEncoder(); - if (encoder.encode(fileName).byteLength <= maxBytes) return fileName; + if (encoder.encode(fileName).byteLength <= maxBytes) {return fileName;} const dotIndex = fileName.lastIndexOf("."); // Dotfile (starts with "." and nothing else) → no extension to preserve. @@ -35,7 +35,7 @@ function truncateFileNameToByteLimit( let usedBytes = 0; for (const { segment } of segmenter.segment(stem)) { const segmentBytes = encoder.encode(segment).byteLength; - if (usedBytes + segmentBytes > stemBudget) break; + if (usedBytes + segmentBytes > stemBudget) {break;} truncatedStem += segment; usedBytes += segmentBytes; } diff --git a/frontend/sync-client/src/sync-operations/expected-fs-events.ts b/frontend/sync-client/src/sync-operations/expected-fs-events.ts index 01d90b79..22c229e7 100644 --- a/frontend/sync-client/src/sync-operations/expected-fs-events.ts +++ b/frontend/sync-client/src/sync-operations/expected-fs-events.ts @@ -90,9 +90,9 @@ export class ExpectedFsEvents { key: RelativePath ): boolean { const count = map.get(key) ?? 0; - if (count === 0) return false; - if (count === 1) map.delete(key); - else map.set(key, count - 1); + if (count === 0) {return false;} + if (count === 1) {map.delete(key);} + else {map.set(key, count - 1);} return true; } } diff --git a/frontend/sync-client/src/sync-operations/offline-change-detector.ts b/frontend/sync-client/src/sync-operations/offline-change-detector.ts index b3cb4dd1..534e35c5 100644 --- a/frontend/sync-client/src/sync-operations/offline-change-detector.ts +++ b/frontend/sync-client/src/sync-operations/offline-change-detector.ts @@ -72,7 +72,7 @@ export async function scheduleOfflineChanges( } for (const path of locallyPossibleCreatedFiles) { - if (renamedPaths.has(path)) continue; + if (renamedPaths.has(path)) {continue;} logger.info( `File ${path} was created while offline, scheduling sync to create it` diff --git a/frontend/sync-client/src/sync-operations/sync-event-queue.ts b/frontend/sync-client/src/sync-operations/sync-event-queue.ts index d362b533..c841fc0b 100644 --- a/frontend/sync-client/src/sync-operations/sync-event-queue.ts +++ b/frontend/sync-client/src/sync-operations/sync-event-queue.ts @@ -17,7 +17,7 @@ import { import { MinCovered } from "../utils/data-structures/min-covered"; export class SyncEventQueue { - private _lastSeenUpdateId: MinCovered; + private readonly _lastSeenUpdateId: MinCovered; // Latest state of the filesystem as we know it, excluding // unconfirmed creates but including pending deletes. @@ -441,7 +441,7 @@ export class SyncEventQueue { newPath: RelativePath ): void { const createEvent = this.findLatestCreateForPath(oldPath); - if (createEvent === undefined) return; + if (createEvent === undefined) {return;} const { promise } = createEvent.resolvers; createEvent.path = newPath; diff --git a/frontend/sync-client/src/sync-operations/syncer.ts b/frontend/sync-client/src/sync-operations/syncer.ts index fd924c15..fffa0300 100644 --- a/frontend/sync-client/src/sync-operations/syncer.ts +++ b/frontend/sync-client/src/sync-operations/syncer.ts @@ -217,8 +217,8 @@ export class Syncer { } private ensureDraining(): void { - if (this.drainPromise !== undefined) return; - if (this.isScanning) return; + if (this.drainPromise !== undefined) {return;} + if (this.isScanning) {return;} this.drainPromise = this.drain().finally(() => { this.drainPromise = undefined; }); @@ -329,7 +329,7 @@ export class Syncer { relativePath = event.path; break; case SyncEventType.RemoteChange: - if (event.remoteVersion.isDeleted) return false; + if (event.remoteVersion.isDeleted) {return false;} sizeInBytes = event.remoteVersion.contentSize; ({ relativePath } = event.remoteVersion); break; @@ -339,7 +339,7 @@ export class Syncer { sizeInBytes, relativePath ); - if (oversizedEntry === undefined) return false; + if (oversizedEntry === undefined) {return false;} this.history.addHistoryEntry(oversizedEntry); diff --git a/frontend/sync-client/src/utils/data-structures/event-listeners.ts b/frontend/sync-client/src/utils/data-structures/event-listeners.ts index 47c8b8ee..2bac9904 100644 --- a/frontend/sync-client/src/utils/data-structures/event-listeners.ts +++ b/frontend/sync-client/src/utils/data-structures/event-listeners.ts @@ -43,7 +43,7 @@ export class EventListeners any> { const snapshot = this.listeners.slice(); for (const listener of snapshot) { // allow removing listeners during the trigger loop - if (!this.listeners.includes(listener)) continue; + if (!this.listeners.includes(listener)) {continue;} listener(...args); } } @@ -59,7 +59,7 @@ export class EventListeners any> { const snapshot = this.listeners.slice(); const promises: Promise[] = []; for (const listener of snapshot) { - if (!this.listeners.includes(listener)) continue; + if (!this.listeners.includes(listener)) {continue;} // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const result = listener(...args); if (result instanceof Promise) { diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index 00acc600..786b7d9f 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -531,9 +531,9 @@ export class MockAgent extends MockClient { private removeBinaryUuid(file: string): void { const existing = this.files.get(file); - if (existing === undefined) return; + if (existing === undefined) {return;} const content = new TextDecoder().decode(existing); - if (!content.startsWith("BINARY:")) return; + if (!content.startsWith("BINARY:")) {return;} const uuid = content.slice("BINARY:".length); utils.removeFromArray(this.writtenBinaryContents, uuid); }