Skip to content

Commit

Permalink
BC-8508 - fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bergatco committed Jan 21, 2025
1 parent 75bb38d commit 8330f88
Show file tree
Hide file tree
Showing 206 changed files with 945 additions and 1,043 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class SampleLoggableException extends BadRequestException implements Loggable {
}

class SampleLoggableExceptionWithCause extends InternalServerErrorException implements Loggable {
constructor(
private readonly testValue: string,
error?: unknown,
) {
constructor(private readonly testValue: string, error?: unknown) {
super(ErrorUtils.createHttpExceptionOptions(error));
}

Expand All @@ -57,7 +54,7 @@ class SampleLoggableFromBusinessException extends BusinessError implements Logga
title: 'test_title',
defaultMessage: 'test_defaultMessage',
},
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ApiValidationErrorResponse extends ErrorResponse {

if (validationError.children) {
validationError.children.forEach((childError: ValidationError) =>
this.extractValidationErrorDetails(childError, propertyPath),
this.extractValidationErrorDetails(childError, propertyPath)
);
}
}
Expand Down
37 changes: 17 additions & 20 deletions apps/server/src/core/error/filter/global-error.filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ class SampleBusinessError extends BusinessError {
title: 'Sample Error',
defaultMessage: 'sample error message',
},
HttpStatus.NOT_IMPLEMENTED,
HttpStatus.NOT_IMPLEMENTED
);
}
}

class SampleLoggableExceptionWithCause extends InternalServerErrorException implements Loggable {
constructor(
private readonly testValue: string,
error?: unknown,
) {
constructor(private readonly testValue: string, error?: unknown) {
super(ErrorUtils.createHttpExceptionOptions(error));
}

Expand Down Expand Up @@ -157,7 +154,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.NOT_IMPLEMENTED).json,
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.NOT_IMPLEMENTED).json
).toBeCalledWith(expectedResponse);
});
});
Expand All @@ -170,7 +167,7 @@ describe('GlobalErrorFilter', () => {
'SAMPLE_ERROR',
'Sample Error',
'sample error message',
HttpStatus.NOT_IMPLEMENTED,
HttpStatus.NOT_IMPLEMENTED
);

return { error, argumentsHost, expectedResponse };
Expand All @@ -182,7 +179,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(argumentsHost.switchToHttp().getResponse<Response>().status).toBeCalledWith(
HttpStatus.NOT_IMPLEMENTED,
HttpStatus.NOT_IMPLEMENTED
);
});

Expand All @@ -192,7 +189,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.NOT_IMPLEMENTED).json,
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.NOT_IMPLEMENTED).json
).toBeCalledWith(expectedResponse);
});
});
Expand All @@ -205,7 +202,7 @@ describe('GlobalErrorFilter', () => {
'BAD_REQUEST',
'Bad Request',
'Bad Request',
HttpStatus.BAD_REQUEST,
HttpStatus.BAD_REQUEST
);

return { error, argumentsHost, expectedResponse };
Expand All @@ -225,7 +222,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.BAD_REQUEST).json,
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.BAD_REQUEST).json
).toBeCalledWith(expectedResponse);
});
});
Expand All @@ -238,7 +235,7 @@ describe('GlobalErrorFilter', () => {
'INTERNAL_SERVER_ERROR',
'Internal Server Error',
'Internal Server Error',
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);

return { error, argumentsHost, expectedResponse };
Expand All @@ -250,7 +247,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(argumentsHost.switchToHttp().getResponse<Response>().status).toBeCalledWith(
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);
});

Expand All @@ -260,7 +257,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.INTERNAL_SERVER_ERROR).json,
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.INTERNAL_SERVER_ERROR).json
).toBeCalledWith(expectedResponse);
});
});
Expand All @@ -273,7 +270,7 @@ describe('GlobalErrorFilter', () => {
'INTERNAL_SERVER_ERROR',
'Internal Server Error',
'Internal Server Error',
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);

return { error, argumentsHost, expectedResponse };
Expand All @@ -285,7 +282,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(argumentsHost.switchToHttp().getResponse<Response>().status).toBeCalledWith(
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);
});

Expand All @@ -295,7 +292,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.INTERNAL_SERVER_ERROR).json,
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.INTERNAL_SERVER_ERROR).json
).toBeCalledWith(expectedResponse);
});
});
Expand All @@ -308,7 +305,7 @@ describe('GlobalErrorFilter', () => {
'SAMPLE_WITH_CAUSE',
'Sample With Cause',
'Sample Loggable Exception With Cause',
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);

const argumentsHost = mockHttpArgumentsHost();
Expand All @@ -322,7 +319,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(argumentsHost.switchToHttp().getResponse<Response>().status).toBeCalledWith(
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.INTERNAL_SERVER_ERROR
);
});

Expand All @@ -332,7 +329,7 @@ describe('GlobalErrorFilter', () => {
service.catch(error, argumentsHost);

expect(
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.INTERNAL_SERVER_ERROR).json,
argumentsHost.switchToHttp().getResponse<Response>().status(HttpStatus.INTERNAL_SERVER_ERROR).json
).toBeCalledWith(expectedResponse);
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/core/error/loggable/error.loggable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SampleBusinessError extends BusinessError {
title: 'Sample Error',
defaultMessage: 'sample error message',
},
HttpStatus.NOT_IMPLEMENTED,
HttpStatus.NOT_IMPLEMENTED
);
}
}
Expand Down
9 changes: 3 additions & 6 deletions apps/server/src/core/error/loggable/error.loggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import { ErrorUtils } from '../utils/error.utils';
export class ErrorLoggable implements Loggable {
readonly actualError: Error;

constructor(
private readonly error: unknown,
private readonly data?: LogMessageDataObject,
) {
constructor(private readonly error: unknown, private readonly data?: LogMessageDataObject) {
if (this.error instanceof Error) {
this.actualError = <Error>error;
} else {
Expand Down Expand Up @@ -71,13 +68,13 @@ export class ErrorLoggable implements Loggable {
target.constructor,
'',
true,
true,
true
);

const privacyProtected = metadatas.some(
(validationMetadata) =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
validationMetadata.propertyName === property && validationMetadata.context?.privacyProtected,
validationMetadata.propertyName === property && validationMetadata.context?.privacyProtected
);

return privacyProtected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const CurrentUser = createParamDecorator<never, never, ICurrentUser>((_,

if (!requestUser || !isCurrentUser(requestUser)) {
throw new UnauthorizedException(
'CurrentUser missing in request context. This route requires jwt authentication guard enabled.',
'CurrentUser missing in request context. This route requires jwt authentication guard enabled.'
);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/infra/auth-guard/strategy/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CurrentUserBuilder, JwtStrategyOptionsFactory } from '../mapper';
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(
private readonly jwtValidationAdapter: JwtValidationAdapter,
configService: ConfigService<JwtAuthGuardConfig>,
configService: ConfigService<JwtAuthGuardConfig>
) {
const strategyOptions = JwtStrategyOptionsFactory.build(extractJwtFromHeader, configService);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CurrentUserBuilder, JwtStrategyOptionsFactory } from '../mapper';
export class WsJwtStrategy extends PassportStrategy(Strategy, StrategyType.WS_JWT) {
constructor(
private readonly jwtValidationAdapter: JwtValidationAdapter,
configService: ConfigService<JwtAuthGuardConfig>,
configService: ConfigService<JwtAuthGuardConfig>
) {
const strategyOptions = JwtStrategyOptionsFactory.build(JwtExtractor.fromCookie('jwt'), configService);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ import { AuthorizationErrorLoggableException, AuthorizationForbiddenLoggableExce

@Injectable()
export class AuthorizationClientAdapter {
constructor(
private readonly authorizationApi: AuthorizationApi,
@Inject(REQUEST) private request: Request,
) {}
constructor(private readonly authorizationApi: AuthorizationApi, @Inject(REQUEST) private request: Request) {}

public async checkPermissionsByReference(
referenceType: AuthorizationBodyParamsReferenceType,
referenceId: string,
context: AuthorizationContextParams,
context: AuthorizationContextParams
): Promise<void> {
const hasPermission = await this.hasPermissionsByReference(referenceType, referenceId, context);

Expand All @@ -32,7 +29,7 @@ export class AuthorizationClientAdapter {
public async hasPermissionsByReference(
referenceType: AuthorizationBodyParamsReferenceType,
referenceId: string,
context: AuthorizationContextParams,
context: AuthorizationContextParams
): Promise<boolean> {
const params = {
referenceType,
Expand All @@ -45,7 +42,7 @@ export class AuthorizationClientAdapter {

const response = await this.authorizationApi.authorizationReferenceControllerAuthorizeByReference(
params,
options,
options
);
const hasPermission = response.data.isAuthorized;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('NextCloudStrategy', () => {
await strategy.updateTeamPermissionsForRole(teamRolePermissionsDto);

expect(client.findGroupId).toHaveBeenCalledWith(
NextcloudStrategySpec.specGenerateGroupId(teamRolePermissionsDto),
NextcloudStrategySpec.specGenerateGroupId(teamRolePermissionsDto)
);
});

Expand Down Expand Up @@ -182,7 +182,7 @@ describe('NextCloudStrategy', () => {
await strategy.updateTeamPermissionsForRole(teamRolePermissionsDto);

expect(client.findGroupId).toHaveBeenCalledWith(
NextcloudStrategySpec.specGenerateGroupId(teamRolePermissionsDto),
NextcloudStrategySpec.specGenerateGroupId(teamRolePermissionsDto)
);
});

Expand Down
14 changes: 7 additions & 7 deletions apps/server/src/infra/etherpad-client/etherpad-client.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class EtherpadClientAdapter {
private readonly groupApi: GroupApi,
private readonly sessionApi: SessionApi,
private readonly authorApi: AuthorApi,
private readonly padApi: PadApi,
private readonly padApi: PadApi
) {}

public async getOrCreateAuthorId(userId: EntityId, username?: string): Promise<AuthorId> {
Expand All @@ -49,7 +49,7 @@ export class EtherpadClientAdapter {

private async tryCreateAuthor(
userId: string,
username?: string,
username?: string
): Promise<AxiosResponse<CreateAuthorUsingGET200Response>> {
try {
const response = await this.authorApi.createAuthorIfNotExistsForUsingGET(userId, username);
Expand Down Expand Up @@ -88,7 +88,7 @@ export class EtherpadClientAdapter {
authorId: AuthorId,
parentId: EntityId,
sessionCookieExpire: Date,
durationThreshold: number,
durationThreshold: number
): Promise<SessionId> {
const session = await this.getSessionByGroupAndAuthor(groupId, authorId);

Expand All @@ -115,7 +115,7 @@ export class EtherpadClientAdapter {
private async tryCreateSession(
groupId: string,
authorId: string,
sessionCookieExpire: Date,
sessionCookieExpire: Date
): Promise<AxiosResponse<CreateSessionUsingGET200Response>> {
try {
const unixTimeInSeconds = Math.floor(sessionCookieExpire.getTime() / 1000);
Expand Down Expand Up @@ -162,7 +162,7 @@ export class EtherpadClientAdapter {
}

private async tryListSessionsOfAuthor(
authorId: AuthorId,
authorId: AuthorId
): Promise<AxiosResponse<ListSessionsOfGroupUsingGET200Response>> {
try {
const response = await this.authorApi.listSessionsOfAuthorUsingGET(authorId);
Expand Down Expand Up @@ -209,7 +209,7 @@ export class EtherpadClientAdapter {

private async tryCreateEtherpad(
groupId: string,
parentId: string,
parentId: string
): Promise<AxiosResponse<DeleteGroupUsingGET200Response>> {
try {
const response = await this.groupApi.createGroupPadUsingGET(groupId, parentId);
Expand Down Expand Up @@ -333,7 +333,7 @@ export class EtherpadClientAdapter {

private handleEtherpadResponse<T extends EtherpadResponse>(
axiosResponse: AxiosResponse<T>,
payload: EtherpadParams,
payload: EtherpadParams
): T['data'] {
const response = axiosResponse.data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export class EtherpadResponseMapper {
static mapResponseToException<T extends EtherpadResponse>(
type: EtherpadErrorType,
payload: EtherpadParams,
response: T | Error,
response: T | Error
): EtherpadErrorLoggableException {
return new EtherpadErrorLoggableException(
type,
payload,
response.message,
ErrorUtils.createHttpExceptionOptions(response.message),
ErrorUtils.createHttpExceptionOptions(response.message)
);
}

Expand Down
Loading

0 comments on commit 8330f88

Please sign in to comment.