Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

exit $exitCode
fi
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Run lint-staged to lint staged files
npx lint-staged

# Run tests
npm test
30 changes: 25 additions & 5 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,52 @@ cd yapli
2. Set up environment variables into `.env.local` (see `.env.example`)
3. Start development server: `npm run dev`

### 4. Create a Branch
### 4. Pre-commit Hooks with Husky

Yapli uses [Husky](https://typicode.github.io/husky/) to run pre-commit hooks that ensure code quality before commits:

1. **Automatic Setup**: Husky is automatically installed and configured when you run `npm install` (via the `prepare` script)
2. **Pre-commit Hook**: The pre-commit hook runs:
- `lint-staged`: Runs ESLint on staged JavaScript/TypeScript files
- `npm test`: Runs all tests to ensure nothing breaks

If you're not seeing the pre-commit hooks run when you commit:

1. Ensure Git hooks are enabled: `git config core.hooksPath .husky`
2. Make sure Husky is installed: `npm run prepare`
3. Verify the pre-commit hook is executable: `chmod +x .husky/pre-commit`

To temporarily bypass the pre-commit hook (not recommended):
```bash
git commit -m "Your message" --no-verify
```

### 5. Create a Branch

```bash
git checkout -b your-branch-name
```

### 5. Make Your Changes
### 6. Make Your Changes

- Follow the code standards outlined in [CLAUDE.md](CLAUDE.md)
- Write tests for new functionality
- Ensure your code passes linting: `npm run lint` and `npm run build`

### 6. Commit Your Changes
### 7. Commit Your Changes

```bash
git add .
git commit -m "feat: add your feature description"
```

### 7. Push to Your Fork
### 8. Push to Your Fork

```bash
git push origin your-branch-name
```

### 8. Create a Pull Request
### 9. Create a Pull Request

1. Navigate to your fork on GitHub
2. Click "New Pull Request"
Expand Down
Loading