Code Style Guidelines (ReactJS/JavaScript)

Component Naming

1. Use PascalCase for component names and their filename.

2. Use a single exported component per file.

Component Structure

1. Prefer functional components over class components.

2. Use React Hooks for state and lifecycle methods.

Variables and Functions

1. Use camelCase for variables and functions.

2. Avoid declaring variables with var. Use let and const instead.

JSX & HTML Attributes

1. Always use double quotes for attributes in JSX.

2. Use curly braces for JavaScript expressions in JSX.

3. Self-close tags without children.

Imports

1. Import libraries first, then components, then styles/assets.

State Management

1. Use useState hook for local state management.

2. For complex state, consider using useReducer or libraries like Redux.

Event Handlers:

1. Use inline arrow functions for event handlers.

Last updated