Skip to content

Commit

Permalink
feat: add husky & commitlint πŸŽ‰
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kulkarni <[email protected]>
  • Loading branch information
Vinayak Kulkarni committed Apr 29, 2024
1 parent 53ac311 commit f219417
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm exec --no -- lint-staged --no-stash
3 changes: 3 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
3 changes: 3 additions & 0 deletions lint-staged.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'*.{js,cjs,mjs,ts}': 'npm run lint',
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:ci": "jest --testLocationInResults --ci --outputFile=test_results.json --json",
"build": "tsc",
"prepublishOnly": "tsc",
"prepare": "npm run build",
"prepare": "is-ci || husky; npm run build",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lintfix": "npm run lint:eslint:fix && npm run lint:prettier:fix",
"lint:eslint": "eslint \"{,!(node_modules|dist)/**/}*.{js,cjs,mjs,ts}\" --ignore-path .gitignore",
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"esnext"
],
"module": "esnext",
"outDir": "build",
"outDir": "dist",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "node",
Expand All @@ -14,5 +14,8 @@
"strict": true,
"resolveJsonModule": true
},
"exclude": ["node_modules", "build"]
"exclude": [
"node_modules",
"dist"
]
}

0 comments on commit f219417

Please sign in to comment.