Style Convention은 BEM 방식을 따른다.
- 상수는 영문 대문자, 스네이크 표기법을 사용한다.
const NAME_ROLE;
- 변수 및 함수는 카멜 케이스를 사용한다.
const helloWorld = () => {} const hello = "hi"
- 배열은 복수형(”s”)을 붙인다.
const datas = [];
- props로 전달되는 handler 함수는 ‘on’으로 시작한다.
<Editor
title={title}
onChangeTitle={handleChangeTitle}
height="40vh"
editorContentRef={editorContentRef}
/>
- 컴포넌트 내부 직접 정의하는 event handler는 ‘handle’로 시작한다.
const handleClick = (event) => console.log(event);
- 정규 표현식은 ‘r’로 시작한다.
const = rName = /.*/;
- Boolean 변수와 boolean을 반환하는 판별 함수는 “is, has, can”으로 시작한다. Boolean은 가급적이면 부정형으로 선언하지 않도록 한다.
const isLoading = false
const canOpen = true;
const hasChildren = true;
const isClient = () => {}
- 클래스 등 생성자는 파스칼케이스를 사용한다.
class Hello {}
- 모든 변수/함수명은 직관적으로 의미를 파악할 수 있도록 한다. 가급적 약어를 사용하지 않는다.