Skip to content

Commit

Permalink
Lint auto-fix for TypeScript projects/packages
Browse files Browse the repository at this point in the history
  • Loading branch information
somnisomni committed Mar 5, 2025
1 parent 0df8652 commit 5f90fee
Show file tree
Hide file tree
Showing 116 changed files with 682 additions and 631 deletions.
4 changes: 2 additions & 2 deletions packages/Common/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
preset: "ts-jest",
testEnvironment: "node",
rootDir: ".",
roots: ["<rootDir>"],
modulePaths: [compilerOptions.baseUrl],
roots: [ "<rootDir>" ],
modulePaths: [ compilerOptions.baseUrl ],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: "<rootDir>/" }),
coverageDirectory: "./coverage",
};
94 changes: 47 additions & 47 deletions packages/Common/src/enums/errors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,80 @@ export enum ErrorCodes {
UNKNOWN_ERROR = 1,

// XXX: Generic errors
INTERNAL_ERROR = 2,
ROUTE_NOT_FOUND = 3,
ENTITY_NOT_FOUND = 4,
INVALID_REQUEST_BODY = 5,
INVALID_REQUEST_QUERY = 6,
INVALID_HTTP_METHOD = 7,
NO_ACCESS = 8,
ENTITY_DUPLICATED = 9,
INTERNAL_ERROR = 2,
ROUTE_NOT_FOUND = 3,
ENTITY_NOT_FOUND = 4,
INVALID_REQUEST_BODY = 5,
INVALID_REQUEST_QUERY = 6,
INVALID_HTTP_METHOD = 7,
NO_ACCESS = 8,
ENTITY_DUPLICATED = 9,
REQUEST_MAX_SIZE_EXCEEDED = 10,

// 1XXX: Authentication/Account errors
UNKNOWN_AUTH_ERROR = 1000,
INVALID_AUTH_TOKEN = 1001,
EXPIRED_AUTH_TOKEN = 1002,
INVALID_REFRESH_TOKEN = 1003,
EXPIRED_REFRESH_TOKEN = 1004,
AUTH_REFRESH_FAILED = 1005,
ACCOUNT_BANNED = 1006,
ACCOUNT_DISABLED = 1007,
AUTH_TOKEN_NEED_REFRESH = 1008,
AUTH_TOKEN_MISSING = 1009,
NEED_RELOGIN = 1010,
SESSION_ALREADY_EXISTS = 1011,
ACCOUNT_INFO_UPDATE_FAILED = 1012,
UNKNOWN_AUTH_ERROR = 1000,
INVALID_AUTH_TOKEN = 1001,
EXPIRED_AUTH_TOKEN = 1002,
INVALID_REFRESH_TOKEN = 1003,
EXPIRED_REFRESH_TOKEN = 1004,
AUTH_REFRESH_FAILED = 1005,
ACCOUNT_BANNED = 1006,
ACCOUNT_DISABLED = 1007,
AUTH_TOKEN_NEED_REFRESH = 1008,
AUTH_TOKEN_MISSING = 1009,
NEED_RELOGIN = 1010,
SESSION_ALREADY_EXISTS = 1011,
ACCOUNT_INFO_UPDATE_FAILED = 1012,
ACCOUNT_PASSWORD_UPDATE_FAILED = 1013,

// 2XXX: Booth errors
UNKNOWN_BOOTH_ERROR = 2000,
BOOTH_STATUS_UPDATE_FAILED = 2001,
BOOTH_INFO_UPDATE_FAILED = 2002,
UNKNOWN_BOOTH_ERROR = 2000,
BOOTH_STATUS_UPDATE_FAILED = 2001,
BOOTH_INFO_UPDATE_FAILED = 2002,
BOOTH_MEMBER_MANIPULATION_FAILED = 2003,
BOOTH_NOT_PUBLISHED = 2004,
BOOTH_NOTICE_UPDATE_FAILED = 2005,
BOOTH_NOT_PUBLISHED = 2004,
BOOTH_NOTICE_UPDATE_FAILED = 2005,

// 3XXX: Goods errors
UNKNOWN_GOODS_ERROR = 3000,
UNKNOWN_GOODS_ERROR = 3000,
GOODS_PARENT_BOOTH_NOT_FOUND = 3001,
GOODS_STATUS_UPDATE_FAILED = 3002,
GOODS_INFO_UPDATE_FAILED = 3003,
GOODS_STATUS_UPDATE_FAILED = 3002,
GOODS_INFO_UPDATE_FAILED = 3003,

// 4XXX: Goods category errors
UNKNOWN_GOODS_CATEGORY_ERROR = 4000,
UNKNOWN_GOODS_CATEGORY_ERROR = 4000,
GOODS_CATEGORY_PARENT_BOOTH_NOT_FOUND = 4001,
GOODS_CATEGORY_INFO_UPDATE_FAILED = 4002,
GOODS_CATEGORY_INFO_UPDATE_FAILED = 4002,

// 5XXX: Goods order errors
UNKNOWN_GOODS_ORDER_ERROR = 5000,
GOODS_ORDER_PARENT_BOOTH_NOT_FOUND = 5001,
GOODS_ORDER_INVALID_CREATE_REQUEST_ORDER_EMPTY = 5002,
GOODS_ORDER_INVALID_CREATE_REQUEST_GOODS_NOT_FOUND = 5003,
UNKNOWN_GOODS_ORDER_ERROR = 5000,
GOODS_ORDER_PARENT_BOOTH_NOT_FOUND = 5001,
GOODS_ORDER_INVALID_CREATE_REQUEST_ORDER_EMPTY = 5002,
GOODS_ORDER_INVALID_CREATE_REQUEST_GOODS_NOT_FOUND = 5003,
GOODS_ORDER_INVALID_CREATE_REQUEST_INVALID_GOODS_AMOUNT = 5004,
GOODS_ORDER_STATUS_UPDATE_FAILED = 5005,
GOODS_ORDER_STATUS_UPDATE_PROHIBITED = 5006,
GOODS_ORDER_STATUS_UPDATE_FAILED = 5005,
GOODS_ORDER_STATUS_UPDATE_PROHIBITED = 5006,
GOODS_ORDER_INVALID_CREATE_REQUEST_GOODS_COMBINATION_NOT_FOUND = 5007,
GOODS_ORDER_INVALID_CREATE_REQUEST_INVALID_GOODS_COMBINATION = 5008,
GOODS_ORDER_INVALID_CREATE_REQUEST_INVALID_GOODS_COMBINATION = 5008,

// 6XXX: Goods combination errors
UNKNOWN_GOODS_COMBINATION_ERROR = 6000,
UNKNOWN_GOODS_COMBINATION_ERROR = 6000,
GOODS_COMBINATION_PARENT_BOOTH_NOT_FOUND = 6001,
GOODS_COMBINATION_INFO_UPDATE_FAILED = 6002,
GOODS_COMBINATION_INFO_UPDATE_FAILED = 6002,

// 7XXX: Booth member errors
UNKNOWN_BOOTH_MEMBER_ERROR = 7000,
UNKNOWN_BOOTH_MEMBER_ERROR = 7000,
BOOTH_MEMBER_PARENT_BOOTH_NOT_FOUND = 7001,
BOOTH_MEMBER_INFO_UPDATE_FAILED = 7002,
BOOTH_MEMBER_INFO_UPDATE_FAILED = 7002,

// 8XXX: Upload / Image / File related errors
UNKNOWN_UPLOAD_ERROR = 8000,
EMPTY_UPLOAD = 8001,
INVALID_IMAGE = 8002,
UNKNOWN_UPLOAD_ERROR = 8000,
EMPTY_UPLOAD = 8001,
INVALID_IMAGE = 8002,
IMAGE_MANIPULATION_FAILED = 8003,

// 9XXX: Fair errors
UNKNOWN_FAIR_ERROR = 9000,
FAIR_PASSED = 9001,
UNKNOWN_FAIR_ERROR = 9000,
FAIR_PASSED = 9001,
FAIR_INFO_UPDATE_FAILED = 9002,
}
6 changes: 3 additions & 3 deletions packages/Common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const APP_NAME = "Codename Sora" as const;
export const DEVELOPER_TWITTER_HANDLE = "somni_somni" as const;
export const HTTP_HEALTH_CHECK_STATUS_CODE = 239 as const;
export const APP_NAME = "Codename Sora" as const;
export const DEVELOPER_TWITTER_HANDLE = "somni_somni" as const;
export const HTTP_HEALTH_CHECK_STATUS_CODE = 239 as const;

export * from "./enums";
export * from "./interfaces";
Expand Down
6 changes: 3 additions & 3 deletions packages/Common/src/interfaces/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorCodes } from "../enums/errors";
import { IFair } from "./fair";
import type { IFair } from "./fair";
import type { ErrorCodes } from "../enums/errors";

/* === Common Response Interfaces === */
export interface IErrorResponse {
Expand All @@ -14,7 +14,7 @@ export interface ISuccessResponse {
}
export const SUCCESS_RESPONSE: Readonly<ISuccessResponse> = Object.freeze({ success: true } as const);

export interface ISingleValueResponse<T> {
export interface ISingleValueResponse<T> {
value: T;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/Common/src/interfaces/booth-member.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IImageUploadInfo } from "./base";
import type { IImageUploadInfo } from "./base";

/* === Common === */
interface IBoothMemberCommon {
Expand All @@ -23,7 +23,7 @@ export interface IBoothMemberModel extends IBoothMemberCommon {

/* === Requests === */
export interface IBoothMemberCreateRequest extends Omit<IBoothMemberCommon, "id"> { }
export interface IBoothMemberUpdateRequest extends Partial<Omit<IBoothMemberCommon, "id" | "boothId">>, Pick<IBoothMemberCommon, "boothId"> { }
export interface IBoothMemberUpdateRequest extends Partial<Omit<IBoothMemberCommon, "id" | "boothId">>, Pick<IBoothMemberCommon, "boothId"> { }

/* === Responses === */
export interface IBoothMemberResponse extends IBoothMember { }
14 changes: 7 additions & 7 deletions packages/Common/src/interfaces/booth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SupportedCurrencyCodes } from "@/utils/currency";
import { IFairInfo, IImageUploadInfo } from "./base";
import type { IFairInfo, IImageUploadInfo } from "./base";
import type { IAccountResponse } from "@/interfaces/account";
import type { SupportedCurrencyCodes } from "@/utils/currency";

/* === Common === */
interface IBoothCommon {
Expand All @@ -16,8 +16,8 @@ interface IBoothCommon {
location?: string | null; // For custom fair
dateOpen?: Date | null; // For custom fair
dateClose?: Date | null; // For custom fair
datesOpenInFair?: Array<Date> | null; // Only with fair
relatedLinks?: Array<IBoothRelatedLink>;
datesOpenInFair?: Date[] | null; // Only with fair
relatedLinks?: IBoothRelatedLink[];
}

export interface IBoothStatus {
Expand Down Expand Up @@ -52,16 +52,16 @@ export interface IBooth extends Omit<IBoothCommon, "fairId"> {
}

export interface IBoothAdmin extends IBooth {
expenses: Array<IBoothExpense>;
expenses: IBoothExpense[];
}

/* === Model for Backend (DB) === */
export interface IBoothModel extends Omit<IBoothCommon, "datesOpenInFair" | "status"> {
datesOpenInFair?: Array<string> | null; // JSON string array of "YYYY-MM-DD"
datesOpenInFair?: string[] | null; // JSON string array of "YYYY-MM-DD"
status: BoothStatus;
statusReason?: string | null;
statusContentPublished: boolean;
expenses: Array<IBoothExpense>;
expenses: IBoothExpense[];
bannerImageId?: number | null;
infoImageId?: number | null;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/Common/src/interfaces/fair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface IFairCommon {
name: string;
description?: string | null;
location: string;
openingDates: Array<Date>;
openingDates: Date[];
websiteUrl?: string | null;
}

Expand All @@ -13,7 +13,7 @@ export interface IFair extends IFairCommon { }

/* === Model for Backend (DB) === */
export interface IFairModel extends Omit<IFairCommon, "openingDates"> {
openingDates: Array<string>; // JSON string array of "YYYY-MM-DD"
openingDates: string[]; // JSON string array of "YYYY-MM-DD"
}

/* === Requests === */
Expand Down
6 changes: 3 additions & 3 deletions packages/Common/src/interfaces/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export enum FeedbackSenderType {

export enum FeedbackType {
FEATURE_REQUEST = "Feature Request",
FAIR_REQUEST = "Fair Registration Request",
BUG_ISSUES = "Bug & Issues",
OTHER = "Other",
FAIR_REQUEST = "Fair Registration Request",
BUG_ISSUES = "Bug & Issues",
OTHER = "Other",
}

export interface IFeedbackRequest {
Expand Down
6 changes: 3 additions & 3 deletions packages/Common/src/interfaces/goods-combination.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GoodsStockVisibility, IGoodsCommon, IGoodsFrontendCommon, IGoodsStock } from "./goods";
import type { GoodsStockVisibility, IGoodsCommon, IGoodsFrontendCommon, IGoodsStock } from "./goods";

/* === Common === */
interface IGoodsCombinationCommon extends Omit<IGoodsCommon, "combinationId"> { }
Expand All @@ -21,11 +21,11 @@ export interface IGoodsCombinationModel extends Omit<IGoodsCombinationCommon, "s
/* === Requests === */
export interface IGoodsCombinationCreateRequest extends Omit<IGoodsCombinationCommon, "id" | "stock" | "ownerMemberIds"> {
stockVisibility: GoodsStockVisibility;
goodsIds: Array<number>;
goodsIds: number[];
}

export interface IGoodsCombinationUpdateRequest extends Partial<Omit<IGoodsCombinationCommon, "id" | "boothId" | "ownerMemberIds">>, Pick<IGoodsCombinationCommon, "boothId"> {
goodsIds?: Array<number> | null;
goodsIds?: number[] | null;
}

/* === Responses === */
Expand Down
4 changes: 2 additions & 2 deletions packages/Common/src/interfaces/goods-order.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// NOTE: Admin-only interfaces (goods order is admin-only feature)

import { MutualExclusive } from "..";
import type { MutualExclusive } from "..";

/* === Common === */
interface IGoodsOrderCommon {
id: number;
boothId: number;
order: Array<IGoodsOrderItem>;
order: IGoodsOrderItem[];
status: GoodsOrderStatus;
totalRevenue: number;
paymentMethod?: GoodsOrderPaymentMethod;
Expand Down
5 changes: 3 additions & 2 deletions packages/Common/src/interfaces/goods.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IImageUploadInfo } from "./base";
import type { IImageUploadInfo } from "./base";

/* === Common === */
// eslint-disable-next-line import-x/exports-last
export interface IGoodsCommon {
id: number;
boothId: number;
Expand All @@ -9,7 +10,7 @@ export interface IGoodsCommon {
description?: string | null;
price: number;
stock: IGoodsStock;
ownerMemberIds?: Array<number> | null;
ownerMemberIds?: number[] | null;
}

interface IGoodsBase extends IGoodsCommon {
Expand Down
2 changes: 1 addition & 1 deletion packages/Common/src/utils/__tests__/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("Common Functions", () => {
describe("deleteKeys()", () => {
it("should delete keys from object in-place", () => {
const obj = { a: 1, b: 2, c: 3, d: 4 };
const keys = ["a", "c"] as const;
const keys = [ "a", "c" ] as const;

expect(obj).toBeInstanceOf(Object);
expect(Object.keys(obj)).toHaveLength(4);
Expand Down
6 changes: 4 additions & 2 deletions packages/Common/src/utils/__tests__/internals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { BoothStatus, IBoothAdmin } from "../../interfaces/booth";
import { deleteSequelizeInternalKeys, WithSequelizeInternals } from "../internals";
import type { IBoothAdmin } from "../../interfaces/booth";
import type { WithSequelizeInternals } from "../internals";
import { BoothStatus } from "../../interfaces/booth";
import { deleteSequelizeInternalKeys } from "../internals";

const testBooth: IBoothAdmin = {
id: 1234,
Expand Down
Loading

0 comments on commit 5f90fee

Please sign in to comment.