Skip to content

Commit 21535f8

Browse files
committed
chore(lint): add lint-staged and husky for pre-commit checks
1 parent 9adafa1 commit 21535f8

File tree

5 files changed

+134
-25
lines changed

5 files changed

+134
-25
lines changed

.husky/commit-msg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
if ! head -1 "$1" | grep -qE "^(feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert|wip)(\(.+?\))?: .{1,}$|^Merge branch .+$"; then
3+
echo "Aborting commit. Your commit message must match https://www.conventionalcommits.org/en/v1.0.0/" >&2
4+
exit 1
5+
fi

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bun lint-staged
2+
bun -r run typecheck --if-present

.lintstagedrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
'*.{ts,tsx,cjs,js}': (files) => {
3+
const filteredFiles = files.filter((file) => !file.includes('generated'));
4+
return filteredFiles.length > 0
5+
? [
6+
`prettier --write ${filteredFiles.join(' ')}`,
7+
`eslint --fix ${filteredFiles.join(' ')}`,
8+
]
9+
: [];
10+
},
11+
'*.{json,md}': (files) => {
12+
const filteredFiles = files.filter((file) => !file.includes('generated'));
13+
return filteredFiles.length > 0
14+
? `prettier --write ${filteredFiles.join(' ')}`
15+
: [];
16+
},
17+
};

0 commit comments

Comments
 (0)