Skip to content

코딩 컨밴션

Yun Hwan, Kim edited this page Nov 20, 2019 · 5 revisions

어떻게 컨밴션을 정할까?

airbnb style guide를 베이스로 규칙을 따르되, 너무 받아들이기 힘든 부분에 의견을 제시하여 바꾼다.

각 1명당 무조건 한가지 스타일을 바꿀 수 있는 권한이 있다.

변경 사항

Eslint & Prettier Page

1. import할때 대상이 하나일때는 한줄로 작성가능, 2개 이상이면 줄을 나누어서 중괄호로 구분할 것

// good
import { hello } from 'foo'

// good 
import {
  hello,
  world,
} from 'foo'

2. indentation은 space 2칸

3. string을 literal하게 사용할때 쌍따옴표를 사용할 것

4. if statement는 한줄만 작성이 되어도 무조건 중괄호를 사용할 것

// good
if (hello && world) {
  foo()
}

5. arrow function의 인자는 무조건 괄호를 할 것

arrowParens: arrow 함수의 파라미터를 소괄호로 감싸는 규칙(https://eslint.org/docs/rules/arrow-parens)

// good
(param) => body

// bad
param => body 

6. 함수의 파라미터에 재할당은 금지

no-param-reassign: 함수의 파라미터에 재할당에 대한 규칙 (https://eslint.org/docs/rules/no-param-reassign)

7. 함수 리턴 타입은 일관성이 있어야함

consistent-return: 일관성있는 함수 리턴 타입에 대한 규칙 (https://eslint.org/docs/rules/consistent-return)

8. 배열 요소가 한줄로 너무 길어지게되면 multi line을 사용 (https://eslint.org/docs/rules/array-element-newline)

array-element-newline