-
Notifications
You must be signed in to change notification settings - Fork 1
Code Conventions
Harman Lamba edited this page Aug 24, 2020
·
2 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
- Single quotes, not double:
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.