📋 목차


🚩 기술 스택

구분 기술 비고
번들러 Vite CRA vs Vite

🚩 코드 컨벤션

📌 코딩스타일

풀네임 사용 여부 축약형보다는 풀네임을 권장
길이 제한 4음절로 제한
컴포넌트 작성 순서 styled-components > hook(상태) > 상수 > 변수 > 함수 > jsx
JSDoc 공통 컴포넌트, 함수 등
함수 형태 컴포넌트는 함수 선언식 export default function Component(){}
그 외 함수는 함수 표현식 export const Fn = () ⇒ {}

📌 네이밍 컨벤션

분류 규칙 예시
상수 SNAKE_CASE const MAX_USERS = 10;
변수 camelCase let userName = 'JohnDoe';
let isActive = true;
let hasLoggedIn = false;
함수 camelCase, 동사+명사 const getUserProfile = () ⇒ { ... }
이벤트 핸들러 camelCase
컴포넌트에 props 넘겨줄 때는 on 접두사
이벤트 함수는 handle 접두사 props -> onChangeHandler
func -> handleChange
타입, 인터페이스 - type : 유니언 타입, 유틸리티 타입

📌 스타일 컴포넌트 컨벤션

  1. tsx 컴포넌트 파일에서 기본값 설정, 스타일 분기 처리
  2. 스타일 컴포넌트에서는 props를 사용하기만 하는 방식으로 props 및 theme은 상단에서 선언한 것을 재사용하기 위해 css 선택자로 묶어주기
export default function Button({
  type = 'button',
  disabled = false,
  width = '13.3rem',
  height = '4.3rem',
  shape,
  ...props
}: ButtonProps) {
  const theme = useTheme();

  return (
    <BaseButton
      type={type}
      disabled={disabled}
      $width={width}
      $height={height}
      $shape={shape || theme.shape.round}
      {...props}
    >
      {isLoading && <CircularProgress size={20} />}
      {!isLoading && children}
    </BaseButton>
  );
}

import styled, { css } from 'styled-components';

export const BaseButton = styled.button<StyledButtonProps>`
  ${({
    $width,
    $height,
    theme,
  }) => css`
    width: ${$width};
    height: ${$height};
    // theme 사용 예시
    border-radius: ${$theme.shape.round};
    color: ${theme.color.black_primary};
  `}
`;

🚩 디렉터리 구조

AlgoBaro
├─ 📂 public // 파비콘 등 자료나 이미지
│  └─ favicon.ico
└─ 📦 src
   ├─ 📂 assets 
   ├─ 📂 components
			├─ index.ts
			└─ 📂Common // 공용 컴포넌트 폴더
	    └─ 📂Avatar
				 ├─ index.ts // 폴더 내 .tsx 파일이 하나일 경우 생략
				 ├─ Avatar.tsx
				 └─ Avatar.style.ts
   ├─ 📂 constants
   ├─ 📂 hooks
   ├─ 📂 pages
   ├─ 📂 routes
   ├─ 📂 services
			├─ 📂 auth
			└─ apiconfig.ts
   ├─ 📂 store
   ├─ 📂 styles
   ├─ 📂 types
   ├─ 📂 utils
   ├─ App.tsx
   └─ main.tsx
├─ .gitignore
├─ index.html
└─ README.md