This document defines the code formatting standards for our organization. It applies to all repositories unless otherwise specified. Consistent formatting improves readability, reduces cognitive load, and makes collaboration easier.
- Indentation: 4 spaces (no tabs)
- Line Length: 100 characters max
- Naming Convention:
camelCasefor variables, functions, and methods - Braces: K&R style (opening brace on the same line)
- Trailing Commas: Yes, where supported
- Quotes: Prefer double quotes (
") unless single quotes are required
- Use Prettier for formatting
- Use ESLint for linting
- Enforce
camelCasefor variables and functions - Use
constandlet(avoidvar) - Prefer arrow functions for anonymous functions
- Use semicolons
Example:
function getUserName(userId) {
if (!userId) {
return null;
}
return userService.getName(userId);
}- Use Black for formatting
- Use Flake8 or pylint for linting
- 4-space indentation
camelCasefor variables and functions (note: this deviates from PEP 8)- Use docstrings for all public functions and classes
Example:
def getUserName(userId):
if not userId:
return None
return user_service.get_name(userId)- Use RuboCop for formatting and linting
- 4-space indentation
camelCasefor method and variable names- Prefer
do...endfor multi-line blocks
Example:
def getUserName(userId)
return nil unless userId
user_service.get_name(userId)
end- Use Prettier for formatting
- 4-space indentation
- Use lowercase for tag and attribute names
- Use double quotes for attribute values
- Use
kebab-casefor class names
Example (HTML):
<div class="user-profile">
<h1 class="user-name">John Doe</h1>
</div>Example (CSS):
.user-profile {
margin-top: 20px;
font-size: 16px;
}- Use sqlfluff for linting and formatting
- Uppercase for SQL keywords
- Indent nested queries with 4 spaces
- Align
JOINandWHEREclauses for readability
Example:
SELECT user_id, user_name
FROM users
WHERE is_active = TRUE
ORDER BY created_at DESC;We recommend setting up formatters and linters to run automatically:
- Use Prettier and ESLint with your editor or as pre-commit hooks
- Use RuboCop via CLI or editor integration
- Use Black and Flake8 for Python
- Use sqlfluff for SQL formatting
All repositories should include formatting checks in CI pipelines.
This ensures consistency and prevents formatting issues from being merged.
- This guide may evolve as we add more languages or tools.
- If you need to propose a change, open a pull request to this document.