Add pre-commit hook for formatting and linting

This commit is contained in:
Maciej Pędzich 2023-05-23 10:15:07 +02:00
parent f86fcb61e5
commit f0c17e756b
3 changed files with 25 additions and 2 deletions

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run prettier-format && npm run lint

18
package-lock.json generated
View File

@ -25,6 +25,8 @@
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.0.0",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"typescript": "^5.0.0",
"vite": "^4.2.0",
"vite-plugin-eslint": "^1.8.1",
@ -1815,6 +1817,21 @@
"he": "bin/he"
}
},
"node_modules/husky": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
"integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
"dev": true,
"bin": {
"husky": "lib/bin.js"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/ignore": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",
@ -2356,7 +2373,6 @@
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"dev": true,
"peer": true,
"bin": {
"prettier": "bin-prettier.js"
},

View File

@ -6,7 +6,8 @@
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"lint": "eslint . --fix --ignore-path .gitignore",
"prettier-format": "prettier --config .prettierrc --ignore-path .gitignore --write \"./**/*.{vue,js,ts}\""
"prettier-format": "prettier --config .prettierrc --ignore-path .gitignore --write \"./**/*.{vue,js,ts}\"",
"prepare": "husky install"
},
"dependencies": {
"@mdi/font": "7.0.96",
@ -26,6 +27,8 @@
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.0.0",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"typescript": "^5.0.0",
"vite": "^4.2.0",
"vite-plugin-eslint": "^1.8.1",