Overview
This project follows strict code style guidelines to maintain consistency and readability. We use automated tools to enforce these standards.Prettier Configuration
The project uses Prettier for automatic code formatting with the following configuration:Key Settings
- Print Width: 100 characters per line
- Quotes: Single quotes for JavaScript/TypeScript
- HTML Parser: Angular-specific HTML parsing
TypeScript Style
Strict Mode
The project uses TypeScript strict mode with additional checks:Type Annotations
Always provide explicit types:Interfaces vs Types
Prefer interfaces for object shapes:Angular Style
Component Structure
Follow Angular’s style guide for component organization:Naming Conventions
Files
- Components:
user-card.component.ts - Services:
user.service.ts - Pipes:
format-date.pipe.ts - Directives:
highlight.directive.ts - Guards:
auth.guard.ts - Interceptors:
auth.interceptor.ts
Classes and Interfaces
Variables and Functions
Template Style
One-Way Binding
Structural Directives
Template Formatting
Keep templates clean and readable:CSS/SCSS Style
Component Styles
Use component-scoped styles:BEM Naming
Consider using BEM (Block Element Modifier) for class names:Import Organization
Organize imports in this order:Comments and Documentation
JSDoc Comments
Document public APIs:Inline Comments
Use sparingly for complex logic:Avoid Obvious Comments
RxJS Style
Observable Naming
Suffix observables with$:
Operator Formatting
Unsubscribe Pattern
UsetakeUntilDestroyed() for automatic cleanup:
Testing Style
Test Structure
Descriptive Test Names
Formatting Commands
While Prettier is configured, you can manually format files:Linting
The project uses TypeScript’s strict compiler checks as linting. Run type checking:Best Practices Summary
- Use Prettier: Let it handle formatting automatically
- Enable Strict Mode: Catch errors at compile time
- Type Everything: Explicit types improve maintainability
- Follow Angular Style Guide: Use official conventions
- Write Tests: Maintain high test coverage
- Document Public APIs: Use JSDoc for public methods
- Keep It Simple: Write clear, readable code
- Use Standalone Components: Modern Angular architecture
Next Steps
- Review Contributing Guidelines
- Learn about Testing
- Explore Development Setup