Commit ConventionCode ConventionNamingComponents Folder & NamingComponentsStylingFunctionsImport OrderAPI UsageGit BranchGit-Flowbranch 최신화
Commit Convention
Commit Message는 한글로 작성한다.
type: Commit Message
type 뒤에는 콜론(:)을 사용한다.
type | description |
feat | 기능 추가 |
fix | 버그 수정 |
refactor | 리팩터링 |
style | css 디자인 관련 내용 |
docs | 문서 작성 및 수정 |
test | 테스트 관련 |
build | 빌드 관련 |
deploy | 배포 관련 |
chore | 그 외 내용(패키지 추가, 파일명 변경 … ) |
Code Convention
Naming
축약어를 사용하지 않고 작성한다.
→ ❌ btn ✅ button
Components Folder & Naming
┣ 📂components ┃ index.ts ┣ 📂HomePage ┃ ┣ 📂Button(component) ┃ ┃ ┣ Button.tsx ┃ ┃ ┣ Button.style.ts // Style 파일은 * 대신 named로 가져올 것 ┃ ┃ ┗ Button.stories.js
Components
function Button() { return ( // ... ) }
Styling
// Button.style.ts import styled from '@emotion/styled' export const CustomButton = styled.button`` // Button.tsx import { CustomButton } from './Button.style' export function Button() { return ( <CustomButton >click me!</CustomButton> ) }
Functions
const onClick = () => { }
Import Order
- 리액트
- 라이브러리
- 모듈
- 스타일
// 리액트 import { useState, useEffect, ... } from 'react' // 라이브러리 import { throttle, debounce, ... } from "lodash"; // 모듈 // components, hooks, store, utils, assets, interface.. import { Button } from 'components' // 스타일 import { ButtonStyle } from './style';
API Usage
// axiosInstance.ts import axios, { AxiosInstance } from 'axios'; const host = process.env.REACT_APP_API_HOST ?? 'localhost'; const port = process.env.REACT_APP_API_PORT ?? 3000; const API_ENDPOINT = `${host}:${port}`; const axiosInstance: AxiosInstance = axios.create({ baseURL: API_ENDPOINT, // baseURL 미리세팅 timeout: 5000, headers: { 'Content-Type': 'application/json', }, }); axiosInstance.interceptors.response.use( (response) => Promise.resolve(response), (error) => { console.error(error); return Promise.reject(error); }, ); export default axiosInstance;
// api/getPost.ts export const getPost = async (postId) => { try { const result = await axiosInstance({ method: 'GET', url: `/posts/${postId}` }) return result.data; } catch (error) { throw new Error('Fetch Error') } };
Git Branch
Sequence
git issue 제작 → develop branch에서 feature/* branch 분기 후 작업
Git-Flow
main
배포가 될 branch이다.
develop
기능 개발이 완료된 branch가 합쳐지는 곳으로, 2명의 승인 후 merge된다.
(24시간 초과시 PR을 작성한 담당자가 merge한다).
feature
feature/현재-개발중인-기능
으로 develop branch에서 분기한다.
feature branch에서 기능들을 작업하고 develop branch로 merge PR을 작성한다.branch 최신화
rebase 사용
작업하던 branch에서 develop branch의 내용을 최신화 하기 위해 다음 과정을 따른다.
작업중인 branch에서 최신화 된 develop branch 내용을 pull한다.
작업중인 branch로 이동해 rebase develop을 이용해 작업 branch를 최신화 한다.
git rebase develop
git add .
git rebase --continue
git push -f
reabse 중 충돌이 발생하면 해당 담당자와 충돌을 해결한다.