Skip to content

Commit

Permalink
refactor(test-loader-utils): Updated eslint to use recommended config (
Browse files Browse the repository at this point in the history
…#23593)

##Description

This PR updates the eslint config for test-loader-utils to use the
recommended config.
  • Loading branch information
WayneFerrao authored Jan 17, 2025
1 parent 5f4097c commit c16bc56
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/loader/test-loader-utils/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
*/

module.exports = {
extends: ["@fluidframework/eslint-config-fluid/minimal-deprecated", "prettier"],
extends: ["@fluidframework/eslint-config-fluid/recommended", "prettier"],
};
2 changes: 1 addition & 1 deletion packages/loader/test-loader-utils/src/mockDeltaStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class MockDocumentDeltaStorageService implements IDocumentDeltaStorageSer
return streamFromMessages(this.getCore(from, to));
}

private async getCore(from: number, to?: number) {
private async getCore(from: number, to?: number): Promise<ISequencedDocumentMessage[]> {
const messages: ISequencedDocumentMessage[] = [];
let index: number = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class MockDocumentDeltaConnection
user: {
id: "mockid",
},
iat: Math.round(new Date().getTime() / 1000),
exp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration
iat: Math.round(Date.now() / 1000),
exp: Math.round(Date.now() / 1000) + 60 * 60, // 1 hour expiration
ver: "1.0",
};

Expand All @@ -58,7 +58,7 @@ export class MockDocumentDeltaConnection
constructor(
public readonly clientId: string,
private readonly submitHandler?: (messages: IDocumentMessage[]) => void,
private readonly submitSignalHandler?: (message: any) => void,
private readonly submitSignalHandler?: (message: unknown) => void,
) {
super();
}
Expand All @@ -69,37 +69,37 @@ export class MockDocumentDeltaConnection
}
}

public submitSignal(message: any): void {
public submitSignal(message: unknown): void {
if (this.submitSignalHandler !== undefined) {
this.submitSignalHandler(message);
}
}
private _disposed = false;
public get disposed() {
public get disposed(): boolean {
return this._disposed;
}
public dispose(error?: Error) {
public dispose(error?: Error): void {
this._disposed = true;
this.emit("disconnect", error?.message ?? "mock close() called");
}

// Mock methods for raising events
public emitOp(documentId: string, messages: Partial<ISequencedDocumentMessage>[]) {
public emitOp(documentId: string, messages: Partial<ISequencedDocumentMessage>[]): void {
this.emit("op", documentId, messages);
}
public emitSignal(signal: Partial<ISignalMessage>) {
public emitSignal(signal: Partial<ISignalMessage>): void {
this.emit("signal", signal);
}
public emitNack(documentId: string, message: Partial<INack>[]) {
public emitNack(documentId: string, message: Partial<INack>[]): void {
this.emit("nack", documentId, message);
}
public emitPong(latency: number) {
public emitPong(latency: number): void {
this.emit("pong", latency);
}
public emitDisconnect(disconnectReason: IAnyDriverError) {
public emitDisconnect(disconnectReason: IAnyDriverError): void {
this.emit("error", disconnectReason);
}
public emitError(error: IAnyDriverError) {
public emitError(error: IAnyDriverError): void {
this.emit("error", error);
}
}
16 changes: 8 additions & 8 deletions packages/loader/test-loader-utils/src/mockDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class MockDocumentService
extends TypedEventEmitter<IDocumentServiceEvents>
implements IDocumentService
{
public get deltaStorageMessages() {
public get deltaStorageMessages(): ISequencedDocumentMessage[] {
return this._deltaStorageMessages;
}

Expand All @@ -42,7 +42,7 @@ export class MockDocumentService
super();
}

public dispose() {}
public dispose(): void {}

// TODO: Issue-2109 Implement detach container api or put appropriate comment.
public get resolvedUrl(): IResolvedUrl {
Expand All @@ -53,13 +53,13 @@ export class MockDocumentService
throw new Error("Method not implemented.");
}
public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {
return this.deltaStorageFactory !== undefined
? this.deltaStorageFactory()
: new MockDocumentDeltaStorageService(this.deltaStorageMessages);
return this.deltaStorageFactory === undefined
? new MockDocumentDeltaStorageService(this.deltaStorageMessages)
: this.deltaStorageFactory();
}
public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {
return this.deltaConnectionFactory !== undefined
? this.deltaConnectionFactory(client)
: new MockDocumentDeltaConnection(`mock_client_${this.nextClientId++}`);
return this.deltaConnectionFactory === undefined
? new MockDocumentDeltaConnection(`mock_client_${this.nextClientId++}`)
: this.deltaConnectionFactory(client);
}
}

0 comments on commit c16bc56

Please sign in to comment.