Skip to content

Backend: Contributing to the source code

Tim K edited this page Sep 3, 2018 · 2 revisions

This page talks about good development practices and correct developer etiquette. No one likes reading spaghetti code and no one likes debugging someone else's code, so it's your responsibility to only push working, well-tested code online.

As a quick summary, your pre-push ritual should look as follows:

  1. Make the code changes you need to make, e.g. add a new feature.
  2. If you need to make any changes to the database, define them using migrations, don't change the database manually! (see Database section in the sidebar for info)
  3. Write tests for the new feature, and make sure they pass. Don't just test the obvious cases - throw in some edge cases and scenarios where feature is supposed to throw an error.
  4. Make sure you didn't break any of the other features in the process by running npm run test-all and making sure they pass.
  5. Make sure your coding style is correct by running npm run lint and fixing any warnings that come up.
  6. Stage the files you changed using Git and write a good, descriptive commit message. If needed, split your changes into several commits.
  7. Finally, push!

This might seem tedious but this ritual is very much worth it - it means that you'll never have to waste time going back to older commits to fix some overseen bugs.

Coding style

Make sure to review the Backend > Notes section in the sidebar. It contains useful information about JavaScript and PostgreSQL coding styles, as well as many other useful tips. Before you push any code online, make sure that npm run lint commands exits without errors or warnings.

We're using ESLint for linting, and chances are your editor has built-in support for it. Check this page to see if your editor can run ESLint automatically.

Git usage

Coming soon.

Testing

Coming soon.