DEV/DevelopSystem

[Env] Prettier Configuration File ์ ์šฉ

9thxg 2024. 3. 8. 14:59

๐Ÿ’ป ๊ฒฐ๊ณผ

Project
  ใ„ดnode_module
  ใ„ดsrc
  ใ„ด.prettierrc
  • ํ”„๋กœ์ ํŠธ Root ํด๋”์—์„œ .prettierrc ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋‹ค.
{
    "arrowParens": "always",
    "printWidth": 120,
    "semi": true,
    "tabWidth": 4,
    "useTabs": true
}
 

Prettier · Opinionated Code Formatter

Opinionated Code Formatter

prettier.io

  • ํ”„๋กœ์ ํŠธ ๋ณ„ Prettier ์„ค์ • ์™„๋ฃŒ.

 

๐Ÿ“ console.log(history)

ํšŒ์‚ฌ ํ”„๋กœ์ ํŠธ๋ฅผ ํ•˜๋‹ค ๋ณด๋‹ˆ ์ด์ „ ํ”„๋กœ์ ํŠธ์™€ ๋‹ค๋ฅด๊ฒŒ ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด์ง€๊ฒŒ ๊ตฌํ˜„ํ•ด์•ผ ํ•  ํŽ˜์ด์ง€๊ฐ€ ์ƒ๊ฒผ๋‹ค. ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด์ง€๋‹ค ๋ณด๋‹ˆ Prettier ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ์ค„ ๋ฐ”๊ฟˆ์ด ๋งŽ์ด ์ผ์–ด๋‚˜์„œ ๊ฐ€๋…์„ฑ์ด ๋งค์šฐ ์ข‹์ง€ ์•Š์•˜๋‹ค.

 

Prettier ๊ฐœ์ธ ์„ค์ •์„ ๋ณ€๊ฒฝํ•˜๋ฉด ๊ฐ™์ด ์ž‘์—…ํ•˜์‹œ๋Š” ๋ถ„๋“ค์ด ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ์ž‘์—…ํ•  ๋•Œ๋งˆ๋‹ค ์ „์ฒด๊ฐ€ ์ˆ˜์ •๋  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ”„๋กœ์ ํŠธ ์ž์ฒด์— ์ ์šฉํ•ด์•ผ ํ–ˆ๋‹ค.

 

๋จผ์ € ๋Œ€๋ฆฌ๋‹˜์—๊ฒŒ ํ•ด๋‹น ์ด์Šˆ์— ๋Œ€ํ•ด ๋ง์”€๋“œ๋ฆฌ๊ณ  ํ”„๋กœ์ ํŠธ์— Configuration File์„ ์ƒ์„ฑํ•ด ์„ค์ •์„ ์™„๋ฃŒํ–ˆ๋‹ค. ํ™•์‹คํžˆ "printWidth" ์˜ต์…˜์„ 80์—์„œ 120์œผ๋กœ ๋Š˜๋ฆฌ๋‹ˆ ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์ด ์ข‹์•„์กŒ๋‹ค.

 

ํšŒ์‚ฌ์—์„œ๋Š” eslint ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์ถ”๊ฐ€์ ์ธ ์„ค์ •์ด ํ•„์š” ์—†์œผ๋‚˜ ๋งŒ์•ฝ eslint๋ฅผ ํ™œ์šฉํ•˜๊ณ  ์žˆ๋‹ค๋ฉด eslint์™€ ์—ฐ๋™ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€์ ์ธ ์„ค์ •์ด ํ•„์š”ํ•˜๋‹ค.

 

๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธํ•  ๋•Œ๋„ prettier ์˜ต์…˜์— ๋Œ€ํ•œ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋Š”๋ฐ Configuration File์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์–ด์„œ ์ถ”ํ›„ ํ”„๋กœ์ ํŠธ์—์„œ๋„ ์ ๊ทน ํ™œ์šฉํ•  ์˜ˆ์ •์ด๋‹ค.