You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,77 @@ based on the labels of the pull requests merged into the `main` branch.
56
56
57
57
See the [release-drafter configuration](./.github/release-drafter.yml) for more details.
58
58
59
+
## Git Hooks with Husky.Net
60
+
61
+
This repository uses [Husky.Net](https://alirezanet.github.io/Husky.Net/) to automatically format and validate code before commits and pushes.
62
+
63
+
### What Gets Checked
64
+
65
+
**Pre-commit hooks** (run on staged files):
66
+
-**prettier** - Formats TypeScript, JavaScript, CSS, and JSON files in `src/Elastic.Documentation.Site/`
67
+
-**typescript-check** - Type checks TypeScript files with `tsc --noEmit` (only if TS files are staged)
68
+
-**eslint** - Lints and fixes JavaScript/TypeScript files
69
+
70
+
**Pre-push hooks** (run on files being pushed):
71
+
-**dotnet-lint** - Lints C# and F# files using `./build.sh lint` (runs `dotnet format --verify-no-changes`)
72
+
73
+
### Installation
74
+
75
+
Husky.Net is included as a dotnet tool. After cloning the repository, restore the tools:
76
+
77
+
```bash
78
+
dotnet tool restore
79
+
```
80
+
81
+
Then install the git hooks:
82
+
83
+
```bash
84
+
dotnet husky install
85
+
```
86
+
87
+
That's it! The hooks will now run automatically on every commit and push.
88
+
89
+
### Usage
90
+
91
+
Once installed, hooks run automatically when you commit or push:
92
+
93
+
```bash
94
+
git add .
95
+
git commit -m "your message"# Pre-commit hooks run here
96
+
git push # Pre-push hooks run here
97
+
```
98
+
99
+
**Note:** If hooks modify files (prettier, eslint), the commit will fail so you can review the changes. Simply stage the changes and commit again:
100
+
101
+
```bash
102
+
git add -u
103
+
git commit -m "your message"
104
+
```
105
+
106
+
If the **dotnet-lint** hook fails during push, you need to fix the linting errors and commit the fixes before pushing again.
107
+
108
+
### Manual Execution
109
+
110
+
You can test hooks without committing or pushing:
111
+
112
+
```bash
113
+
# Run all pre-commit tasks
114
+
dotnet husky run --group pre-commit
115
+
116
+
# Run all pre-push tasks
117
+
dotnet husky run --group pre-push
118
+
119
+
# Test individual tasks
120
+
dotnet husky run --name prettier
121
+
dotnet husky run --name typescript-check
122
+
dotnet husky run --name eslint
123
+
dotnet husky run --name dotnet-lint
124
+
```
125
+
126
+
### Configuration
127
+
128
+
Hook configuration is defined in `.husky/task-runner.json`. See the [Husky.Net documentation](https://alirezanet.github.io/Husky.Net/guide/task-runner.html) for more details.
129
+
59
130
## Creating a New Release
60
131
61
132
To create a new release trigger the [release](https://github.com/elastic/docs-builder/actions/workflows/release.yml) workflow on the `main` branch.
0 commit comments