Skip to content

feat: added pre commit hooks #1804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
17 changes: 17 additions & 0 deletions .changeset/1804.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@asyncapi/cli': minor
---

feat: added pre commit hooks

- 971c99c: refactor: remove unused dependencies (#1795)

Co-authored-by: Souvikns <[email protected]>
- 4bcd664: test: husky hook
- 97e54f0: test: husky hook
- 3f6ffff: feat: added lefthook for pre-commits
- 904d8e0: fixed and test
- 9f270a4: updated development.md
- 37685bd: updated


17 changes: 17 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ After cloning the repository, you should setup the fork properly and configure t
npm install
```

3. **Set up Git hooks with Lefthook:**

Lefthook is used to run pre-commit and commit message checks automatically.
After installing dependencies, Lefthook hooks are set up automatically if you have the `"prepare": "lefthook install"` script in your `package.json`.
If you ever need to re-install hooks, run:

```bash
npx lefthook install
```

## Pre-commit and commit message hooks

This project uses [Lefthook](https://github.com/evilmartians/lefthook) to enforce code quality and commit standards:

- **Pre-commit:** `npm run lint`, and `npm run test:unit` before every commit.
- **Commit message:** Uses [commitlint](https://commitlint.js.org/) to enforce [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).

## Running tests

### Local testing
Expand Down
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
15 changes: 15 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pre-commit:
parallel: true
commands:
lint:
run: npm run lint
test:
run: npm run test:unit

commit-msg:
parallel: true
commands:
commitlint:
run: npx commitlint --edit {1}
echo-test:
run: echo "Lefthook commit-msg hook running"
Loading