๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ฌ/ใ…ใ……ใ…Œใ…‹ใ…ใ…… ์ฑŒ๋ฆฐ์ง€

34์ผ์ฐจ

๐ŸฆŠ

34์ผ์ฐจ

 

Part 10. React ๋กœ ์‡ผํ•‘๋ชฐ ๋งŒ๋“ค๊ธฐ (React ๊ธฐ๋ณธ)

Ch 3. Creating React Project

 


 

 

Ch 3. Creating React Project

 

 

https://create-react-app.dev/

 

Create React App

Set up a modern web app by running one command.

create-react-app.dev

 

$ npx create-react-app my-app

 

// package.json

{
    "scripts": {
        "start": "react-scripts start", // npm start (๊ฐœ๋ฐœ์šฉ)
        "build": "react-scripts build", // npm run build (ํ”„๋กœ๋•์…˜์šฉ)
        "test": "react-scripts test", // npm test (ํ…Œ์ŠคํŠธ์šฉ)
        "eject": "react-scripts eject" // npm run eject (๊บผ๋ƒ„ => create-react-app ์‚ฌ์šฉX ์ถ”์ฒœใ„ดใ„ด)
    },
}
$ npm run build
$ npx serve -s build

 

 

 ๐Ÿ”— ESLint  (React ๊ธฐ๋ณธ ์ œ๊ณต) => The pluggable linting utility for JavaScript and JSX

 

$ npm i eslint -D
$ npx eslint --init
$ npx eslint index.js // eslint ํ™•์ธ
$ npx eslint index.js --fix // eslint ํ™•์ธ => fix
// .eslintrc.js

module.exports = {
  ...
  rules: {
    semi: ["error", "always"],
  },
};

 

 

 ๐Ÿ”— Prettirer  => An opinionated code formatter

 

https://prettier.io/

 

Prettier · Opinionated Code Formatter

Opinionated Code Formatter

prettier.io

 

$ npm i prettier -D
$ npx prettier index.js // eslint ํ™•์ธ
$ npx prettier index.js --write // eslint ํ™•์ธ => fix
// .prettierrc.json

{
  "singleQuote": true
}

https://prettier.io/docs/en/options.html

 

Prettier · Opinionated Code Formatter

Opinionated Code Formatter

prettier.io

 

https://github.com/prettier/eslint-config-prettier

 

GitHub - prettier/eslint-config-prettier: Turns off all rules that are unnecessary or might conflict with Prettier.

Turns off all rules that are unnecessary or might conflict with Prettier. - GitHub - prettier/eslint-config-prettier: Turns off all rules that are unnecessary or might conflict with Prettier.

github.com

// eslint-config-prettier

{
    ...
    "eslintConfig": {
        "extends": [
            "react-app",
            "prettier"
        ]
    }
}

 

 

 ๐Ÿ”— husky  => Git hooks made easy

 

https://github.com/typicode/husky

 

GitHub - typicode/husky: Git hooks made easy ๐Ÿถ woof!

Git hooks made easy ๐Ÿถ woof! Contribute to typicode/husky development by creating an account on GitHub.

github.com

 

$ npm i husky -D
$ npx husky install
$ npx husky add .husky/pre-commit "npm test"
$ git add -A
$ git commit -m "husky test"
// package.json

{
  "scripts": {
    "prepare": "husky install",
    ...
  },
}

 

 

 ๐Ÿ”— lint-staged  => Run linters on git staged files

 

$ npm i husky -D
$ npx husky install
$ npx husky add .husky/pre-commit "npx lint-staged"
$ npx i lint-staged -D
// package.json

{
  "scripts": {
    "prepare": "husky install",
    ...
  },
  "lint-staged": {
    "**/*.js": [
      "eslint --fix",
      "prettier --write",
      "git add"
    ]
  },
  ...
}

 

'๐Ÿ’ฌ > ใ…ใ……ใ…Œใ…‹ใ…ใ…… ์ฑŒ๋ฆฐ์ง€' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

36์ผ์ฐจ  (0) 2022.03.21
35์ผ์ฐจ  (0) 2022.03.21
33์ผ์ฐจ  (0) 2022.03.19
32์ผ์ฐจ  (0) 2022.03.18
31์ผ์ฐจ  (0) 2022.03.18