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 the eslint linter on a file that is passed as a command-line argument
    • Add appropriate package.json fields so that the test-staged script is executed on all staged javascript files. (Refer to lint-staged and husky documentation for examples)

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

  • npm
  • git
  • bookbrainz
  • validation

Students who completed this task

Eshan Singh

Task type

  • code Code
  • done_all Quality Assurance
close

2017