Skip to content

Commit 44a8cfd

Browse files
authored
Merge pull request #942 from w3bdesign/lefthook
Set up lefthook to enforce code quality checks during the git workflow. The configuration includes pre-commit linting and a prepare-commit-msg hook for automated commit message generation.
2 parents b2be3d5 + e7ba507 commit 44a8cfd

File tree

4 files changed

+12850
-6577
lines changed

4 files changed

+12850
-6577
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Sanity.io and Typescript.
116116
- 100% test coverage with Jest and React testing library
117117
- AI-powered commit message generation following Conventional Commits with
118118
gitmojis
119+
- Automated pre-commit linting and formatting using Lefthook and lint-staged.
119120
- Automated performance monitoring with Lighthouse CI
120121
- Performance, accessibility, best practices, and SEO checks on every PR
121122
- Configurable thresholds for quality metrics
@@ -164,6 +165,7 @@ Sanity.io and Typescript.
164165
- Structured defect management process
165166
166167
- Enforced AAA (Arrange-Act-Assert) pattern in all test files
168+
167169
- Each test must include the following comments:
168170
169171
```typescript

lefthook.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Lefthook Configuration
2+
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
3+
4+
pre-commit:
5+
commands:
6+
lint-staged:
7+
run: pnpm lint-staged --allow-empty
8+
9+
prepare-commit-msg:
10+
commands:
11+
generate-commit-message:
12+
run: python commit/commit_analyzer.py --hook

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
"ladle": "ladle serve",
2424
"typegen": "npx sanity typegen generate"
2525
},
26+
"lint-staged": {
27+
"*.{js,jsx,ts,tsx,json,css,scss,md,yml,yaml}": [
28+
"prettier --write"
29+
],
30+
"*.{js,jsx,ts,tsx}": [
31+
"eslint --fix"
32+
]
33+
},
2634
"dependencies": {
2735
"@babel/helpers": ">=7.27.4",
2836
"@emailjs/browser": "^4.4.1",
@@ -82,6 +90,8 @@
8290
"jest-environment-jsdom": "^29.7.0",
8391
"jest-extended": "^5.0.3",
8492
"jsdom-testing-mocks": "^1.13.1",
93+
"lefthook": "^1.11.13",
94+
"lint-staged": "^16.1.0",
8595
"postcss": "^8.5.4",
8696
"prettier": "3.5.3",
8797
"tailwindcss": "^4.1.8",

0 commit comments

Comments
 (0)