yarn create next-app --typescript
-----
✔ What is your project named? … project_name
✔ Would you like to use ESLint with this project? … No / Yes
✔ Would you like to use Tailwind CSS with this project? … No / Yes
✔ Would you like to use `src/` directory with this project? … No / Yes
✔ Would you like to use experimental `app/` directory with this project? … No / Yes
✔ What import alias would you like configured? … @/*
-----
cd project_name
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier
in settings.json
// settings.json
{
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
},
"editor.formatOnSave": true,
"eslint.format.enable": true,
}
.prettierrc.json
생성
// .prettierrc.json
{
"singleQuote": true
}
// .eslintrc.json
{
"extends": "next/core-web-vitals"
}
"plugin:prettier/recommended"
추가
// .eslintrc.json
{
"extends": [
"next/core-web-vitals",
"plugin:prettier/recommended"
]
}
vs code
를 한번 껏다 켜보자!settings.json
에서 "editor.defaultFormatter”
설정이 빠짐.eslint output
을 확인해보자. 대부분 eslint
설정 오류settings.json
에서 빼먹었는지 확인.
"editor.formatOnSave": true,
"eslint.format.enable": true,
.eslint.json
확인
{
"extends": [
"next/core-web-vitals",
"plugin:prettier/recommended"
]
}
package.json
확인
{
"name": "project_name",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@types/node": "18.15.11",
"@types/react": "18.0.37",
"@types/react-dom": "18.0.11",
"eslint": "8.38.0",
"eslint-config-next": "13.3.0",
"next": "13.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
},
"devDependencies": {
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.7"
}
}