Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external/personal ESLint config package #69

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"preinstall": "pnpm dlx only-allow pnpm",
"postinstall": "pnpm run common:build",
"forceinstall": "pnpm dlx rimraf ./node_modules ./pnpm-lock.yaml && pnpm store prune && pnpm install",
"all": "pnpm -r run",
"all:version": "pnpm -r exec npm version",
"all:build": "pnpm all build",
Expand All @@ -24,11 +25,11 @@
"test:cov": "pnpm jest --coverage"
},
"devDependencies": {
"@myboothmanager/dev-shared": "workspace:^",
"@types/node": "^20.17.9",
"@somni/eslint-config": "https://gitpkg.vercel.app/somnisomni/webdev-common/packages/eslint-config?main",
"@types/node": "^20.17.10",
"concurrently": "^9.1.0",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2"
"typescript": "=5.6.3"
}
}
4 changes: 2 additions & 2 deletions packages/Common/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eslintConfigs } from "@myboothmanager/dev-shared";
import { ts } from "@somni/eslint-config";

export default [
...eslintConfigs.typescript,
...ts,
];
6 changes: 3 additions & 3 deletions packages/Common/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-var-requires */

const { JestConfigWithTsJest, pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("./tsconfig.json");
Expand All @@ -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",
};
6 changes: 3 additions & 3 deletions packages/Common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
"./dist"
],
"devDependencies": {
"@myboothmanager/dev-shared": "workspace:^",
"@somni/eslint-config": "https://gitpkg.vercel.app/somnisomni/webdev-common/packages/eslint-config?main",
"@tsconfig/node20": "^20.1.4",
"@types/jest": "^29.5.14",
"@types/node": "^20.17.9",
"@types/node": "^20.17.10",
"eslint": "^9.16.0",
"execa": "^9.5.2",
"jest": "^29.7.0",
"rimraf": "^6.0.1",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2",
"typescript": "=5.6.3",
"tsc-alias": "^1.8.10"
},
"dependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/Common/src/enums/errors/base.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @stylistic/no-multi-spaces */

export enum ErrorCodes {
SUCCESS = 0,
UNKNOWN_ERROR = 1,
Expand Down
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
2 changes: 2 additions & 0 deletions packages/Common/src/interfaces/account.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */

/* === Common === */
interface IAccountCommon {
id: number;
Expand Down
8 changes: 5 additions & 3 deletions packages/Common/src/interfaces/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ErrorCodes } from "../enums/errors";
import { IFair } from "./fair";
/* eslint-disable @typescript-eslint/no-empty-object-type */

import type { IFair } from "./fair";
import type { ErrorCodes } from "../enums/errors";

/* === Common Response Interfaces === */
export interface IErrorResponse {
Expand All @@ -14,7 +16,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
6 changes: 4 additions & 2 deletions packages/Common/src/interfaces/booth-member.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { IImageUploadInfo } from "./base";
/* eslint-disable @typescript-eslint/no-empty-object-type */

import type { IImageUploadInfo } from "./base";

/* === Common === */
interface IBoothMemberCommon {
Expand All @@ -23,7 +25,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 { }
30 changes: 16 additions & 14 deletions packages/Common/src/interfaces/booth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SupportedCurrencyCodes } from "@/utils/currency";
import { IFairInfo, IImageUploadInfo } from "./base";
/* eslint-disable @typescript-eslint/no-empty-object-type */

import type { IFairInfo, IImageUploadInfo } from "./base";
import type { SupportedCurrencyCodes } from "@/utils/currency";

/* === Common === */
interface IBoothCommon {
Expand All @@ -15,8 +17,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 @@ -51,27 +53,27 @@ 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;
}

/* === Requests === */
export type IBoothCreateRequest = Omit<IBoothCommon, "id" | "ownerId" | "noticeContent" | "status" | "datesOpenInFair" | "relatedLinks">;
export type IBoothCreateWithFairRequest = Omit<IBoothCommon, "id" | "ownerId" | "noticeContent" | "status" | "location" | "dateOpen" | "dateClose" | "relatedLinks">;
export type IBoothUpdateRequest = Partial<Omit<IBoothCommon, "id" | "ownerId" | "fairId" | "status" | "currencyCode">>;
export type IBoothNoticeUpdateRequest = Pick<IBoothCommon, "noticeContent">;
export type IBoothStatusUpdateRequest = Partial<IBoothStatus>;
export interface IBoothCreateRequest extends Omit<IBoothCommon, "id" | "ownerId" | "noticeContent" | "status" | "datesOpenInFair" | "relatedLinks"> { }
export interface IBoothCreateWithFairRequest extends Omit<IBoothCommon, "id" | "ownerId" | "noticeContent" | "status" | "location" | "dateOpen" | "dateClose" | "relatedLinks"> { }
export interface IBoothUpdateRequest extends Partial<Omit<IBoothCommon, "id" | "ownerId" | "fairId" | "status" | "currencyCode">> { }
export interface IBoothNoticeUpdateRequest extends Pick<IBoothCommon, "noticeContent"> { }
export interface IBoothStatusUpdateRequest extends Partial<IBoothStatus> { }

/* === Responses === */
export type IBoothResponse = Omit<IBooth, "fairId">;
export type IBoothAdminResponse = IBoothAdmin;
export interface IBoothResponse extends Omit<IBooth, "fairId"> { }
export interface IBoothAdminResponse extends IBoothAdmin { }
6 changes: 4 additions & 2 deletions packages/Common/src/interfaces/fair.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */

/* === Common === */
interface IFairCommon {
id: number;
name: string;
description?: string | null;
location: string;
openingDates: Array<Date>;
openingDates: Date[];
websiteUrl?: string | null;
}

Expand All @@ -13,7 +15,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
2 changes: 2 additions & 0 deletions packages/Common/src/interfaces/goods-category.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */

/* === Common === */
interface IGoodsCategoryCommon {
id: number;
Expand Down
8 changes: 5 additions & 3 deletions packages/Common/src/interfaces/goods-combination.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GoodsStockVisibility, IGoodsCommon, IGoodsFrontendCommon, IGoodsStock } from "./goods";
/* eslint-disable @typescript-eslint/no-empty-object-type */

import type { GoodsStockVisibility, IGoodsCommon, IGoodsFrontendCommon, IGoodsStock } from "./goods";

/* === Common === */
interface IGoodsCombinationCommon extends Omit<IGoodsCommon, "combinationId"> { }
Expand All @@ -21,11 +23,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
6 changes: 4 additions & 2 deletions packages/Common/src/interfaces/goods-order.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */

// 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
8 changes: 5 additions & 3 deletions packages/Common/src/interfaces/goods.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { IImageUploadInfo } from "./base";
/* eslint-disable @typescript-eslint/no-empty-object-type */

import type { IImageUploadInfo } from "./base";

/* === Common === */
export interface IGoodsCommon {
Expand All @@ -9,10 +11,10 @@ export interface IGoodsCommon {
description?: string | null;
price: number;
stock: IGoodsStock;
ownerMemberIds?: Array<number> | null;
ownerMemberIds?: number[] | null;
}

interface IGoodsBase extends IGoodsCommon {
export interface IGoodsBase extends IGoodsCommon {
combinationId?: number | null;
type?: string | null;
}
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
Loading