snippets ํ์ฅ ์ฌ์ฉ - ES7+ React/Redux/React-Native snippets
rfc
๋ช
๋ น์ด๋ก ์ปดํฌ๋ํธ ์์ฑํ๋ฉด ๋ฉ๋๋ค.import React from 'react';
์ ๊ฑฐํ๋ ๋ฐฉ๋ฒ.1. VSCode 'User Settings'(์ปจํธ๋กค + ,)
2. React Snippets ๊ฒ์
3. 'React Snippets > Settings: Import React On Top' ์ฒดํฌ ํด์
installed ES7+ React/Redux/React-Native snippets, but i don't have _rfce
1. ๋ณ์๋ช
, ํจ์๋ช
๋ณ์ / ํจ์ : camelCase
์์: SNAKE_CASE / ๋๋ฌธ์
์๋ณ์/ํด๋์ค/์ปดํฌ๋ํธ/์ธํฐํ์ด์ค : PascalCase
(ts ํ์ผ์ camelCase / tsx ํ์ผ์ PascalCase)
ts ํ์ผ ๋ด์ ๋๋ ํ ๋ฆฌ๋ช
: camelCase
์ปดํฌ๋ํธ(tsx) ๋๋ ํ ๋ฆฌ๋ช
: PascalCase
2. ํจ์, ์ปดํฌ๋ํธ ์์ฑ
pages ์ ํ์ด์ง ๋ ๋๋ง ํ์ผ๋ค์ camelCase
์ปดํฌ๋ํธ ๋ง๋ค ๋ export default ํจ์ ๋ช
์์ ๋ถ์ธ๋ค.
ํจ์ ์ ์ธ์ ์ฌ์ฉ function Button() {}
ex)
export function Button() {
const handleClick = () => {}
return <button onClick={handleClick }></button>
}
3. ์ด๋ฒคํธํธ๋ค๋ฌ
camelCase(handleLoginButtonClick / onClickLoginButton)
prop์ผ๋ก ๋๊ฒจ์ฃผ๋ ์ด๋ฒคํธ: on(onClick)
์ง์ ์ฒ๋ฆฌํ๋ ์ด๋ฒคํธ: handle(handleClick)
ex)
<Button onClick={handleClick} />
export function Button({ onClick }) {
return <button onClick={onClick}></button>
}
4. import order
- ๋ฆฌ์กํธ ํ
- ๋ผ์ด๋ธ๋ฌ๋ฆฌ
- ์ปดํฌ๋ํธ
- ์ด๋ฏธ์ง
- css
5. ESLint
{
"extends": ["next/core-web-vitals", "prettier"]
}
6. Prettier
{
"arrowParens": "avoid",
"bracketSpacing": true,
"bracketSameLine": true,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"printWidth": 120,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"endOfLine": "auto"
}
์ฐธ๊ณ . StyleLint
{
"extends": [
"stylelint-config-idiomatic-order",
"stylelint-config-prettier-scss",
"stylelint-config-standard-scss"
],
"plugins": [
"stylelint-scss",
"stylelint-order"
],
"ignoreFiles": [
"@/src/styles/reset.scss"
],
"rules": {
"color-hex-length": "long",
"selector-class-pattern": "^([a-z][a-zA-Z0-9]*)$",
"scss/at-mixin-pattern": "^.[a-z]+(-[a-z0-9])*",
"scss/dollar-variable-pattern": "^.[a-z]+(-[a-z0-9])*",
"scss/percent-placeholder-pattern": "^.[a-z]+(-[a-z0-9])*"
}
}
์ธ์ฆ&ํ๋กํ - 1, 2 =>์์ธ
์ํ ๋ชฉ๋ก(ํ) - 3 => ๋ด์ฐฌ
์ํ ์์ธ(๊ธฐ๋ณธ) - 4.1, 4.4, 4.6 => ์ก์
์ํ ์์ธ(๊ณต๋ ๊ตฌ๋งค) - 4.2, 4.3, 4.5 => ๋ฏผ์
๊ฒฐ์ (์ฃผ๋ฌธ์) + ์ฅ๋ฐ๊ตฌ๋ - 5, 6 => ์ง์
๋ด์ฐฌ: ํด๋๊ตฌ์กฐ / husky / github acrions
๋ฏผ์: prettier
์์ธ: ๊นํ๋ธ ์ด์, PR ํ ํ๋ฆฟ
์ด์์ธ