기본 설정

nextjs typescript 설치

React framework

yarn create next-app --typescript

material-ui 설치

React UI 라이브러리

yarn add @mui/material @emotion/react @emotion/styled

server rendering with nextjs

ESLint + Prettier 설치

https://paulintrognon.fr/blog/typescript-prettier-eslint-next-jsarrow-up-right

ESLint

javascript 문법 검사

yarn add --dev @typescript-eslint/eslint-plugin

// .eslintrc.json
{
  "plugins": ["@typescript-eslint"],
  "extends": [
    "next/core-web-vitals",
    "plugin:@typescript-eslint/recommended"
  ],
  "rules": {
    // I suggest you add those two rules:
    "@typescript-eslint/no-unused-vars": "error",
    "@typescript-eslint/no-explicit-any": "error"
  }
}

Prettier

코딩 스타일 지정

Husky + Lint-staged 설치

커밋 시 prettier 와 eslint 를 먼저 실행하여 에러시 커밋되지 않는다.

https://paulintrognon.fr/blog/typescript-prettier-eslint-next-jsarrow-up-right

lint-staged

커밋 시 에러, 린팅, 코드 포맷을 체크한다.

Lint staged

필요할 때 린트를 실행할 수 있게 설정한다.

pre-commit hook 설정

커밋 시 prettier + eslint 를 먼저 실행한다.

Last updated