Add husky for pre-commit checks

This commit is contained in:
Henrik Hüttemann 2023-05-20 10:44:58 +02:00
parent 8804c37d6d
commit 09d5f1c806
No known key found for this signature in database
GPG Key ID: 9F7BD10E0A8A111E
3 changed files with 37 additions and 4 deletions

8
.husky/pre-commit Executable file
View File

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

22
package-lock.json generated
View File

@ -21,6 +21,7 @@
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.3",
"prettier": "2.8.8",
"typescript": "^5.0.4"
}
@ -1688,6 +1689,21 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"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",
@ -4064,6 +4080,12 @@
"has-symbols": "^1.0.2"
}
},
"husky": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz",
"integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==",
"dev": true
},
"ignore": {
"version": "5.2.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz",

View File

@ -9,14 +9,16 @@
"url": "https://git.verdigado.com/NB-Public/rocketchat2matrix"
},
"scripts": {
"format": "prettier 'src/**/*.ts' --write",
"format": "prettier 'src/**/*.ts' --check",
"format-fix": "prettier 'src/**/*.ts' --write",
"lint": "eslint src/ --ext .ts",
"lint-fix": "eslint src/ --fix --ext .ts",
"prefix": "npm run format",
"prefix": "npm run format-fix",
"fix": "npm run lint-fix",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "echo \"Warning: no test specified\"",
"compile": "rm -rf dist/ && tsc",
"start": "npm run compile && node dist/app.js"
"start": "npm run compile && node dist/app.js",
"prepare": "husky install"
},
"version": "0.1.0",
"devDependencies": {
@ -29,6 +31,7 @@
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.3",
"prettier": "2.8.8",
"typescript": "^5.0.4"
},