Skip to content

Style Guidelines

To maintain consistency in our codebase, we follow these basic style guidelines:

General:

  • Ensure code is well-commented for clarity and maintainability.
  • Use meaningful and descriptive names for variables, functions, and classes.
  • Write unit tests for critical functions and components.
  • Follow the SOLID principles for object-oriented design.
  • Review and adhere to DRY principles (Don’t Repeat Yourself).

JavaScript:

  • Use camelCase for variable and function names (e.g., userName).
  • Use PascalCase for class names (e.g., UserClass).
  • Use consistent indentation (4 spaces).
  • Keep lines under 80 characters.
  • Prefer const and let over var for variable declarations.
  • Use strict equality (===) and inequality (!==) to avoid type coercion issues.
  • Follow the Airbnb JavaScript Style Guide.

Astro:

  • Follow the official Astro style guide.
  • Ensure all components are self-contained and reusable.
  • Use consistent naming conventions for component files and functions.

Python:

  • Use snake_case for variable and function names (e.g., user_name).
  • Use PascalCase for class names (e.g., UserClass).
  • Use consistent indentation (4 spaces).
  • Keep lines under 79 characters.
  • Follow the PEP 8 style guide.
  • Ensure docstrings are provided for all public modules, classes, functions, and methods (PEP 257).
  • Utilize type hints to improve code readability and maintainability.

HTML/CSS:

  • Use lowercase letters and hyphens for class names (e.g., user-name).
  • Use double quotes for attribute values.
  • Keep HTML and CSS code well-formatted and readable.
  • Follow the W3C HTML and CSS guidelines.

Git:

  • Write clear and concise commit messages.
  • Follow the Conventional Commits convention.
  • Regularly pull changes from the main branch to stay up-to-date.
  • Use feature branches for new features and bug fixes.
  • Ensure all tests pass before merging to the main branch.

By adhering to these guidelines, we ensure a clean, consistent, and maintainable codebase across the 2077 Collective projects.