Skip to content

Commit 43b8dfe

Browse files
authored
build(commitlint): replace npm commitlint with go version (#661)
Co-authored-by: Omer Cohen <omercnet@users.noreply.github.com>
1 parent 8465282 commit 43b8dfe

File tree

4 files changed

+63
-55
lines changed

4 files changed

+63
-55
lines changed

.commitlint.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: v0.18.6
2+
formatter: default
3+
4+
rules:
5+
- header-max-length
6+
- body-leading-blank
7+
- body-max-line-length
8+
- footer-leading-blank
9+
- footer-max-line-length
10+
- type-enum
11+
- type-case
12+
- type-empty
13+
- scope-case
14+
- subject-empty
15+
- subject-full-stop
16+
17+
severity:
18+
default: error
19+
20+
settings:
21+
header-max-length:
22+
argument: 72
23+
body-max-line-length:
24+
argument: 100
25+
footer-max-line-length:
26+
argument: 100
27+
type-enum:
28+
argument:
29+
- feat
30+
- fix
31+
- docs
32+
- style
33+
- refactor
34+
- perf
35+
- test
36+
- build
37+
- ci
38+
- chore
39+
- revert
40+
type-case:
41+
argument: lower
42+
scope-case:
43+
argument: lower
44+
subject-full-stop:
45+
argument: "."
46+
flags:
47+
negate: true

.commitlintrc.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

.hooks/pre-commit

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,29 @@
22

33
source scripts/lint/lint.sh
44

5-
# Validate commit message using commitlint (if available)
6-
if command -v npx &> /dev/null; then
5+
COMMITLINT_VERSION="0.18.6"
6+
7+
ensure_commitlint() {
8+
if ! command -v commitlint &> /dev/null; then
9+
echo "Installing commitlint (Go version) v${COMMITLINT_VERSION}..."
10+
go install github.com/conventionalcommit/commitlint@v${COMMITLINT_VERSION}
11+
echo "Done installing commitlint"
12+
fi
13+
}
14+
15+
validate_commit_message() {
716
echo "- Validating commit message with commitlint"
817
if [ -f .git/COMMIT_EDITMSG ]; then
9-
npx --no-install commitlint --edit .git/COMMIT_EDITMSG
10-
if [ $? -ne 0 ]; then
18+
ensure_commitlint
19+
if ! commitlint lint < .git/COMMIT_EDITMSG; then
1120
echo "Commit message does not follow conventional commits format"
1221
echo "Expected format: <type>(<scope>): <subject>"
1322
echo "Example: feat: add new authentication method"
1423
echo "Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
1524
exit 1
1625
fi
1726
fi
18-
fi
27+
}
1928

20-
run_linter --build-folder "./..." --do-not-check-main $1
29+
validate_commit_message
30+
run_linter --build-folder "./..." --do-not-check-main "$1"

package.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)