Skip to content

Commit c0a686d

Browse files
authored
build: fix hooks verification (#19)
### TL;DR Replace commitizen with commitlint for commit message validation and typos with cspell for spell checking. ### What changed? - Added commitlint configuration with `commitlint.config.js` using conventional commit standards - Replaced typos with cspell for spell checking in the pre-commit hook - Updated lefthook.yml to use cspell instead of typos and commitlint instead of commitizen - Added new dev dependencies: `@commitlint/cli`, `@commitlint/config-conventional`, and `cspell` - Simplified the oxfmt command in lefthook by removing the `exec` prefix - Removed empty `.prettierignore` file ### How to test? 1. Make a commit with an invalid commit message format to verify commitlint rejects it 2. Make a commit with a valid conventional commit message to verify it passes 3. Introduce a spelling error in a file and verify cspell catches it in the pre-commit hook ### Why make this change? This change standardizes the commit message format using the widely-adopted conventional commits specification, which improves commit history readability and enables automated changelog generation. It also replaces the optional typos tool with cspell, which provides more consistent spell checking across the team without requiring external tool installation.
1 parent 755c659 commit c0a686d

5 files changed

Lines changed: 1501 additions & 16 deletions

File tree

.prettierignore

Whitespace-only changes.

commitlint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
extends: ["@commitlint/config-angular"],
3+
};

lefthook.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pre-commit:
88
# Format code with oxfmt
99
oxfmt:
1010
glob: "*.{js,ts,jsx,tsx,json,yaml,yml,md}"
11-
run: pnpm exec oxfmt {staged_files}
11+
run: pnpm oxfmt {staged_files}
1212
stage_fixed: true
1313

1414
buildifier-format:
@@ -20,13 +20,13 @@ pre-commit:
2020
stage_fixed: true
2121

2222
# Check for typos
23-
typos:
24-
run: |
25-
if command -v typos &> /dev/null; then
26-
typos
27-
else
28-
echo "typos not installed, skipping"
29-
fi
23+
cspell:
24+
run: pnpm cspell lint --no-progress --no-summary {staged_files}
25+
exclude:
26+
- pnpm-lock.yaml
27+
- "*.lock"
28+
- lefthook.yml
29+
- package.json
3030

3131
# Note: The following pre-commit hooks are not available in lefthook or were removed:
3232
# - check-hooks-apply (meta hook, lefthook-specific)
@@ -43,11 +43,6 @@ pre-commit:
4343

4444
commit-msg:
4545
commands:
46-
# Commit message validation with commitizen
47-
commitizen:
48-
run: |
49-
if command -v cz &> /dev/null; then
50-
cz check --commit-msg-file {1}
51-
else
52-
echo "commitizen not installed, skipping commit message validation"
53-
fi
46+
# Commit message validation with commitlint
47+
commitlint:
48+
run: pnpm commitlint --edit {1}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"prepare": "lefthook install"
77
},
88
"devDependencies": {
9+
"@commitlint/cli": "^20.3.0",
10+
"@commitlint/config-angular": "^20.3.0",
911
"@evilmartians/lefthook": "^2.0.0",
12+
"cspell": "^9.4.0",
1013
"oxfmt": "^0.22.0"
1114
},
1215
"packageManager": "pnpm@10.27.0"

0 commit comments

Comments
 (0)