Skip to content

Commit f757e57

Browse files
refactor(chore): fix any types sonar code smells (#208)
fix sonar code smells related to unexpected any types GH-204
1 parent 0236903 commit f757e57

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

src/strategies/types/cognito.types.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {AnyObject} from '@loopback/repository';
2+
13
export namespace Cognito {
24
export interface StrategyOptions {
35
callbackURL: string;
@@ -16,14 +18,14 @@ export namespace Cognito {
1618
// eslint-disable-next-line @typescript-eslint/naming-convention
1719
phone_number?: string;
1820
// eslint-disable-next-line @typescript-eslint/no-explicit-any
19-
[key: string]: any;
21+
[key: string]: any; // NOSONAR
2022
}
2123

2224
export type VerifyCallback = (
2325
err?: string | Error,
24-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
user?: any,
26-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27-
info?: any,
26+
27+
user?: AnyObject,
28+
29+
info?: AnyObject,
2830
) => void;
2931
}

src/strategies/types/keycloak.types.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {AnyObject} from '@loopback/repository';
2+
import {IAuthUser} from '../../types';
3+
14
export namespace Keycloak {
25
export interface StrategyOptions {
36
host: string;
@@ -20,14 +23,14 @@ export namespace Keycloak {
2023
avatar: string;
2124
realm: string;
2225
// eslint-disable-next-line @typescript-eslint/no-explicit-any
23-
[key: string]: any;
26+
[key: string]: any; // NOSONAR
2427
}
2528

2629
export type VerifyCallback = (
2730
err?: string | Error,
28-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29-
user?: any,
30-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31-
info?: any,
31+
32+
user?: IAuthUser,
33+
34+
info?: AnyObject,
3235
) => void;
3336
}

src/strategies/types/types.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
2+
import {AnyObject} from '@loopback/repository';
23
import {Request} from '@loopback/rest';
3-
import * as GoogleStrategy from 'passport-google-oauth20';
4-
import * as AzureADStrategy from 'passport-azure-ad';
5-
import * as InstagramStrategy from 'passport-instagram';
6-
import * as FacebookStrategy from 'passport-facebook';
7-
import * as AppleStrategy from 'passport-apple';
84
import * as SamlStrategy from '@node-saml/passport-saml';
5+
import * as AppleStrategy from 'passport-apple';
96
import {DecodedIdToken} from 'passport-apple';
7+
import * as AzureADStrategy from 'passport-azure-ad';
8+
import * as FacebookStrategy from 'passport-facebook';
9+
import * as GoogleStrategy from 'passport-google-oauth20';
10+
import * as InstagramStrategy from 'passport-instagram';
1011
import {Cognito, IAuthClient, IAuthSecureClient, IAuthUser} from '../../types';
11-
import {Keycloak} from './keycloak.types';
1212
import {Otp} from '../passport';
13+
import {Keycloak} from './keycloak.types';
1314

1415
export type VerifyCallback = (
1516
err?: string | Error | null,
1617
user?: Express.User,
17-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18-
info?: any,
18+
19+
info?: AnyObject,
1920
) => void;
2021

2122
export namespace VerifyFunction {

src/strategy-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Node module: @loopback/authentication
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
5+
import {AnyObject} from '@loopback/repository';
56
import {HttpErrors, Request, Response} from '@loopback/rest';
67
import {Strategy} from 'passport';
78

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

4444
// create a prototype chain of an instance of a passport strategy

0 commit comments

Comments
 (0)