Syntax Standards
Naming Conventions
Naming variables
Use
camelCasefor filenames ex:leadActions.jsUse
camelCasefor naming variables ex:let leadNameUse
UPPER_SNAKE_CASEfor naming constants.Use
camelCasefor naming the props of a component ex:<Lead leadName={name}/>Do Not Use snake_case anywhere
Use
PascalCasefor naming classes and components ex:export default class LeadCardBoolean variables, or functions that return a boolean value, should start with “is,” “has” or “should.”
Use
camelCasefor 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
Was this helpful?