Code Conventions - mostpros1/repository GitHub Wiki

Code Conventions for Mostpros

Introduction

Code conventions are essential for maintaining a consistent and readable codebase in any software project. This wiki outlines the conventions to be followed up in Mostpros. The primary focus is on organizing folder structure, with an emphasis on lowercase folder names and uppercase JavaScript file names.

Folder Structure

The project follows a standardized folder structure to enhance organization and maintainability. Key conventions include:

Lowercase Folders: All folder names within the project should be in lowercase. This applies to both top-level and nested folders. The folders housing React components are the only exception to that rule.

Example:

  • src/
    • public/
    • components/
      • Foo/
    • pages/
      • Bar/

File Naming

In addition to the folder structure, conventions are also put in place for file names, especially for TypeScript files:

TypeScript files containing React components should have uppercase file names. This convention improves visibility and distinguishes these files from other types of files. CSS files' names should be lowercase, unless they belong to a React component. In those cases, the CSS and TypeScript files should share a name exactly with the only thing differentiating them being the file extension.

Example:

(at this moment of writing we have not established how we split up things like homepage etc)

  • src/
    • components/
      • Foo/
        • Foo.tsx
        • Foo.css

Naming Conventions

Descriptive and consistent naming is crucial for code readability. Follow these guidelines:

  • Descriptive Component Names: When naming React components, use clear and descriptive names that reflect their purpose or functionality.

Example:

// Good
const Header = () => {
  // component logic
};

// Avoid
const TopOfPage = () => {
  // unclear component logic
}; 

Conclusion

Adhering to these code conventions ensures a standardized and readable codebase, facilitating collaboration and maintenance in the long run. Developers are encouraged to follow these guidelines consistently throughout the project.

Remember, code conventions are meant to be guidelines, and it's essential to maintain flexibility based on project-specific needs.