add git pre-commit hook to prettier code

This commit is contained in:
秦秋旭 2023-02-17 17:18:28 +08:00
parent 2b63ba2825
commit ca67040909
6 changed files with 668 additions and 268 deletions

View File

@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "prettier"]
}

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

8
.prettierrc Normal file
View File

@ -0,0 +1,8 @@
{
"singleQuote": true,
"trailingComma": "all",
"semi": false,
"tabWidth": 2,
"useTabs": false,
"printWidth": 80
}

View File

@ -6,18 +6,29 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"format": "prettier --write \"src/**/*.ts\"",
"prepare": "husky install"
},
"dependencies": {
"@next/font": "13.1.6",
"next": "13.1.6",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "18.13.0",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"eslint": "8.34.0",
"eslint-config-next": "13.1.6",
"next": "13.1.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.9.5"
"eslint": "^8.34.0",
"eslint-config-next": "^13.1.6",
"eslint-config-prettier": "^8.6.0",
"husky": "^8.0.0",
"lint-staged": "^13.1.2",
"prettier": "2.8.4",
"typescript": "^4.9.5"
},
"lint-staged": {
"*.{ts,tsx,js,jsx,json,md}": "prettier --write"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ type Data = {
export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
res: NextApiResponse<Data>,
) {
res.status(200).json({ name: 'John Doe' })
}