📋
Philanthrolab
  • Philanthrolab Technical Docs
  • SSN Component Library
  • Datalabs
    • Introduction
    • Architecture
    • Schema Dictionary
    • Project Status/Timeline
  • Social Safety Network
    • Introduction
    • Architecture
    • Schema Dictionary
    • Project Status/Timeline
      • V1
      • V2
  • SSN for Organisations
    • Introduction
    • Features and user stories
    • Architecture
    • Schema Dictionary
    • Project Status/Timeline
  • Developer Resources
    • Frontend Project Guide
    • Coding Guide
    • Creating a Neo4j instance on GCP vm
    • Set up local deploy for staging and production envs
    • Install ElasticSearch on GCP
    • ElasticSearch Query
    • ETL Strategy for Neo4j Database: Scraping, Transformation, and Enrichment
    • ETL Checklist
  • SSN Authentication
    • Introduction
    • Architecture
    • Schema
  • SSN Admin Dashboard
    • Introduction
    • Architecture
  • SSN Job Board
    • Introduction
    • Architecture
    • User Stories
    • Schema Dictionary
  • SSN Eligibility criteria AI feature
    • Introduction
    • Working Principles
    • Architecture
    • Schema Dictionary
  • DataBase Repopulation
    • Introduction
    • Proposed Solution
    • DB Details
    • Batch 1
  • LLM INTEGRATION
    • LLM Strategy and Implementation
Powered by GitBook
On this page
  • JavaScript and Nodejs Guide
  • Commits
  • Major Changes
  • File names
  • Indentation
  • Source file structure
  • Naming Convention
  • Class names
  • Method names
  • Constant names
  • JSDoc
  • Testing

Was this helpful?

  1. Developer Resources

Coding Guide

PreviousFrontend Project GuideNextCreating a Neo4j instance on GCP vm

Last updated 11 months ago

Was this helpful?

JavaScript and Nodejs Guide

This style guide extends from the official and some aspects has been modified to suit our needs.

Commits

Git commits should follow the format:

[file/method/function changed]: (Fixes #num | Refs #num ) Your descriptive commit message

Note: #num is a pull or issue number.

For example:

[Imageprocessor]: Fixes #20 Add crop method

Major Changes

All changes are made in new branches and a pull request should be opened against the dev branch for review.

File names

File names must be all lowercase and may be separated by dot . For example:

-User
  - create.user.js
  - update.user.js

Indentation

We use two spaces for indentation. If you use a code editor like vscode, you can set a default spaces to 2 instead of 4. We do not use Tab.

Source file structure

A file consist of the following, in order:

  • License or copyright information

  • ES import statements, if an ES module

  • The file’s source code

For example:

/**
    Copyright 2020, Philanthrolab.
    All rights reserved.
**/
import table from 'table-data'
import me from 'you'
import { cat, dog, eagle } from '../animals'

/**
    Returns the sum of two numbers
    @param {number} num1 
    @param {number} num2 
    @returns {number} sum of num1 and num2 
*/ 
function getSum(num1, num2){
     return num1 + num2
 }

Naming Convention

Class names

Class, interface, record, and typedef names are written in UpperCamelCase e.g ImageProcessor. Type names are typically nouns or noun phrases. For example, Request, ImmutableList, or VisibilityMode.

Method names

Method names are written in lowerCamelCase e.g addNum. Names for private methods must start with a trailing underscore e.g _startAddition.

Method names are typically verbs or verb phrases. For example, sendMessage or _stopProcess. Getter and setter methods for properties are never required, but if they are used they should be named getFoo (or optionally isFoo or hasFoo for booleans), or setFoo(value) for setters.

Constant names

Constant names use CONSTANT_CASE: all uppercase letters, with words separated by underscores.

JSDoc

JSDoc is used on all classes, fields, functions/methods. The basic formatting of JSDoc blocks is as seen in this example:

/**
 * Multiple lines of JSDoc text are written here,
 * wrapped normally.
 * @param {number} arg A number to do something to.
 * @returns {string} name A name of the compute
 */
function doSomething(arg) { … }

Testing

We use for testing, and require contributors to follow a (TDD) approach where you write test to fail at first and then write the corresponding function to pass the test.

Google Javascript style guide
Mocha
Test Driven Development