함수
// Good
const name = () => {} // (스니펫 단축키 rafce)
// Bad
function name() {}
함수명
// Good
const onChangeHandler = () => {};
// Bad
const changeHandler = () => {};
const handleChange = () => {};
export
- export가 필요한 각 함수, 변수의 앞에 export를 붙임
// Good
export const name1 = () => {};
export const name2 = () => {};
// Bad
const name1 = () => {};
const name2 = () => {};
export {name1, name2};
if문
// Good
if(true) {
alert("");
return;
}
// Bad
if(true) {
return alert("");
}
event는 e로 쓰기
const onChangeHandler = (e) => {}
Typescript 규칙
- types/index.ts 폴더 안에만 type 작성
- 타입 import할 때 import type “interface 명“
- interface로 통일하기
interface Todo {
id: string;
title: string;
content: string;
isDone: boolean;
}