Call-for-Code-for-Racial-Justice / Five-Fifths-Voter

Five Fifths Voter is a web application tool designed to enable and empower Black people and others to exercise their right to vote by ensuring their voice is heard
Apache License 2.0
67 stars 37 forks source link

Enable pre-commit hooks #286

Closed rafvasq closed 2 years ago

rafvasq commented 2 years ago

Resolves #285

What did you do?

Added the husky package to enable git hooks for developers

Why did you do it?

Add pre-commit hook support

How have you tested it?

Saw "hello husky" after a test commit

Were docs updated if needed?

Type of change

Checklist:

upkarlidder commented 2 years ago

Thanks @rafvasq. I have not used pre-commit hooks before. Is that idea to perform certain tests like linting, formatting, etc on the developer local machine when they commit the code? Also, I had to follow these steps to enable husky. Are these correct? and if so, we should add these steps in the docs as well.

  1. cd ui
  2. yarn install to install husky
  3. yarn run postinstall to enable husky
  4. Now I get hello husky when I commit.

Since all three directories use the same root husky command, the developer just has to do this once. In any of the three folders.

@davidnixon I guess we should still add similar GitHub actions? Are they complementary to pre-commit hooks? The difference being they are run on servers after the commit happens. The advantage being the user does not have to "enable" anything, they just run on every commit.

Did I understand all this correctly? 😃

davidnixon commented 2 years ago

@upkarlidder exactly right. These are complementary to the actions. For example, It's faster to fix a lint issue if you find it when you commit rather than waiting for the action to run against your PR. The hooks however can be disabled by the committer so we still need the actions.

Also, do you need to tag this as hacktoberfest?

upkarlidder commented 2 years ago

@davidnixon @rafvasq, do we need to update dev docs to mention this new recommended workflow? The devs still need to enable it by running:

  1. cd ui
  2. yarn install to install husky
  3. yarn run postinstall to enable husky
  4. Now I get hello husky when I commit.