LeagueSphere maintains high-quality standards across its polyglot codebase (Python, TypeScript, HTML/CSS).
- Separation of Concerns: Business logic should reside in Django
service/modules or Reacthooks/. - DRY (Don't Repeat Yourself): Shared utilities are centralized in
league_manager/utils/(backend) orsrc/lib/(frontend). - SOLID: Aim for single-responsibility components and classes.
- Version: Django 5.2+; Python 3.12+.
- Formatting: Strictly follow
black .for formatting. - Typing: Use type hints where practical to improve code clarity and IDE support.
- REST APIs: Use Django REST Framework (DRF) with explicit serializers for all external endpoints.
- Tests: Every new feature requires a
pytestsuite in the app'stests/directory.
- Framework: Vite-based applications.
- State Management: Prefer React Context for new state or Redux if established in a legacy component.
- Styling: Standard Vanilla CSS is preferred for all new components to maintain platform-native feel and flexibility.
- Typing: No
any. Use interfaces and types for all props, states, and API responses. If necessary to work around type constraints, use proper type syntax likeReturnType<typeof someFunction>instead ofas any. - Tests: Use
vitestfor all frontend unit and integration tests. - Linting: All TypeScript/JavaScript code MUST pass ESLint checks before committing. See "Linting Standards" below.
All frontend code MUST pass ESLint before committing. Run before pushing:
npm run eslintCritical Rules Enforced:
-
@typescript-eslint/no-explicit-any: Never useas anytype assertions. Replace with proper types:- β BAD:
mockApi.mockResolvedValue({} as any) - β
GOOD:
mockApi.mockResolvedValue({} as ReturnType<typeof api>) - β
GOOD: Type the object explicitly:
mockApi.mockResolvedValue<ApiResponse>({...})
- β BAD:
-
@typescript-eslint/no-unused-vars: Remove unused imports and variables. -
Deprecation Warnings: Replace deprecated methods:
- β BAD:
.substr(2, 9)(deprecated) - β
GOOD:
.slice(2, 11)(current standard)
- β BAD:
Random Number Generation:
- β BAD:
Math.random()for security-sensitive values (sessions, tokens, IDs) - β
GOOD:
crypto.getRandomValues()for cryptographically secure randomness
# Check for lint errors
npm run eslint
# Format code (if available)
npm run prettier- Use consistent spacing (multiples of 4px/8px).
- Interactive elements must provide visual feedback (hover, active states).
- All new features must be mobile-responsive by default.
- Never Log Secrets: RIGOROUSLY avoid logging or printing API keys, passwords, or tokens.
- Input Validation: All data from the client MUST be validated in the backend, even if already checked in the frontend.
- Token Handling: Use Knox tokens for API authentication; ensure they are handled securely in frontend storage.