feat: add husky & commitlint

Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
This commit is contained in:
Vinayak Kulkarni 2022-09-20 13:14:46 +05:30
parent 609b0c9163
commit 33b135518e
No known key found for this signature in database
GPG key ID: 0FE8ABF8260A1552
5 changed files with 39 additions and 3 deletions

21
.husky/commit-msg Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
NAME=$(git config user.name)
EMAIL=$(git config user.email)
if [ -z "$NAME" ]; then
echo "empty git config user.name"
exit 1
fi
if [ -z "$EMAIL" ]; then
echo "empty git config user.email"
exit 1
fi
git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $NAME <$EMAIL>" \
--in-place "$1"
npm exec --no -- commitlint --edit $1

4
.husky/pre-push Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm exec --no -- lint-staged --no-stash

3
commitlint.config.cjs Normal file
View file

@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};

4
lint-staged.config.cjs Normal file
View file

@ -0,0 +1,4 @@
module.exports = {
'*.{js,ts}': 'npm run lint:js',
'*.{yml}': 'npm run lint:yml',
};

View file

@ -8,11 +8,12 @@
"scripts": {
"test": "mocha test/**.js --timeout 10000",
"lint:yml": "yamllint --schema=CORE_SCHEMA *.{yml,yaml}",
"lint:js": "npm run lint:prettier",
"lint:js:fix": "npm run lint:prettier:fix",
"lint:prettier": "prettier --check \"{,!(node_modules|dist|static)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
"lint:prettier:fix": "prettier --write \"{,!(node_modules|dist|static)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
"lint": "npm run lint:prettier",
"lintfix": "npm run lint:prettier:fix",
"docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:80 $(docker build -q .)"
"docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:80 $(docker build -q .)",
"prepare": "husky install"
},
"dependencies": {
"@mapbox/glyph-pbf-composite": "0.0.3",
@ -40,7 +41,10 @@
"sanitize-filename": "1.6.3"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"chai": "4.3.6",
"husky": "^8.0.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"should": "^13.2.3",