Skip to content

Code Formatting and Standards

Cristian Aldea edited this page Mar 13, 2020 · 3 revisions

Pre-commit

We are using pre-commit for coding standards.

Installation

  1. Install here: https://pre-commit.com/#install
  2. pre-commit install
  3. Once there exists a .pre-commit-config.yaml file, you can run pre-commit run -a

How does it work?

  • Pre-commit is a local Git hook that runs when you do a git commit ... command.
  • Your commit will pass if all pre-commit checks have passed.
  • Otherwise, pre-commit will make the changes for you so that the checks will pass, and you have to re-commit.

How does it benefit us?

  • Depending on the hooks we use, it can and will enforce our coding standards.
  • First layer of code protection: running pre-commit locally to pass all checks
  • Second layer of code protection: running pre-commit checks on Travis
  • Third layer of code protection: you cannot merge any PR unless all Travis builds have passed

Additional Coding Standards

  • When passing properties to a component, the names must match:
<Component propertyName={propertyName}/>