From 76d1fbaf11281bb3c6534599a8f67037a2230029 Mon Sep 17 00:00:00 2001 From: pamapa Date: Thu, 24 Aug 2023 17:40:38 +0200 Subject: [PATCH] fix: make code compatible for eslint-plugin v6.4 --- docs/oidc-client-ts.api.md | 6 +++--- src/OidcClientSettings.ts | 4 ++-- src/RefreshState.ts | 2 +- src/State.ts | 2 +- src/UserManager.test.ts | 2 +- src/navigators/IFrameWindow.test.ts | 4 ++-- src/navigators/RedirectNavigator.test.ts | 6 +++--- src/utils/Logger.ts | 4 ++++ 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/oidc-client-ts.api.md b/docs/oidc-client-ts.api.md index b3d2b7b46..a7412c74d 100644 --- a/docs/oidc-client-ts.api.md +++ b/docs/oidc-client-ts.api.md @@ -344,7 +344,7 @@ export interface OidcClientSettings { stateStore?: StateStore; ui_locales?: string; // @deprecated (undocumented) - userInfoJwtIssuer?: "ANY" | "OP" | string; + userInfoJwtIssuer?: string; } // @public @@ -415,7 +415,7 @@ export class OidcClientSettingsStore { // (undocumented) readonly ui_locales: string | undefined; // (undocumented) - readonly userInfoJwtIssuer: "ANY" | "OP" | string; + readonly userInfoJwtIssuer: string; } // @public (undocumented) @@ -777,7 +777,7 @@ export class State { static clearStaleState(storage: StateStore, age: number): Promise; // (undocumented) readonly created: number; - readonly data: unknown | undefined; + readonly data?: unknown; // (undocumented) static fromStorageString(storageString: string): State; // (undocumented) diff --git a/src/OidcClientSettings.ts b/src/OidcClientSettings.ts index 75e7f0e32..b808727df 100644 --- a/src/OidcClientSettings.ts +++ b/src/OidcClientSettings.ts @@ -90,7 +90,7 @@ export interface OidcClientSettings { /** @deprecated Unused */ clockSkewInSeconds?: number; /** @deprecated Unused */ - userInfoJwtIssuer?: "ANY" | "OP" | string; + userInfoJwtIssuer?: /*"ANY" | "OP" |*/ string; /** * Indicates if objects returned from the user info endpoint as claims (e.g. `address`) are merged into the claims from the id token as a single object. @@ -179,7 +179,7 @@ export class OidcClientSettingsStore { public readonly loadUserInfo: boolean; public readonly staleStateAgeInSeconds: number; public readonly clockSkewInSeconds: number; - public readonly userInfoJwtIssuer: "ANY" | "OP" | string; + public readonly userInfoJwtIssuer: /*"ANY" | "OP" |*/ string; public readonly mergeClaims: boolean; public readonly stateStore: StateStore; diff --git a/src/RefreshState.ts b/src/RefreshState.ts index 66f78293c..794a07ee2 100644 --- a/src/RefreshState.ts +++ b/src/RefreshState.ts @@ -10,7 +10,7 @@ import type { UserProfile } from "./User"; */ export class RefreshState { /** custom "state", which can be used by a caller to have "data" round tripped */ - public readonly data: unknown | undefined; + public readonly data?: unknown; public readonly refresh_token: string; public readonly id_token?: string; diff --git a/src/State.ts b/src/State.ts index b7466a909..668a6b1f2 100644 --- a/src/State.ts +++ b/src/State.ts @@ -13,7 +13,7 @@ export class State { public readonly request_type: string | undefined; /** custom "state", which can be used by a caller to have "data" round tripped */ - public readonly data: unknown | undefined; + public readonly data?: unknown; public constructor(args: { id?: string; diff --git a/src/UserManager.test.ts b/src/UserManager.test.ts index 2416c655b..25fe9646b 100644 --- a/src/UserManager.test.ts +++ b/src/UserManager.test.ts @@ -178,7 +178,7 @@ describe("UserManager", () => { it("should redirect the browser to the authorize url", async () => { // act const spy = jest.fn(); - subject.signinRedirect().finally(spy); + void subject.signinRedirect().finally(spy); // signinRedirect is a promise that will never resolve (since we // want it to hold until the page has redirected), so we wait for diff --git a/src/navigators/IFrameWindow.test.ts b/src/navigators/IFrameWindow.test.ts index cfcf476be..8156275e0 100644 --- a/src/navigators/IFrameWindow.test.ts +++ b/src/navigators/IFrameWindow.test.ts @@ -135,7 +135,7 @@ describe("IFrameWindow", () => { const frameWindow = new IFrameWindow({}); const promise = frameWindow.navigate({ state: fakeState, url: fakeUrl, scriptOrigin: args.passedOrigin }); - promise.finally(() => promiseDone = true); + void promise.finally(() => promiseDone = true); await flushPromises(); expect(promiseDone).toBe(false); @@ -154,7 +154,7 @@ describe("IFrameWindow", () => { const frameWindow = new IFrameWindow({}); const promise = frameWindow.navigate({ state: "diff_state", url: fakeUrl }); - promise.finally(() => promiseDone = true); + void promise.finally(() => promiseDone = true); await flushPromises(); expect(promiseDone).toBe(false); diff --git a/src/navigators/RedirectNavigator.test.ts b/src/navigators/RedirectNavigator.test.ts index 4153f79fc..e00be84a4 100644 --- a/src/navigators/RedirectNavigator.test.ts +++ b/src/navigators/RedirectNavigator.test.ts @@ -21,7 +21,7 @@ describe("RedirectNavigator", () => { it("should redirect to the authority server using a specific redirect method", async () => { const handle = await navigator.prepare({ redirectMethod: "replace" }); const spy = jest.fn(); - handle.navigate({ url: "http://sts/authorize" }).finally(spy); + void handle.navigate({ url: "http://sts/authorize" }).finally(spy); expect(window.location.replace).toHaveBeenCalledWith("http://sts/authorize"); @@ -32,7 +32,7 @@ describe("RedirectNavigator", () => { }); it("should redirect to the authority server from window top", async () => { - + Object.defineProperty(window, "top", { value: { location: { @@ -43,7 +43,7 @@ describe("RedirectNavigator", () => { const handle = await navigator.prepare({ redirectTarget: "top" }); const spy = jest.fn(); - handle.navigate({ url: "http://sts/authorize" }).finally(spy); + void handle.navigate({ url: "http://sts/authorize" }).finally(spy); expect(window.location.assign).toHaveBeenCalledTimes(0); expect(window.parent.location.assign).toHaveBeenCalledTimes(0); diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 2e8a82ff6..7ff303d75 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -68,6 +68,7 @@ export class Logger { private _method?: string; public constructor(private _name: string) {} + /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */ public debug(...args: unknown[]): void { if (level >= Log.DEBUG) { logger.debug(Logger._format(this._name, this._method), ...args); @@ -88,6 +89,7 @@ export class Logger { logger.error(Logger._format(this._name, this._method), ...args); } } + /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */ public throw(err: Error): never { this.error(err); @@ -112,6 +114,7 @@ export class Logger { return method ? `${prefix} ${method}:` : prefix; } + /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */ // helpers for static class methods public static debug(name: string, ...args: unknown[]): void { if (level >= Log.DEBUG) { @@ -133,6 +136,7 @@ export class Logger { logger.error(Logger._format(name), ...args); } } + /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */ } Log.reset();