Format & lint

This commit is contained in:
Andras Schmelczer 2025-12-14 13:55:23 +00:00
parent 0e0a85df82
commit 5efe30d9d6
7 changed files with 32 additions and 22 deletions

View file

@ -7,6 +7,7 @@ on:
branches: ["main"] branches: ["main"]
schedule: schedule:
- cron: '0 * * * *' - cron: '0 * * * *'
workflow_dispatch:
concurrency: concurrency:
group: e2e-tests group: e2e-tests

View file

@ -190,7 +190,10 @@ export class WebSocketManager {
this.webSocket.onopen = (): void => { this.webSocket.onopen = (): void => {
// Check if we've been stopped while connecting // Check if we've been stopped while connecting
if (this.isStopped) { if (this.isStopped) {
this.webSocket?.close(1000, "WebSocketManager was stopped during connection"); this.webSocket?.close(
1000,
"WebSocketManager was stopped during connection"
);
return; return;
} }
this.logger.info("WebSocket connection opened"); this.logger.info("WebSocket connection opened");

View file

@ -55,9 +55,8 @@ export class SyncClient {
settings: Partial<SyncSettings>; settings: Partial<SyncSettings>;
database: Partial<StoredDatabase>; database: Partial<StoredDatabase>;
}> }>
>, >
) { ) {}
}
public get documentCount(): number { public get documentCount(): number {
return this.database.length; return this.database.length;
@ -256,11 +255,13 @@ export class SyncClient {
this.unloadTelemetry = setUpTelemetry(); this.unloadTelemetry = setUpTelemetry();
} }
this.eventUnsubscribers.push(this.settings.onSettingsChanged.add((newSettings, oldSettings) => { this.eventUnsubscribers.push(
if (oldSettings.isSyncEnabled != newSettings.isSyncEnabled) { this.settings.onSettingsChanged.add((newSettings, oldSettings) => {
this.fetchController.canFetch = newSettings.isSyncEnabled; if (oldSettings.isSyncEnabled != newSettings.isSyncEnabled) {
} this.fetchController.canFetch = newSettings.isSyncEnabled;
})); }
})
);
this.eventUnsubscribers.push( this.eventUnsubscribers.push(
this.logger.onLogEmitted.add((log): void => { this.logger.onLogEmitted.add((log): void => {
@ -271,7 +272,9 @@ export class SyncClient {
); );
this.eventUnsubscribers.push( this.eventUnsubscribers.push(
this.settings.onSettingsChanged.add(this.onSettingsChange.bind(this)) this.settings.onSettingsChanged.add(
this.onSettingsChange.bind(this)
)
); );
if (this.settings.getSettings().isSyncEnabled) { if (this.settings.getSettings().isSyncEnabled) {
@ -441,7 +444,9 @@ export class SyncClient {
// Prevent concurrent destroy calls // Prevent concurrent destroy calls
if (this.isDestroying) { if (this.isDestroying) {
this.logger.warn("destroy() called while already destroying, ignoring"); this.logger.warn(
"destroy() called while already destroying, ignoring"
);
return; return;
} }
this.isDestroying = true; this.isDestroying = true;
@ -454,7 +459,9 @@ export class SyncClient {
this.resetInMemoryState(); this.resetInMemoryState();
// Clean up event listeners to prevent memory leaks // Clean up event listeners to prevent memory leaks
this.eventUnsubscribers.forEach((unsubscribe) => unsubscribe()); this.eventUnsubscribers.forEach((unsubscribe) => {
unsubscribe();
});
this.eventUnsubscribers.length = 0; this.eventUnsubscribers.length = 0;
this.logger.info("SyncClient has been successfully disposed"); this.logger.info("SyncClient has been successfully disposed");

View file

@ -171,7 +171,7 @@ export class Syncer {
// in that case, we mustn't move it again. // in that case, we mustn't move it again.
if ( if (
this.database.getLatestDocumentByRelativePath(relativePath) === this.database.getLatestDocumentByRelativePath(relativePath) ===
undefined || undefined ||
this.database.getLatestDocumentByRelativePath(relativePath) this.database.getLatestDocumentByRelativePath(relativePath)
?.isDeleted === true ?.isDeleted === true
) { ) {

View file

@ -252,7 +252,7 @@ describe("reset", () => {
await sleep(1); await sleep(1);
const secondPromise = locks.withLock(testPath, async () => "second"); const secondPromise = locks.withLock(testPath, async () => "second");
void secondPromise.catch(() => { }); void secondPromise.catch(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
locks.reset(); locks.reset();
@ -273,7 +273,7 @@ describe("reset", () => {
await sleep(1); await sleep(1);
const secondPromise = locks.withLock(testPath, async () => "second"); const secondPromise = locks.withLock(testPath, async () => "second");
void secondPromise.catch(() => { }); void secondPromise.catch(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
locks.reset(); locks.reset();

View file

@ -13,9 +13,12 @@ export class Locks<T> {
private readonly locked = new Set<T>(); private readonly locked = new Set<T>();
/** Queue of resolve functions waiting for each key */ /** Queue of resolve functions waiting for each key */
private readonly waiters = new Map<T, ([() => unknown, (err: unknown) => unknown])[]>(); private readonly waiters = new Map<
T,
[() => unknown, (err: unknown) => unknown][]
>();
public constructor(private readonly logger?: Logger) { } public constructor(private readonly logger?: Logger) {}
/** /**
* Executes a function while holding exclusive locks on one or more keys. * Executes a function while holding exclusive locks on one or more keys.

View file

@ -58,8 +58,4 @@ fi
cd .. cd ..
if [[ "$FIX_MODE" == true ]]; then echo "Success"
$0
else
echo "Success"
fi