๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์„ค์น˜&์„ธํŒ…๋ฒ•

ESLint / Prettier

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 11. 20.
๋ฐ˜์‘ํ˜•

๐Ÿฅ— ESLint ๋ž€?

ES + Lint

์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด์„œ ์ƒ๊ธธ ์ˆ˜ ์žˆ๋Š” ์˜ค๋ฅ˜(Error)๋ฅผ ์ž๋™์œผ๋กœ ๋ถ„์„ํ•ด์ฃผ๋Š” ๋„๊ตฌ์ด๋‹ค.

  • ES : Ecma Script.
    Ecma๋ผ๋Š” ๊ธฐ๊ตฌ์—์„œ ๋งŒ๋“  Script. ์ฆ‰, ํ‘œ์ค€ Javascript๋ฅผ ์˜๋ฏธํ•œ๋‹ค.
  • Lint : ์—๋Ÿฌ๊ฐ€ ์žˆ๋Š” ์ฝ”๋“œ์— ํ‘œ์‹œ๋ฅผ ๋‹ฌ์•„๋†“๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.

 

๐Ÿ‘‰๐Ÿป ์„ค์น˜ ๋ฐฉ๋ฒ•



๐Ÿฅ— Prettier ์ด๋ž€?

Visual Studio Code Extention์œผ๋กœ ์ •ํ•ด์ง„ ๊ทœ์น™์— ๋”ฐ๋ผ ์ž๋™์œผ๋กœ ์ฝ”๋“œ ์Šคํƒ€์ผ์„ ์ •๋ฆฌ ํ•ด์ฃผ๋Š” ๋„๊ตฌ์ด๋‹ค.

  • ์ฝ”๋“œ๋ฅผ ์ €์žฅ ์‹œ ์ •ํ•ด๋†“์€ ๊ทœ์น™์— ๋งž๊ฒŒ ์ž๋™์œผ๋กœ ์ •๋ ฌํ•ด์„œ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๊ณ  ์ฝ”๋“œ ์Šคํƒ€์ผ์„ ํ†ต์ผํ•  ์ˆ˜ ์žˆ๋‹ค.
  • Visual Studio Code Extention ์ค‘์— ์ฝ”๋“œ๋ฅผ ์ •๋ ฌํ•ด ์ฃผ๋Š” Code Formatter ์ค‘ ํ•˜๋‚˜์ด๋‹ค.

 

๐Ÿ‘‰๐Ÿป ์„ค์น˜ ๋ฐฉ๋ฒ•

 

 

๐Ÿ‘‰๐Ÿป Setting Guide

์„ธํŒ… ๋ฒ•์€ ํŒ€๋งˆ๋‹ค ๋‹ค๋ฅด๋‹ค!

{
  "singleQuote": true,     // ๋”ฐ์˜ดํ‘œ ๊ณ ์ •
  "semi": true,            // ์ฝ”๋“œ ๋์— ; ์„ค์ •
  "useTabs": false,        // Tap ์‚ฌ์šฉ์—ฌ๋ถ€
  "tabWidth": 2,           // Tap ํฌ๊ธฐ
  "trailingComma": "all",  // ๊ฐ์ฒด ๋ ๋ถ€๋ถ„์—๋„ ์ฝค๋งˆ(comma) ์ถ”๊ฐ€
  "printWidth": 100        // ์ค„ ๋‹น max length
}



๐Ÿฅ— Team Setting

์šฐ๋ฆฌ ํŒ€์€ ์ด๋ ‡๊ฒŒ ํŒ€์„ธํŒ…์„ ์ง„ํ–‰ํ–ˆ๋‹ค!

 

๐Ÿ‘‡๐Ÿป .vscode/settings.json

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
  "source.fixAll.eslint": true,
  },
  "javascript.format.enable": false,
  "eslint.alwaysShowStatus": true,
  "files.autoSave": "onFocusChange"
}

 

๐Ÿ‘‡๐Ÿป .eslintrc (ESLint๊ณผ Prettier๋ฅผ ์—ฐ๊ฒฐ)

{
  "extends": ["react-app", "plugin:prettier/recommended"]
}

 

๐Ÿ‘‡๐Ÿป .prettierrc

{
  "tabWidth": 2, 
  "endOfLine": "lf", 
  "arrowParens": "avoid", 
  "singleQuote": true,
}
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€