๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

"Setting" ํƒœ๊ทธ๋กœ ์—ฐ๊ฒฐ๋œ 2๊ฐœ ๊ฒŒ์‹œ๋ฌผ๊ฐœ์˜ ๊ฒŒ์‹œ๋ฌผ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  ํƒœ๊ทธ ๋ณด๊ธฐ

ยท ์•ฝ 3๋ถ„

React + TypeScript + Storybook + ESLint ์„ธํŒ…#

ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ#

yarn create react-app my-app-name --template typescript

CRA + ESLint + Prettier#

Create-React-App with TypeScript, ESLint, Prettier, and Github Actions

Husky + lint-staged#

์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ํŒŒ์ผ ์ง€์šฐ๊ธฐ#

.gitignore#

.gitignore ๋Š” ํ”„๋กœ์ ํŠธ์—์„œ ์ค‘์š”ํ•œ ๊ฒƒ์œผ๋กœ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ์ž์ฒด์—์„œ ์ƒ์„ฑํ•œ ํŒŒ์ผ์ด๋‚˜ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋‚˜์—ดํ•ด์•ผ ํ•œ๋‹ค. ๊ฐ€์žฅ ์ข‹์€ ์˜ˆ๋Š” ์บ์‹œ ํŒŒ์ผ, ๋กœ๊ทธ, ๋กœ์ปฌ ๊ตฌ์„ฑ ๋“ฑ์ด๋‹ค.

.vscode , .idea , .DS_Store ๋“ฑ์€ ํ”„๋กœ์ ํŠธ์˜ .gitignore ๋ณด๋‹ค ์ปดํ“จํ„ฐ์˜ ๊ธ€๋กœ๋ฒŒ .gitignore ์— ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

๊ธ€๋กœ๋ฒŒ .gitignore ๋Š” home ๋””๋ ‰ํ† ๋ฆฌ์˜ .gitconfig ์„ ๋ณด๋ฉด ์•Œ ์ˆ˜ ์žˆ๋‹ค.

[core]    excludesfile = /Users/{home}/.gitignore_global

Don't put .idea and .vscode directories to project's .gitignore

ํด๋” ๊ตฌ์„ฑํ•˜๊ธฐ#

โ””โ”€โ”€ src    โ”œโ”€โ”€ components        โ””โ”€โ”€ src    โ”œโ”€โ”€ pages    โ”œโ”€โ”€ App.tsx    โ””โ”€โ”€ index.tsx

Storybook ์„ค์น˜ํ•˜๊ธฐ#

npx sb init

https://storybook.js.org/docs/react/get-started/install


์›น ํฐํŠธ ์‚ฌ์šฉ#

NAVER D2


free illustration#

unDraw - Open source illustrations for any idea


Styled Components#

The Advanced Way to Style with Styled Components

Thoughts around design systems: implementationโ€Š-โ€ŠReact, Styled-Components, and more

How does the ampersand work in styled-components?

The Sass Ampersand | CSS-Tricks

Type Guard#

https://www.typescriptlang.org/docs/handbook/advanced-types.html

validate css unit value#

https://www.reddit.com/r/learnjavascript/comments/8u5pew/function_that_can_validate_if_a_string_is_a_valid/

ยท ์•ฝ 2๋ถ„

ESLint#

  • ํฌ๋งทํŒ…

  • ์ฝ”๋“œ ํ’ˆ์งˆ

๊ทœ์น™#

rules ๋กœ ์ถ”๊ฐ€ ๊ฐ€๋Šฅ

  • ์ž๋™์œผ๋กœ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ทœ์น™๊ณผ ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ทœ์น™์ด ์žˆ์Œ.

  • ๊ทœ์น™ ๋ชฉ๋ก ์ค‘ ๋ Œ์น˜ ๊ธฐํ˜ธ๊ฐ€ ๋ถ™์€ ๊ฒƒ์ด ์ž๋™์œผ๋กœ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ทœ์น™

  • --fix ์˜ต์…˜์œผ๋กœ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

List of available rules

Extends#

  • ์—ฌ๋Ÿฌ ๊ทœ์น™์„ ๋ชจ์•„๋†“์€ ๊ฒƒ๋“ค

  • eslint:recommended , eslint-config-airbnb-base , eslint-config-standard ๋“ฑ์ด ์žˆ๋‹ค.

init#

--init ์˜ต์…˜์œผ๋กœ ๋Œ€ํ™”์‹์œผ๋กœ ์„ค์ • ๊ฐ€๋Šฅ

npx eslint --init
? How would you like to use ESLint?? What type of modules does your project use?? Which framework does your project use?? Where does your code run?? How would you like to define a style for your project?? Which style guide do you want to follow?? What format do you want your config file to be in?

Prettier์™€์˜ ํ†ตํ•ฉ#

Integrating with Linters ยท Prettier

Create-React-App with TypeScript, ESLint, Prettier, and Github Actions