CodeNight-Ethiopia / codenight-frontend

Website for the Codenight Developer Community
https://codenight.et
MIT License
46 stars 27 forks source link

Add pre commit hooks #19

Closed hope-miky closed 1 year ago

hope-miky commented 1 year ago

Closes #18

Changes

Added pre-commit hooks for Rome, Next-Lint, Run Tests, and Build in .pre-commit-config.yaml. The hooks are configured to run on commit and push stages and updated the contribution doc accordingly.

Description

This pull request adds pre-commit hooks to ensure consistent code formatting, linting, building and testing before committing and pushing changes. The following hooks have been added:

Rome: to format the code using Rome Next-Lint: to run linting for the Next.js project Run Tests: to run tests using npm run test Build: to build the Next.js project

These hooks will help to ensure that code quality is maintained and prevent common errors and issues from being introduced.

Usage To use these pre-commit hooks, ensure that you have pre-commit installed:

pip install pre-commit   # other options on https://pre-commit.com/

Then, run the following command in the root directory of your project:

pre-commit install && pre-commit install --hook-type pre-push

This will install all hooks with the stages field set to either commit or push. The --hook-type option is used to specify commit hooks

After running this command, all hooks in your .pre-commit-config.yaml file will be installed and ready to use. You can then run git commit or git push as usual, and the pre-commit hooks will automatically run before the commit or push is completed.

Example output when committing

Screenshot 2023-04-05 at 16 43 18

Example output when pushing

Screenshot 2023-04-05 at 16 43 08