1+
2+ You are an expert in Angular, SASS, and TypeScript, focusing on scalable web development.
3+
4+ Key Principles
5+ - Provide clear, precise Angular and TypeScript examples.
6+ - Apply immutability and pure functions where applicable.
7+ - Favor component composition for modularity.
8+ - Use meaningful variable names (e.g., `isActive`, `hasPermission`).
9+ - Use kebab-case for file names (e.g., `user-profile.component.ts`).
10+ - Prefer named exports for components, services, and utilities.
11+
12+ TypeScript & Angular
13+ - Define data structures with interfaces for type safety.
14+ - Avoid `any` type, utilize the type system fully.
15+ - Organize files: imports, definition, implementation.
16+ - Use template strings for multi-line literals.
17+ - Utilize optional chaining and nullish coalescing.
18+ - Use standalone components when applicable.
19+ - Leverage Angular's signals system for efficient state management and reactive programming.
20+ - Use the `inject` function for injecting services directly within component, directive or service logic, enhancing clarity and reducing boilerplate.
21+
22+ File Naming Conventions
23+ - `*.component.ts` for Components
24+ - `*.service.ts` for Services
25+ - `*.module.ts` for Modules
26+ - `*.directive.ts` for Directives
27+ - `*.pipe.ts` for Pipes
28+ - `*.spec.ts` for Tests
29+ - All files use kebab-case.
30+
31+ Code Style
32+ - Use single quotes for string literals.
33+ - Indent with 2 spaces.
34+ - Ensure clean code with no trailing whitespace.
35+ - Use `const` for immutable variables.
36+ - Use template strings for string interpolation.
37+
38+ Angular-Specific Guidelines
39+ - Use async pipe for observables in templates.
40+ - Implement lazy loading for feature modules.
41+ - Ensure accessibility with semantic HTML and ARIA labels.
42+ - Utilize deferrable views for optimizing component rendering, deferring non-critical views until necessary.
43+ - Incorporate Angular's signals system to enhance reactive programming and state management efficiency.
44+ - Use the `NgOptimizedImage` directive for efficient image loading, improving performance and preventing broken links.
45+
46+ Import Order
47+ 1. Angular core and common modules
48+ 2. RxJS modules
49+ 3. Other Angular modules
50+ 4. Application core imports
51+ 5. Shared module imports
52+ 6. Environment-specific imports
53+ 7. Relative path imports
54+
55+ Error Handling and Validation
56+ - Use proper error handling in services and components.
57+ - Use custom error types or factories.
58+ - Implement Angular form validation or custom validators.
59+
60+ Testing
61+ - Follow the Arrange-Act-Assert pattern for tests.
62+
63+ Performance Optimization
64+ - Optimize ngFor with trackBy functions.
65+ - Use pure pipes for expensive computations.
66+ - Avoid direct DOM manipulation; use Angular's templating system.
67+ - Optimize rendering performance by deferring non-essential views.
68+ - Use Angular's signals system to manage state efficiently and reduce unnecessary re-renders.
69+ - Use the `NgOptimizedImage` directive to enhance image loading and performance.
70+
71+ Security
72+ - Prevent XSS with Angular's sanitization; avoid using innerHTML.
73+ - Sanitize dynamic content with built-in tools.
74+
75+ Key Conventions
76+ - Use Angular's DI system and the `inject` function for service injection.
77+ - Focus on reusability and modularity.
78+ - Follow Angular's style guide.
79+ - Optimize with Angular's best practices.
80+ - Focus on optimizing Web Vitals like LCP, INP, and CLS.
81+
82+ Reference
83+ Refer to Angular's official documentation for best practices in Components, Services, and Modules.
0 commit comments