Skip to content

Commit 1a60906

Browse files
committed
fix: eslint strict null check
1 parent 828c7ca commit 1a60906

File tree

105 files changed

+439
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+439
-428
lines changed

eslint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ module.exports = rubiin({
1818
},
1919
typescript:
2020
{
21+
"ts/no-unsafe-assignment": "off",
22+
"ts/no-unsafe-call": "off",
23+
"ts/strict-boolean-expressions":"off",
2124
"ts/no-misused-promises": [
2225
"error",
2326
{

src/_mocks_/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ mockUserRepo.softRemoveAndFlush.mockImplementation((entity) => {
153153
return of(entity);
154154
});
155155

156-
mockUserRepo.findOne.mockImplementation((options: FilterQuery<User>) => {
156+
mockUserRepo.findOne.mockImplementation(async (options: FilterQuery<User>) => {
157157
if ("idx" in options) {
158158
return Promise.resolve({
159159
user: mockedUser,
@@ -170,16 +170,16 @@ mockUserRepo.findOne.mockImplementation((options: FilterQuery<User>) => {
170170
return Promise.resolve(mockedUser);
171171
});
172172

173-
mockPostRepo.findOne.mockImplementation((options: FilterQuery<Post>) => {
173+
mockPostRepo.findOne.mockImplementation(async (options: FilterQuery<Post>) => {
174174
return Promise.resolve({
175175
user: mockedUser,
176176
...mockedPost,
177177
title: options.title,
178178
});
179179
});
180180

181-
mockRefreshRepo.findOne.mockImplementation(() =>
182-
Promise.resolve(refreshToken)
181+
mockRefreshRepo.findOne.mockImplementation(async () =>
182+
Promise.resolve(refreshToken),
183183
);
184184

185185
mockRefreshRepo.nativeUpdate.mockResolvedValueOnce(1);
@@ -190,15 +190,15 @@ mockPostRepo.softRemoveAndFlush.mockImplementation((entity) => {
190190
return of(entity);
191191
});
192192

193-
mockOtpLogRepo.findOne.mockImplementation(options =>
193+
mockOtpLogRepo.findOne.mockImplementation(async options =>
194194

195195
Promise.resolve({
196196
user: mockedUser,
197197
idx: options.idx,
198198
}),
199199
);
200200

201-
mockProtocolRepo.findOne.mockImplementation(options =>
201+
mockProtocolRepo.findOne.mockImplementation(async options =>
202202
Promise.resolve({
203203
...mockedProtocol,
204204
idx: options.idx,

src/cluster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import cluster from "node:cluster";
22
import os from "node:os";
33

4+
import process from "node:process";
45
import { HelperService } from "@common/helpers";
56
import { Logger } from "@nestjs/common";
67
import { isUndefined } from "helper-fns";
7-
import process from "node:process";
88

99
export class Cluster {
1010
private static readonly loggerService = new Logger(Cluster.name);

src/common/@types/classes/common.response.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ export class AuthenticationResponse {
33
* @example fb9eac5f-eb94-489b-8fca-24324558be18
44
*/
55
user!: {
6-
idx?: string
7-
id: number
6+
idx?: string;
7+
id: number;
88
};
99

1010
/**

src/common/@types/classes/cursor.response.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ export class CursorMeta {
77
* @example AdVxY2F0ZWdvcnlfaWQ9MjMx
88
*/
99
@ApiProperty()
10-
nextCursor!: string;
10+
nextCursor!: string;
1111

1212
/**
1313
* @example false
1414
*/
1515
@ApiProperty()
16-
hasNextPage!: boolean;
16+
hasNextPage!: boolean;
1717

1818
/**
1919
* @example true
2020
*/
2121
@ApiProperty()
22-
hasPreviousPage!: boolean;
22+
hasPreviousPage!: boolean;
2323

2424
/**
2525
* @example "lorem ipsum"
2626
*/
2727
@ApiProperty()
28-
search?: string;
28+
search?: string;
2929
}
3030

3131
export class CursorPaginationResponse<T> implements PaginationAbstractResponse<T, CursorMeta> {

src/common/@types/classes/offset.response.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export class OffsetMeta {
4444
pageOptionsDto,
4545
itemCount,
4646
}: {
47-
pageOptionsDto: Omit<OffsetPaginationDto, "type">
48-
itemCount: number
47+
pageOptionsDto: Omit<OffsetPaginationDto, "type">;
48+
itemCount: number;
4949
}) {
5050
this.page = pageOptionsDto.page;
5151
this.limit = pageOptionsDto.limit;

src/common/@types/enums/misc.enum.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export enum TemplateEngine {
3838
}
3939

4040
export const FileType: Record<keyof typeof FileSize, string[]> = {
41-
IMAGE:["jpg", "jpeg", "png", "svg", "webp", "gif", "svg"],
42-
DOC:["pdf", "doc", "txt", "key", "csv", "docx", "xls", "xlsx", "ppt", "pptx"],
41+
IMAGE: ["jpg", "jpeg", "png", "svg", "webp", "gif", "svg"],
42+
DOC: ["pdf", "doc", "txt", "key", "csv", "docx", "xls", "xlsx", "ppt", "pptx"],
4343
};
4444

4545
export const ThreadFunctions = {
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
export interface OauthResponse {
2-
email: string
3-
firstName: string
4-
lastName: string
5-
accessToken: string
2+
email: string;
3+
firstName: string;
4+
lastName: string;
5+
accessToken: string;
66
}
77

88
export interface JwtPayload {
9-
jti?: number
10-
sub: number
11-
iat: number
12-
exp: number
13-
aud: string
14-
iss: string
15-
isTwoFactorEnabled?: boolean
16-
roles?: string[]
9+
jti?: number;
10+
sub: number;
11+
iat: number;
12+
exp: number;
13+
aud: string;
14+
iss: string;
15+
isTwoFactorEnabled?: boolean;
16+
roles?: string[];
1717
}

src/common/@types/interfaces/crud.interface.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ import type {
1212
* common interface that enforces common methods for controller and service
1313
*/
1414
export interface Crud<
15-
Entity extends BaseEntity,
16-
PaginationRequest extends TPaginationRequest,
17-
CreateDto extends CreateEntityType<Entity> = CreateEntityType<Entity>,
18-
UpdateDto extends UpdateEntityType<Entity> = UpdateEntityType<Entity>,
15+
Entity extends BaseEntity,
16+
PaginationRequest extends TPaginationRequest,
17+
CreateDto extends CreateEntityType<Entity> = CreateEntityType<Entity>,
18+
UpdateDto extends UpdateEntityType<Entity> = UpdateEntityType<Entity>,
1919
> {
20-
findAll(query: PaginationRequest): Observable<PaginationResponse<Entity>>
20+
findAll: (query: PaginationRequest) => Observable<PaginationResponse<Entity>>;
2121

22-
findOne(index: string): Observable<Entity>
22+
findOne: (index: string) => Observable<Entity>;
2323

24-
create(body: CreateDto, user?: User): Observable<Entity>
24+
create: (body: CreateDto, user?: User) => Observable<Entity>;
2525

26-
update(index: string, body: UpdateDto): Observable<Entity>
26+
update: (index: string, body: UpdateDto) => Observable<Entity>;
2727

28-
remove(index: string): Observable<Entity>
28+
remove: (index: string) => Observable<Entity>;
2929
}

src/common/@types/interfaces/file.interface.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ import type { Buffer } from "node:buffer";
44
/** Object containing file metadata and access information. */
55
export interface File {
66
/** Name of the form field associated with this file. */
7-
fieldname: string
7+
fieldname: string;
88
/** Name of the file on the uploader's computer. */
9-
originalname: string
9+
originalname: string;
1010
/**
1111
* Value of the `Content-Transfer-Encoding` header for this file.
1212
* @deprecated since July 2015
1313
* @see RFC 7578, Section 4.7
1414
*/
15-
encoding: string
15+
encoding: string;
1616
/** Value of the `Content-Type` header for this file. */
17-
mimetype: string
17+
mimetype: string;
1818
/** Size of the file in bytes. */
19-
size: number
19+
size: number;
2020
/**
2121
* A readable stream of this file. Only available to the `_handleFile`
2222
* callback for custom `StorageEngine`s.
2323
*/
24-
stream: Readable
24+
stream: Readable;
2525
/** `DiskStorage` only: Directory to which this file has been uploaded. */
26-
destination: string
26+
destination: string;
2727
/** `DiskStorage` only: Name of this file within `destination`. */
28-
filename: string
28+
filename: string;
2929
/** `DiskStorage` only: Full path to the uploaded file. */
30-
path: string
30+
path: string;
3131
/** `MemoryStorage` only: A Buffer containing the entire file. */
32-
buffer: Buffer
32+
buffer: Buffer;
3333
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface ProfileData {
2-
following: boolean
3-
avatar: string
4-
username: string
2+
following: boolean;
3+
avatar: string;
4+
username: string;
55
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { EmailTemplate } from "../enums";
22

33
export interface MailPayload {
4-
template: string
5-
replacements: Record<string, string>
6-
to: string
7-
subject: string
8-
from: string
4+
template: string;
5+
replacements: Record<string, string>;
6+
to: string;
7+
subject: string;
8+
from: string;
99
}
1010

1111
export type TEmailSubject = keyof typeof EmailTemplate extends `${infer T}_TEMPLATE` ? T : never;

src/common/@types/interfaces/pagination.interface.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ import type { CursorPaginationResponse, OffsetPaginationResponse } from "../clas
44
import { CursorType, QueryCursor, QueryOrder } from "../enums";
55

66
export interface QBCursorPaginationOptions<T extends Dictionary> {
7-
qb: QueryBuilder<T>
7+
qb: QueryBuilder<T>;
88
pageOptionsDto: Omit<CursorPaginationDto, "type"> & {
9-
alias: string
10-
cursor: keyof T
11-
cursorType: CursorType
12-
order: QueryOrder
13-
searchField: keyof T
14-
}
9+
alias: string;
10+
cursor: keyof T;
11+
cursorType: CursorType;
12+
order: QueryOrder;
13+
searchField: keyof T;
14+
};
1515
}
1616

1717
export interface QBOffsetPaginationOptions<T extends Dictionary> {
18-
pageOptionsDto: Omit<OffsetPaginationDto, "type"> & { searchField: keyof T, alias: string }
19-
qb: QueryBuilder<T>
18+
pageOptionsDto: Omit<OffsetPaginationDto, "type"> & { searchField: keyof T; alias: string };
19+
qb: QueryBuilder<T>;
2020
}
2121

2222
export interface PaginateOptions<T> {
23-
instances: T[]
24-
currentCount: number
25-
previousCount: number
26-
cursor: keyof T
27-
first: number
28-
search?: string
23+
instances: T[];
24+
currentCount: number;
25+
previousCount: number;
26+
cursor: keyof T;
27+
first: number;
28+
search?: string;
2929
}
3030

3131
export interface PaginationAbstractResponse<T, Y> {
32-
data: T[]
33-
meta: Y
32+
data: T[];
33+
meta: Y;
3434
}
3535

3636
export type Order = "$gt" | "$lt";

src/common/@types/types/common.types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type Nullable<T> = T | null;
66

77
// This type represents a dto that contains a file or files
88
export type RecordWithFile<T, K = File> = T & {
9-
files: K
9+
files: K;
1010
};
1111

1212
export type UpdateEntityType<Entity> = Partial<EntityDTO<FromEntityType<Entity>>>;

src/common/@types/typings/globals.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {User as UserEntity} from "@entities";
1+
import type { User as UserEntity } from "@entities";
22
import type { I18nTranslations as I18nTranslationTypes } from "@generated";
33
import type { Config as ConfigInterface } from "@lib/config/config.interface";
44
import type { NextFunction, Request, Response } from "express";
@@ -11,11 +11,11 @@ export {};
1111
declare global {
1212
namespace Express {
1313
export interface Request {
14-
realIp?: string
15-
idx?: string
16-
ip: string
17-
i18nLang?: string
18-
ips: string[]
14+
realIp?: string;
15+
idx?: string;
16+
ip: string;
17+
i18nLang?: string;
18+
ips: string[];
1919

2020
}
2121
interface User extends UserEntity {

0 commit comments

Comments
 (0)