Skip to content

Commit cf43b66

Browse files
docs: trim duplicated config snippets; fix gitlint pkg path
1 parent 549a0b2 commit cf43b66

4 files changed

Lines changed: 1 addition & 146 deletions

File tree

docs/guide/getting-started.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,6 @@
22
title: Getting Started with bun-git-hooks
33
description: Learn how to set up and use bun-git-hooks for managing Git hooks in your Bun projects
44
---
5-
'pre-commit': 'bun run lint',
6-
'commit-msg': 'bun commitlint --edit $1',
7-
}
8-
```
9-
10-
### JSON
11-
12-
```json
13-
// git-hooks.config.json
14-
{
15-
"pre-commit": "bun run lint",
16-
"commit-msg": "bun commitlint --edit $1"
17-
}
18-
```
19-
20-
### Package.json
21-
22-
```json
23-
// package.json
24-
{
25-
"name": "my-project",
26-
"git-hooks": {
27-
"pre-commit": "bun run lint",
28-
"commit-msg": "bun commitlint --edit $1"
29-
}
30-
}
31-
```
32-
33-
## Basic Hook Configuration
34-
35-
### Single Command
36-
37-
```typescript
38-
const config: GitHooksConfig = {
39-
'pre-commit': 'bun run lint',
40-
}
41-
```
42-
43-
### Multiple Commands
44-
45-
Chain multiple commands with `&&`:
46-
47-
```typescript
48-
const config: GitHooksConfig = {
49-
'pre-commit': 'bun run lint && bun run test && bun run typecheck',
50-
'pre-push': 'bun run build && bun run test:e2e',
51-
}
52-
```
53-
545
### With Staged File Linting
556

567
Run linters only on staged files (pre-commit only):

docs/guide/hooks.md

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,6 @@
22
title: Hook Types
33
description: Complete guide to all Git hook types supported by bun-git-hooks
44
---
5-
**Use cases:**
6-
7-
- Enforce commit message format (conventional commits)
8-
- Check for required prefixes
9-
- Validate message length
10-
11-
**Example with commitlint:**
12-
13-
```bash
14-
15-
# Install commitlint
16-
17-
bun add -D @commitlint/cli @commitlint/config-conventional
18-
```
19-
20-
```typescript
21-
// commitlint.config.ts
22-
export default {
23-
extends: ['@commitlint/config-conventional'],
24-
rules: {
25-
'type-enum': [2, 'always', [
26-
'feat', 'fix', 'docs', 'style', 'refactor',
27-
'test', 'chore', 'perf', 'ci', 'build',
28-
]],
29-
'subject-case': [2, 'always', 'lower-case'],
30-
},
31-
}
32-
```
33-
34-
### post-commit
35-
36-
Runs after a commit is created. Used for notifications or cleanup.
37-
38-
```typescript
39-
const config: GitHooksConfig = {
40-
'post-commit': 'echo "Commit created successfully!"',
41-
}
42-
```
43-
44-
**Use cases:**
45-
46-
- Send notifications
47-
- Update local documentation
48-
- Trigger builds
49-
50-
### pre-push
51-
52-
Runs before pushing to a remote. This is where you run expensive checks.
535

546
```typescript
557
const config: GitHooksConfig = {

docs/guide/staged.md

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,6 @@
22
title: Staged File Linting
33
description: Run linters and formatters only on staged files with bun-git-hooks
44
---
5-
}
6-
```
7-
8-
## Multiple Commands
9-
10-
### Command Array
11-
12-
Run multiple commands sequentially on matching files:
13-
14-
```typescript
15-
const config: GitHooksConfig = {
16-
'pre-commit': {
17-
stagedLint: {
18-
'*.{ts,tsx}': [
19-
'eslint --fix',
20-
'prettier --write',
21-
],
22-
23-
'*.css': [
24-
'stylelint --fix',
25-
'prettier --write',
26-
],
27-
},
28-
},
29-
}
30-
```
31-
32-
### Execution Order
33-
34-
Commands run in order. If any command fails, the process stops:
35-
36-
```typescript
37-
const config: GitHooksConfig = {
38-
'pre-commit': {
39-
stagedLint: {
40-
'*.ts': [
41-
'eslint --fix --max-warnings=0', // Lint first
42-
'prettier --write', // Then format
43-
'tsc --noEmit', // Then type check
44-
],
45-
},
46-
},
47-
}
48-
```
49-
50-
## How It Works
51-
52-
1. When you run `git commit`, the pre-commit hook activates
535
2. bun-git-hooks gets the list of staged files
546
3. For each pattern, it finds matching staged files
557
4. It runs the specified commands with the matched files as arguments

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@
9090
},
9191
"autoRestage": true
9292
},
93-
"commit-msg": "bunx gitlint --edit .git/COMMIT_EDITMSG"
93+
"commit-msg": "bunx --bun @stacksjs/gitlint --edit .git/COMMIT_EDITMSG"
9494
}
9595
}

0 commit comments

Comments
 (0)