Coding Conventions - HeartUoA/HeaRT GitHub Wiki

Commenting Conventions

  • Comments should only be written as necessary - this article does a good job of explaining when to / not use comments - "Good code comments explain why things are done, not what is done".
  • Place the comment on a separate line, not at the end of a line of code.
  • Begin comment text with an uppercase letter. End comment text with a period.
  • Insert one space between the comment delimiter (//) and the comment text, as shown in the following example:

// I will write good comments. 👍

//i am bad at writing comments 👎

Layout Conventions

  • Use default code editor (with smart indenting)
  • Write only one statement per line
  • Add at least one blank line between method definitions and property definitions.
  • Use parentheses to make clauses in an expression apparent.

Frontend and Backend (JS) Conventions

For React development, coding conventions defined by Airbnb's styling guide will be followed.

Components

Functional components will be used with an arrow function.

 class Component extends React.Component {} 👎 
 function Component() {} 👎 
 const Component = () => {} 👍 

Functions

Functions will be defined using arrows

 function DoSomething() {} 👎 
 const DoSomething = () => {} 👍

Naming Conventions

Pascal Case

Custom Components:

const MyComponent = () => {}

Component/CSS Files:

MyComponent.js

Camel Case

Fields:

let isEmpty = true

Functions:

const onClick = () => {}

Normal JavaScript files:

helperFunctions.js

Comments

/** **/ Higher level comments

// In line comments

Strings

Double quotes, not single:

import React from "react"