Code Style¶
WebMACS enforces consistent code style across all components.
Python (Backend & Controller)¶
Formatter & Linter: Ruff¶
Ruff handles both formatting and linting:
# pyproject.toml
[tool.ruff]
target-version = "py313"
line-length = 120
[tool.ruff.lint]
select = [
"E", "F", "W", # pycodestyle, pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"S", # bandit (security)
"B", # bugbear
"A", # builtins
"C4", # comprehensions
"DTZ", # datetime timezone
"T20", # print statements
"PT", # pytest style
"SIM", # simplify
"TID", # tidy imports
"TCH", # type checking
"ARG", # unused arguments
"PL", # pylint
"TRY", # tryceratops
"PERF", # performance
"RUF", # ruff-specific
]
ignore = ["S101", "TRY003", "PLR0913"]
Type Checking: mypy¶
Commands¶
just lint # ruff check + format check
just format # ruff format (auto-fix)
just fix # format + lint-fix
TypeScript (Frontend)¶
Linter: ESLint¶
The frontend uses ESLint with Vue and TypeScript rules:
Type Checking: vue-tsc¶
Conventions¶
Python¶
- Imports: Sorted by
isort(via Ruff). First-party packages:webmacs_backend,webmacs_controller - Docstrings: Google style
- Naming:
snake_casefor functions/variables,PascalCasefor classes - Type hints: Required on all public functions (mypy strict mode)
- Async: Use
async deffor all I/O-bound operations
TypeScript¶
- Naming:
camelCasefor variables/functions,PascalCasefor components/types - Composition API:
<script setup lang="ts">for all components - Types: Explicit interfaces in
types/directory - Imports: Absolute paths from
@/alias
Commits¶
Follow Conventional Commits — see Contributing.
Pre-Commit Checks¶
Run before every commit:
Or integrate with git hooks:
Next Steps¶
- Contributing — full development workflow
- Testing — test structure and patterns