Skip to content

코딩 컨벤션 & 네이밍 규칙

yejineee edited this page Oct 29, 2020 · 6 revisions

📌 코딩 컨벤션

  • 코딩 컨벤션은 airbnb 스타일 사용을 사용한다.
  • 개발을 하며 필요한 rule을 추가할 수 있다.
  • eslintprettier를 사용하여 코딩 스타일 통합한다.

📌 네이밍 규칙

  1. 함수명과 변수명 등 축약하지 않는다.

img 🙅‍♀ => image🙆‍♂

btn 🙅‍♀ => button🙆‍♂

  1. wrapper vs container ✅

  2. index 사용 규칙

    • 반복문에서는 i -> j -> k 반복문은 지양하고, 고차함수를 사용한다.
    for(let i = 0 ; ; )
        for(let j = 0 ; ; )
            for(let k = 0 ; ; )
    • 고차함수에서는 idx
    reduce(acc, item, idx)
    forEach(item, idx)
    • 그 외에는 index
    const index = 0 ;
    const selectedCardIndex = ... ; 

Naming

📌 컴포넌트 이름 규칙

기존 태그를 대체하는 것

  • prefix : Custom을 붙인다.
<CustomButton/>
  • styled을 지정하는 변수명은 기존 태그명 그대로 사용
const Div = styled.div``;
<Div></Div>

컴포넌트 구조 네이밍

postfix:

xxContainer
    xxHeader
    xxBody
        xxItem
    xxFooter

Clone this wiki locally