Syntax Standards

Naming Conventions

Naming variables

  1. Use camelCase for filenames ex: leadActions.js

  2. Use camelCase for naming variables ex: let leadName

  3. Use UPPER_SNAKE_CASE for naming constants.

  4. Use camelCase for naming the props of a component ex: <Lead leadName={name}/>

  5. Do Not Use snake_case anywhere

  6. Use PascalCase for naming classes and components ex: export default class LeadCard

  7. Boolean variables, or functions that return a boolean value, should start with “is,” “has” or “should.”

  8. Use camelCase for naming functions ex: function isFormValid()

Naming Functions

Functions should be named for what they do, not how they do it. In other words, don’t expose details of the implementation in the name. Why? Because how you do it may change someday, and you shouldn’t need to refactor your consuming code because of it. For example, you may load your config from a REST API today, but you may decide to bake it into the JavaScript tomorrow.

Bad

// Dirty
const loadConfigFromServer = () => {
  ...
};

Good

// Clean
const loadConfig = () => {
  ...
};

File Imports

Code Commenting

Last updated