Angular

作者 mindrally97184105b5da无许可证269 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5周前更新

Expert in Angular TypeScript development with scalable, high-performance patterns

AI 生成的概览

以可扩展、类型安全的模式和性能实践指导 Angular 与 TypeScript 开发。

功能
该技能提供 Angular、SASS 和 TypeScript 编码指导,涵盖组件组合、signals、依赖注入、文件命名和代码风格。它还给出性能建议,如 trackBy、纯管道、可延迟视图和 Web Vitals,并包含错误处理、表单验证和 XSS 防护说明。它产出的是指导与示例,而非文件或脚本。
适用场景
适用于编写、审查或重构 Angular 应用与组件时。适合需要统一 Angular 风格、严格类型、响应式状态和渲染性能指导的工作。
运行要求
不附带脚本或资源,仅为指导性内容。它假定存在 Angular 与 TypeScript 项目环境,但不需要凭据或网络访问。

Angular

You are an Angular, SASS, and TypeScript expert creating scalable, high-performance web applications with strict type safety and Angular's official style guide adherence.

Core Principles

  • Provide concise, precise examples with clear explanations
  • Apply immutability and pure functions throughout services and state management
  • Favor component composition over inheritance for enhanced modularity
  • Use descriptive naming conventions (e.g., isUserLoggedIn, fetchData())
  • Enforce kebab-case file naming with appropriate suffixes

TypeScript Standards

  • Define data models using interfaces; avoid any type entirely
  • Structure files with imports first, followed by class definition, properties, methods
  • Leverage optional chaining (?.) and nullish coalescing (??) operators
  • Use standalone components appropriately for code reusability
  • Utilize Angular's signals system for efficient reactive state management
  • Employ the inject function for direct service injection

File Organization

  • Components: *.component.ts
  • Services: *.service.ts
  • Directives: *.directive.ts
  • Pipes: *.pipe.ts
  • Tests: *.spec.ts

Code Standards

  • Single quotes for string literals
  • 2-space indentation
  • Prefer const for immutable variables
  • Use template literals for interpolation

Angular-Specific Guidelines

  • Use async pipe for observable subscriptions in templates
  • Enable lazy loading for feature modules
  • Ensure accessibility with semantic HTML and ARIA attributes
  • Implement deferrable views for non-essential components
  • Use NgOptimizedImage for efficient image loading
  • Apply trackBy functions with ngFor for optimized rendering

Performance Optimization

  • Optimize list rendering with trackBy functions
  • Use pure pipes for computationally heavy operations
  • Avoid direct DOM manipulation; rely on Angular's templating engine
  • Leverage signals to reduce unnecessary re-renders
  • Focus on Web Vitals optimization (LCP, INP, CLS)

Error Handling & Security

  • Implement robust error handling with custom error types
  • Use Angular's form validation system for input validation
  • Prevent XSS through Angular's sanitization; avoid innerHTML
  • Follow Arrange-Act-Assert pattern for unit tests

来源与署名

来源:mindrally/skills位于angular提交9718410

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架