-
Notifications
You must be signed in to change notification settings - Fork 0
Code Conventions
salma-s edited this page May 9, 2020
·
5 revisions
- 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 am bad at comments
👍 // I will write good comments
- 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, as shown in the following code.
For C# development, coding conventions defined by Microsoft C# guidelines will be followed.
For React development, coding conventions defined by Google's styling guide will be followed.
Whenever possible, functional components with an arrow function will be used.
👎 class Component extends React.Component {}
👎 function Component() {}
👍 const Component = () => {}
Functions will be defined using arrows
👎 function DoSomething() {}
👍 const DoSomething = () => {}
-
Custom Components:
const MyComponent = () => {}
-
Component/CSS Files:
my-component.js
-
Fields:
let isEmpty = true
-
Functions:
const onClick = () => {}
-
Normal JavaScript files:
helper-functions.js
/** **/ Higher level comments
// In line comments
- Double quotes, not single:
import React from "react"
- Dispatching: The action type must always be dispatched. If the data being dispatched is an object containing two or more properties, the data should be wrapped in
payload
. Otherwise, if the data being dispatched is one data type (e.g. a string array) then it can be dispatched as is.
Jainal Gandhi | Harman Lamba | Eric Leung | Salma Sanad
Made with love 👨👨👧👦💖