Skip to content

[URH-76] 프로젝트 폴더 구조 수정 #65

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

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
🔨 refactor: alias 적용
  • Loading branch information
bicochan committed Sep 12, 2024
commit 1b8f3199040426a727a274d3727a4f7ae1b8b0b4
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config: JestConfigWithTsJest = {
},
moduleNameMapper: {
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
'^@/(.*)$': '<rootDir>/src/$1',
},
setupFiles: ['jest-canvas-mock', './src/mocks/mockWorker.ts'],
setupFilesAfterEnv: ['./jest.setup.ts'],
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useAsyncTasks/useAsyncTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
PromiseCircularityError,
} from 'async-wave';

import { delayExecution } from '../../utils';
import { delayExecution } from '@/utils';

type Task<R> = R | ((input: R) => R | Promise<R> | void | Promise<void>);

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useClipboard/useClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { imgToBlob } from '../../utils';
import { imgToBlob } from '@/utils';

interface UseClipboardProps {
resetTime?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useConfirm/useConfirm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { ConfirmContext as context } from '../../context/ConfirmContext';
import { ConfirmContext as context } from '@/context/ConfirmContext';

/**
* 컨펌 다이얼로그를 구현할 때 사용하는 훅.
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useDetectDevice/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderHook } from '@testing-library/react';
import useDetectDevice from './useDetectDevice';
import * as utils from '../../utils';
import * as utils from '@/utils';

const mockUserAgent = (userAgent: string) => {
Object.defineProperty(navigator, 'userAgent', {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useDetectDevice/useDetectDevice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { isClient } from '../../utils';
import { isClient } from '@/utils';

interface UseDeviceDetectReturns {
isMobile: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useDetectInactivity/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { act, renderHook } from '@testing-library/react';
import useDetectInactivity from './useDetectInactivity';
import { useTimer } from '../useTimer';
import { isTouchDevice } from '../../utils';
import { useTimer } from '@/hooks/useTimer';
import { isTouchDevice } from '@/utils';

jest.mock('../useTimer');

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useDetectInactivity/useDetectInactivity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from 'react';
import { useTimer } from '../useTimer';
import { isTouchDevice, throttle } from '../../utils';
import { useTimer } from '@/hooks/useTimer';
import { isTouchDevice, throttle } from '@/utils';

type Fn = () => void;

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useEventListener/test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cleanup, fireEvent, render, renderHook } from '@testing-library/react';
import useEventListener from './useEventListener';
import { act, useRef } from 'react';
import * as utils from '../../utils';
import * as utils from '@/utils';

describe('useEventListener', () => {
let handler: jest.Mock;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useEventListener/useEventListener.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RefObject, useEffect, useRef } from 'react';
import { isClient } from '../../utils';
import { isClient } from '@/utils';

type EventMap = {
window: WindowEventMap;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useIntersectionObserver/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useIntersectionObserver from './useIntersectionObserver';
import {
MockIntersectionObserver,
mockIntersectionObserver,
} from '../../mocks/mockIntersectionObserver';
} from '@/mocks/mockIntersectionObserver';

describe('useIntersectionObserver', () => {
let rootElement: Element;
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useInterval/useInterval.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import { Fn } from '../../types';

type Fn = () => void;

/**
* 지정된 시간 간격만큼 반복적으로 콜백 함수를 호출하는 훅
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useLocalStorage/useLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { validators } from '../../utils';
import { ValueResolver } from '../../types';
import { validators } from '@/utils';

type ValueResolver<T> = T | ((prevPayload: T) => T);

/**
* 로컬 스토리지와 동기화된 상태를 관리하는 훅
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { act, renderHook } from '@testing-library/react';
import useLongPress from '../useLongPress/useLongPress';
import useLongPress from './useLongPress';

const callback = jest.fn();
const defaultDelay = 500;
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useLongPress/useLongPress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { Fn } from '../../types';

type Fn = () => void;

/**
* 사용자가 요소를 길게 눌렀을 때 콜백 함수를 호출하는 훅
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useMousePosition/useMousePosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useRef,
useState,
} from 'react';
import { throttle } from '../../utils';
import { throttle } from '@/utils';

interface MousePosOptions {
delayTime?: number;
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useOnlineStatus/useOnlineStatus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { Fn } from '../../types';
import { hasNavigator } from '../../utils';
import { hasNavigator } from '@/utils';

type Fn = () => void;

interface useOnlineStatusProps {
onlineCallback?: Fn;
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/usePrefersColorScheme/usePrefersColorScheme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useSyncExternalStore } from 'react';
import { Fn } from '../../types';
import { isClient } from '../../utils';
import { isClient } from '@/utils';

type Fn = () => void;

interface UsePrefersColorSchemeProps {
serverSnapshot?: ColorSchemeType;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useScrollLock/useScrollLock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef } from 'react';
import { isClient } from '../../utils';
import { isClient } from '@/utils';

/**
* 페이지의 스크롤을 잠그거나 해제하여 사용자가 스크롤할 수 없도록 하는 훅
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useScrollY/useScrollY.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCallback, useEffect } from 'react';
import { Fn } from '../../types';
import { debounce } from '../../utils/debounce';
import { useLocalStorage } from '../useLocalStorage';
import { debounce } from '@/utils';
import { useLocalStorage } from '@/hooks/useLocalStorage';

type Fn = () => void;

const useScrollY = (): { moveTrigger: Fn } => {
const isClient = typeof window !== 'undefined';
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTimer/useTimer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useRef } from 'react';

import { type CancelToken, delayExecution } from '../../utils';
import useUnmountEffect from '../useUnmountEffect/useUnmountEffect';
import { type CancelToken, delayExecution } from '@/utils';
import { useUnmountEffect } from '@/hooks/useUnmountEffect';

type Callback = () => void;

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTranslation/test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import useTranslation from './useTranslation';
import { TranslationProvider } from '../../context/TranslationContext';
import { TranslationProvider } from '@/context/TranslationContext';

const translations = {
en: {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTranslation/useTranslation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { TranslationContext } from '../../context/TranslationContext';
import { TranslationContext } from '@/context/TranslationContext';

const DYNAMIC_VALUE_PATTERN = /\$\{(.*?)\}/g;

Expand Down
8 changes: 7 additions & 1 deletion src/hooks/useWindowSize/useWindowSize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { useEffect, useState } from 'react';
import { PositiveInteger } from '../../types/number';

export type PositiveInteger<T extends number> = `${T}` extends
| `-${string}`
| `${string}.${string}`
| '0'
? never
: T;

interface WindowSize {
width: number | null;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useWorker/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
mockPostMessage,
mockTerminate,
mockWorkerScript,
} from '../../mocks/mockWorker';
} from '@/mocks/mockWorker';

beforeEach(() => {
globalThis.URL.createObjectURL = jest.fn();
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useWorker/useWorker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MutableRefObject, useCallback, useRef, useState } from 'react';

import { validators } from '../../utils';
import { useUnmountEffect } from '../useUnmountEffect';
import { validators } from '@/utils';
import { useUnmountEffect } from '@/hooks/useUnmountEffect';

type WorkerScript<A, R, C> = (arg: A, accessClosure?: C) => R;

Expand Down
5 changes: 0 additions & 5 deletions src/types/index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/types/number.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { delayExecution, type CancelToken } from './delayExecution';
export { throttle } from './throttle';
export { debounce } from './debounce';
export { isClient, hasNavigator } from './isClient';
export { isTouchDevice } from './isTouchDevice';
export { validators, MatchError } from './validators';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/throttle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenericFn } from '../types';
type GenericFn<T extends unknown[]> = (...args: T) => void;

export const throttle = <T extends unknown[]>(
callbackFn: GenericFn<T>,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueResolver } from '../types';
type ValueResolver<T> = T | ((prevPayload: T) => T);

const validators = {
isClient(): boolean {
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,

"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["**/main.tsx", "**/App.tsx", "src/docs", "**/*.test.*"]
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,

"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*.spec.ts", "src/**/*.spec.tsx"]
}