Skip to content

Core v4 Style Guide

crowbardispensingcore edited this page Jan 19, 2022 · 9 revisions

API

Success Response Format

{

  "data": {

    "firstName": "Jane",

    "lastName": "Doe",

    "email": "example@email.com"

  }

}

Error Response Format

{

  "error": {

    "message": "Use 8 characters or more for your password"

  }

}

How to Read Response With Axios

try {

    const res = await axios.post(...);

    const { firstName, lastName, email } = res.data.data;

} catch (err) {

    const status = err.response.status;

    const { message } = err.response.data.error;

}

React Code

  • Use functional component instead of class component

  • Use state hooks

  • Break down components as much as possible

PR Description

  • Use the PR template

File Naming

Folder kebab-case

backend/main-endpoints/routes

Non React File kebab-case

officer-manager.js

React File PascalCase.jsx

ProfileHeader.jsx

React Stylesheet PascalCase

ProfileHeader.css

ProfileHeader.scss

Others kebab-case

helper-function.js

header-image.jpg

MongoDB

Database camelCaseDB

  • camelCase

  • append DB to the end of the name

  • singular

myNewDB

Collection lowercasenoseparator

  • lowercase

  • no separators

  • plural

doorcodes
inventoryitems

Field camelCase

accessLevel

firstName

HTML & CSS

BEM — Block Element Modifier