MetaBrainz Foundation
Add project pre-commit hooks to BookBrainz
The goal of this task is to add a pre-commit hook that tests all files that have been staged to git. This change will save time by having linter/test errors be caught locally during development instead of after the continuous integration suite has been run. Code formatters such as prettier can also be run automatically once this tool-chain is set up.
To get started, clone the bookbrainz-site repository and create a new branch named "precommit-YOUR_GCI_USERNAME".
Following this, you will need to:
- Install lint-staged and husky
- Edit the project's
package.jsonfile:- Add an npm
test-stagedscript that runs theeslintlinter on a file that is passed as a command-line argument - Add appropriate
package.jsonfields so that thetest-stagedscript is executed on all staged javascript files. (Refer to lint-staged and husky documentation for examples)
- Add an npm
Commit your changes, using small commits which make clear, self-contained changes, and using the conventions here. Finally, push your work to GitHub and create a new Pull Request.
Task tags
Students who completed this task
Eshan Singh