Skip to content

Commit 41e6ceb

Browse files
authored
Remove/fix most of the ESLint exceptions in Container (#884)
1 parent 5af193b commit 41e6ceb

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

packages/loader/container-loader/src/container.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* Licensed under the MIT License.
44
*/
55

6-
// Disabling these per-file rather than full subdirectory
7-
/* eslint-disable @typescript-eslint/no-misused-promises */
8-
96
import * as assert from "assert";
107
import {
118
ITelemetryBaseLogger,
@@ -118,8 +115,7 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
118115
request,
119116
logger);
120117

121-
// eslint-disable-next-line no-async-promise-executor
122-
return new Promise<Container>(async (res, rej) => {
118+
return new Promise<Container>((res, rej) => {
123119
let alreadyRaisedError = false;
124120
const onError = (error) => {
125121
container.removeListener("error", onError);
@@ -135,8 +131,7 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
135131
const version = request.headers && request.headers[LoaderHeader.version];
136132
const pause = request.headers && request.headers[LoaderHeader.pause];
137133

138-
// tslint:disable-next-line no-unsafe-any
139-
return container.load(version, !!pause)
134+
container.load(version, !!pause)
140135
.then(() => {
141136
container.removeListener("error", onError);
142137
res(container);
@@ -156,10 +151,6 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
156151

157152
private pendingClientId: string | undefined;
158153
private loaded = false;
159-
// TSLint incorrectly believes blobManager is not reassigned, but actually it is in load().
160-
// Known bug: https://github.com/palantir/tslint/issues/3803
161-
// Fixed in ESLint: https://github.com/typescript-eslint/typescript-eslint/issues/946
162-
// tslint:disable-next-line:prefer-readonly
163154
private blobManager: BlobManager | undefined;
164155

165156
// Active chaincode and associated runtime
@@ -179,10 +170,6 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
179170
private context: ContainerContext | undefined;
180171
private pkg: string | IFluidCodeDetails | undefined;
181172
private codeQuorumKey;
182-
// TSLint incorrectly believes protocolHandler is not reassigned, but actually it is in load().
183-
// Known bug: https://github.com/palantir/tslint/issues/3803
184-
// Fixed in ESLint: https://github.com/typescript-eslint/typescript-eslint/issues/946
185-
// tslint:disable-next-line:prefer-readonly
186173
private protocolHandler: ProtocolOpHandler | undefined;
187174

188175
private firstConnection = true;
@@ -349,7 +336,6 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
349336
public on(event: "pong" | "processTime", listener: (latency: number) => void): this;
350337
public on(event: MessageType.BlobUploaded, listener: (contents: any) => void): this;
351338

352-
/* tslint:disable:no-unnecessary-override */
353339
public on(event: string | symbol, listener: (...args: any[]) => void): this {
354340
return super.on(event, listener);
355341
}
@@ -431,8 +417,7 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
431417
this.emit("error", error);
432418
}
433419

434-
// eslint-disable-next-line @typescript-eslint/promise-function-async
435-
public reloadContext(): Promise<void> {
420+
public async reloadContext(): Promise<void> {
436421
return this.reloadContextCore().catch((error) => {
437422
this.raiseCriticalError(error);
438423
throw error;
@@ -770,7 +755,6 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
770755
});
771756

772757
protocol.quorum.on("error", (error) => {
773-
// tslint:disable-next-line no-unsafe-any
774758
protocolLogger.sendErrorEvent(error);
775759
});
776760

@@ -877,9 +861,7 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
877861
}
878862

879863
private get client() {
880-
// tslint:disable-next-line:no-unsafe-any
881864
const client: IClient = this.options && this.options.client
882-
// tslint:disable-next-line:no-unsafe-any
883865
? (this.options.client as IClient)
884866
: {
885867
type: "browser", // Back-compat: 0.11 clientType
@@ -896,7 +878,6 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
896878
&& this.originalRequest.headers[LoaderHeader.clientDetails];
897879

898880
if (headerClientDetails) {
899-
// tslint:disable-next-line: no-unsafe-any
900881
merge(client.details, headerClientDetails);
901882
}
902883

@@ -1145,13 +1126,10 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
11451126
}
11461127
}
11471128

1148-
// tslint:disable no-unsafe-any
11491129
private getScopes(options: any): string[] {
11501130
return options && options.tokens && options.tokens.jwt ?
1151-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
1152-
(jwtDecode(options.tokens.jwt) as ITokenClaims).scopes : [];
1131+
jwtDecode<ITokenClaims>(options.tokens.jwt).scopes : [];
11531132
}
1154-
// tslint:enable no-unsafe-any
11551133

11561134
/**
11571135
* Get the most recent snapshot, or a specific version.
@@ -1198,8 +1176,7 @@ export class Container extends EventEmitterWithErrorHandling implements IContain
11981176
(err) => this.raiseCriticalError(err),
11991177
(type, contents) => this.submitMessage(type, contents),
12001178
(message) => this.submitSignal(message),
1201-
// eslint-disable-next-line @typescript-eslint/promise-function-async
1202-
(message) => this.snapshot(message),
1179+
async (message) => this.snapshot(message),
12031180
(reason?: string) => this.close(reason),
12041181
Container.version,
12051182
);

0 commit comments

Comments
 (0)