Skip to content

Commit

Permalink
refactor(chore): fix any types sonar code smells (#208)
Browse files Browse the repository at this point in the history
fix sonar code smells related to unexpected any types

GH-204
  • Loading branch information
sf-sahil-jassal authored Jan 9, 2024
1 parent 0236903 commit f757e57
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
12 changes: 7 additions & 5 deletions src/strategies/types/cognito.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {AnyObject} from '@loopback/repository';

export namespace Cognito {
export interface StrategyOptions {
callbackURL: string;
Expand All @@ -16,14 +18,14 @@ export namespace Cognito {
// eslint-disable-next-line @typescript-eslint/naming-convention
phone_number?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
[key: string]: any; // NOSONAR
}

export type VerifyCallback = (
err?: string | Error,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
user?: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
info?: any,

user?: AnyObject,

info?: AnyObject,
) => void;
}
13 changes: 8 additions & 5 deletions src/strategies/types/keycloak.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {AnyObject} from '@loopback/repository';
import {IAuthUser} from '../../types';

export namespace Keycloak {
export interface StrategyOptions {
host: string;
Expand All @@ -20,14 +23,14 @@ export namespace Keycloak {
avatar: string;
realm: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
[key: string]: any; // NOSONAR
}

export type VerifyCallback = (
err?: string | Error,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
user?: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
info?: any,

user?: IAuthUser,

info?: AnyObject,
) => void;
}
17 changes: 9 additions & 8 deletions src/strategies/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
/* eslint-disable @typescript-eslint/naming-convention */
import {AnyObject} from '@loopback/repository';
import {Request} from '@loopback/rest';
import * as GoogleStrategy from 'passport-google-oauth20';
import * as AzureADStrategy from 'passport-azure-ad';
import * as InstagramStrategy from 'passport-instagram';
import * as FacebookStrategy from 'passport-facebook';
import * as AppleStrategy from 'passport-apple';
import * as SamlStrategy from '@node-saml/passport-saml';
import * as AppleStrategy from 'passport-apple';
import {DecodedIdToken} from 'passport-apple';
import * as AzureADStrategy from 'passport-azure-ad';
import * as FacebookStrategy from 'passport-facebook';
import * as GoogleStrategy from 'passport-google-oauth20';
import * as InstagramStrategy from 'passport-instagram';
import {Cognito, IAuthClient, IAuthSecureClient, IAuthUser} from '../../types';
import {Keycloak} from './keycloak.types';
import {Otp} from '../passport';
import {Keycloak} from './keycloak.types';

export type VerifyCallback = (
err?: string | Error | null,
user?: Express.User,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
info?: any,

info?: AnyObject,
) => void;

export namespace VerifyFunction {
Expand Down
4 changes: 2 additions & 2 deletions src/strategy-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Node module: @loopback/authentication
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {AnyObject} from '@loopback/repository';
import {HttpErrors, Request, Response} from '@loopback/rest';
import {Strategy} from 'passport';

Expand Down Expand Up @@ -37,8 +38,7 @@ export class StrategyAdapter<T> {
return new Promise<T | void>((resolve, reject) => {
// mix-in passport additions like req.logIn and req.logOut
for (const key in passportRequestMixin) {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
(request as any)[key] = passportRequestMixin[key];
(request as AnyObject)[key] = passportRequestMixin[key];
}

// create a prototype chain of an instance of a passport strategy
Expand Down

0 comments on commit f757e57

Please sign in to comment.