Code Convention - Hi-Fi-Club/FE GitHub Wiki
-
์ธ๋ถ ๋ชจ๋๊ณผ ๋ด๋ถ ๋ชจ๋์ ๊ตฌ๋ถํ์ฌ ์ฌ์ฉ.
-
์ธ๋ถ๋ชจ๋์ ๊ฐ .tsx ํ์ผ ๋งจ์์, ๊ทธ ๋ฐ์๋ ๋ด๋ถ๋ชจ๋
-
๋ด๋ถ๋ชจ๋์ ๊ฒฝ์ฐ ์ปดํฌ๋ํธ > ๋ฆฌ์ฝ์ผ atom > ์ ํธ ์์ผ๋ก ์์๋ฅผ ๊ตฌ๋ถํ๋ค.
-
์์
import { useState, useEffect } from "react"; import styled from 'styled-components'; import { useSetRecoilState, useRecoilValue } from "recoil"; โ import MilestonesHeader from "./MilestonesHeader"; import MilestoneCard from "./MilestoneCard"; import MilestoneInput from "./MilestoneInput"; โ import { milestoneAddButtonFlagState, milestoneCountState, labelAddButtonFlagState, navigatorAddButtonFlagState, } from "RecoilStore/Atoms"; โ โ import API from "util/API"; import fetchData from "util/fetchData";
๊ณต๋ฐฑ์ ๋ณด๊ธฐ ํธํ์๋ผ๊ณ ๋ฃ์์ต๋๋ค! ์ค์ ๊ฐ๋ฐํ ๋ ๊ณต๋ฐฑ์์ด!
- ์ฝ๋ ํ ์ค ์ต๋ ๊ธ์ ์ (
printWidth
): 120 - ์ฌ๋ฐฑ (
tabWidth
): 2์นธ
- ๊ธฐ๋ณธ์ ์ผ๋ก eslint-config-airbnb-typescript ๋ฅผ ๋ฐ๋ฅธ๋ค
- ์ถ๊ฐํ๊ณ ์ถ์ ๋ฃฐ์ด ์๋ ๊ฒฝ์ฐ ๋ ผ์ ํ ๋ฐ์ ๊ฐ๋ฅ.
- ํ๋ก์ ํธ ๋ฃจํธํด๋์
.eslitrc
์ฐธ๊ณ
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src", "tsconfig.paths.json"]
}
- ์ปดํฌ๋ํธ๋ฅผ ๋ฐํํ๋ ํ์ผ์ *.tsx ํ์ฅ์๋ฅผ ์ฌ์ฉํ๋ค.
- ์ปดํฌ๋ํธ๋ฅผ ๋ฐํํ๋ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ *.ts ํ์ฅ์๋ฅผ ์ฌ์ฉํ๋ค.
-
*.tsx
- ์ปดํฌ๋ํธ, ํ์ผ, ํด๋๋ช โ PascalCase -
*.ts
- ํ์ผ, ํด๋๋ช โ cammelCase - ์์ โ SNAKE_CASE
const MAX_COUNT = 100
- ํจ์ ๋ฐ ๋ณ์ โ cammelCase
const foo = () => {}
let bar = 3
- ์ฐฝ์์ ์ธ ๋จ์ด ์ฐ์ง ์๊ธฐ (์ ์ผ ๋ ์ค๋ฅด๊ธฐ ์ฝ๊ณ ๊ธฐ๋ณธ์ ์ธ ๋จ์ด)
- ๋ณ์๋ ๋ช ์ฌํ์ผ๋ก ์์ฑ
- ํจ์๋ ๋์ฌํ์ผ๋ก ์์ฑ (doSomething, getValue)
- ์์
- Header/index.tsx
- components/Slider.tsx
- util/functions/getMoney.ts
- util/hooks/useFetch.ts
- htmlํ๊ทธ ์ ์ธ ์ ๊ฐ๋ฅํ ์๋ฉํฑํ ํ๊ทธ ์ฌ์ฉ
- ํค๋์๋
<header>
๋ฆฌ์คํธ๋<li>
(๊ฐ์ ์๋!)
- ํค๋์๋
- ์ฝ๋ PR์ ์ง์ ๋ ๋ฆฌ๋ทฐ์ด๊ฐ approve ํ ํ์ merge ํ ์ ์๋ค!
- PR ์๋ ๋ค ํ์์๊ณ ๋ฆฌ๋ทฐ์ด๋ง ์ง์ !
- ๋ฆฌ๋ทฐ์ด๊ฐ ์ง์ ํ ๋ถ๋ถ ๊ณ ์น ํ์ comment๋ก ์๋ฆด ๊ฒ
- ์ฝ๋ ๋ฆฌ๋ทฐ๋ ํ์! ๊ผญ ํ์ธํ๊ธฐ!
- ํ์์ ๋ฆฌ๋ทฐ์ ํ ๋ง์ด ์์ผ๋ฉด ๋๋๊ธ์ ์๋ฌ๋๋ผ๋ ์ด๋ชจํฐ์ฝ ๋ฐ์ ์ ๋๋ ํด์ฃผ์~๐
- html ์ id ํน์ className์
snake__case
๋ก ํ๋ค. (ex:label__description
) - JSX์ ์ต์๋จ ํ๊ทธ๋ฅผ StyledComponent ๋ก ํํํ๊ณ
__Layout
์ผ๋ก ๋ง์ถ๋ค. (ex:<TitleLayout>
) - ํจ์ํํ์์ผ๋ก ์จ์ ์ฝ๋ฐฑ์ผ๋ก ์จ๋จน์!