Skip to content

Code Formatting Guide

Diego Mejía edited this page Apr 19, 2022 · 1 revision

Variables

Use camelCase, like so:

let testingVariable = 0;

Environment variables should be all uppercase SNAKECASE, as well as starting with "REACT_APP_" so that REACT is able to detect them, like so:

REACT_APP_TESTING_VARIABLE = "secret_key_123";

(Note that if an environment variable is either modified or created while running a development server, said server should be restarted to read those changes)

Functions

For the following functions, use camelCase for their definition.

Normal Functions

const normalFunction = () => {
   console.log("hello world");
}

Async functions

async function helloAsync() {
   await console.log("hello world");
}

React component

function helloComponent ({ name }) {
   /* 
   A React component should be structured like this:
      - React Hook declaration
      - Variable declaration
      - Normal functions
      - Async functions
   */
   return (
      <p>Hello World { name }!</p>
   )
}

Folder structure

Try to stick to the following folder schema:

image

Clone this wiki locally