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.json
file:- Add an npm
test-staged
script that runs theeslint
linter on a file that is passed as a command-line argument - Add appropriate
package.json
fields so that thetest-staged
script 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