Skip to content

Commit

Permalink
chore: setup git hooks to run linter for you
Browse files Browse the repository at this point in the history
By using git hooks, you can make sure your code is linted and formatted as expected.

Added docs to readme for how to install these hooks.

commit-id:8d6cc4bc
  • Loading branch information
levibostian committed Apr 11, 2024
1 parent 76d4567 commit a3a5151
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ Follow the steps below to compile the Wendy project on your machine for contribu

[mint][14] used to run other development CLI commands such as linter/formatter.
[taskfile][15] an alternative to `Makefile` to run commands.
[lefthook](https://github.com/evilmartians/lefthook/blob/HEAD/docs/install.md) for git hooks.

* Install git hooks:

`lefthook install`

* Generate the boilerplate code, otherwise you will not be able to compile the code.

Expand Down
17 changes: 17 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Configuration for lefthook tool to manage git hooks
# https://github.com/evilmartians/lefthook

# Commands to run before committing code.
pre-commit:
commands:
lint:
# Format code and then `git add` modified files from formatter.
run: task format && git add {staged_files}

# Commands to run before pushing code
pre-push:
commands:
lint:
# Run linter giving you errors to fix.
# By using `|| echo "..."`, we do not block you from pushing code. Running lint in a git hooks is to warn you about lint errors early, but not block you from pushing code with errors if you decide to push.
run: task lint || echo -e "\n\n ⚠️ Linting contains errors that will prevent you from merging a pull request. Fix errors above if you are planning on making a pull request."

0 comments on commit a3a5151

Please sign in to comment.