Addressing Code Formatting Challenges in Remote Development Teams

Establish practices to ensure consistent code formatting among distributed development teams.

0 likes
8 views

Rule Content

---
description: Enforce consistent code formatting across all files to maintain readability and uniformity in distributed development teams.
globs: ['**/*.{js,jsx,ts,tsx,py,java,cs,cpp,html,css,scss}']
tags: [code-formatting, remote-teams, consistency]
priority: 1
version: 1.0.0
---

# Addressing Code Formatting Challenges in Remote Development Teams

## Context
- Applicable to all source code files in the project.
- Ensures uniform code style across distributed teams to enhance collaboration and maintainability.

## Requirements
- **Indentation**: Use 2 spaces for indentation in JavaScript, TypeScript, HTML, CSS, and SCSS files; use 4 spaces in Python, Java, C#, and C++ files.
- **Line Length**: Limit lines to 80 characters to improve readability.
- **Trailing Whitespace**: Remove trailing whitespace in all lines.
- **EOL Characters**: Use LF (Line Feed) as the end-of-line character.
- **File Encoding**: Save files with UTF-8 encoding.
- **Naming Conventions**:
  - Variables and functions: camelCase (e.g., `userName`)
  - Classes: PascalCase (e.g., `UserProfile`)
  - Constants: UPPER_SNAKE_CASE (e.g., `MAX_COUNT`)
  - Files: kebab-case (e.g., `user-profile.js`)
- **Braces**: Use K&R style for brace placement in all languages.
- **Semicolons**: Always use semicolons in JavaScript and TypeScript.
- **Quotes**: Use single quotes for strings in JavaScript, TypeScript, and Python; double quotes in HTML and CSS.
- **Commenting**:
  - Provide meaningful comments that explain the 'why' behind complex logic.
  - Use JSDoc-style comments for functions and classes in JavaScript and TypeScript.
  - Use docstrings in Python.
- **File Organization**:
  - Group related files together in appropriately named directories.
  - Maintain a consistent directory structure across the project.

## Examples

<example>
// Good: Consistent indentation, naming, and brace placement
function fetchUserData(userId) {
  if (!userId) {
    throw new Error('User ID is required');
  }
  // Fetch user data logic here
}
</example>

<example type="invalid">
// Bad: Inconsistent indentation and missing semicolon
function fetchuserdata(userid)
{
    if (!userid)
    {
        throw new Error("User ID is required")
    }
    // Fetch user data logic here
}
</example>