2.9 KiB
2.9 KiB
AionUI Code Review Style Guide
Overview
This document defines the coding standards and best practices for the AionUI project. The AI code reviewer should use these guidelines when reviewing pull requests.
Technology Stack
- Runtime: Bun
- Framework: Electron + React
- Language: TypeScript (strict mode)
- Styling: Tailwind CSS + Arco Design
- State Management: React hooks + SWR
- i18n: react-i18next (support: en-US, zh-CN, zh-TW, ja-JP, ko-KR)
Code Quality Standards
TypeScript
- Use strict TypeScript configuration
- Avoid
anytype - useunknownor proper generics - Prefer interfaces over type aliases for object shapes
- Use explicit return types for exported functions
- Use optional chaining (
?.) and nullish coalescing (??)
React
- Use functional components with hooks
- Prefer
useMemoanduseCallbackfor expensive computations - Avoid inline functions in JSX when possible
- Use proper dependency arrays in hooks
- Follow React naming conventions (PascalCase for components)
Error Handling
- Always handle Promise rejections
- Use try-catch for async/await
- Provide meaningful error messages
- Log errors appropriately using console.error
Security
- Never commit secrets or API keys
- Validate all user inputs
- Sanitize data before rendering (XSS prevention)
- Use secure IPC communication patterns in Electron
Performance
- Lazy load components when appropriate
- Avoid unnecessary re-renders
- Use proper memoization
- Consider bundle size when adding dependencies
File Organization
src/
├── common/ # Shared utilities and types
├── process/ # Main process code (Electron)
├── renderer/ # Renderer process code (React)
│ ├── components/ # Reusable UI components
│ ├── hooks/ # Custom React hooks
│ ├── pages/ # Page components
│ └── i18n/ # Internationalization
└── agent/ # AI agent related code
Commit Message Convention
Follow Conventional Commits:
feat:- New featurefix:- Bug fixdocs:- Documentationstyle:- Code style (formatting, etc.)refactor:- Code refactoringperf:- Performance improvementtest:- Testschore:- Maintenance tasks
Review Priorities
When reviewing code, prioritize in this order:
- Security - Vulnerabilities, secrets exposure, injection attacks
- Correctness - Logic errors, edge cases, data validation
- Performance - Memory leaks, unnecessary computations
- Maintainability - Code readability, proper abstractions
- Style - Naming conventions, formatting (lowest priority)
Language
- Code comments should be in English or bilingual (English + Chinese)
- Use clear and descriptive variable/function names
- Avoid abbreviations unless widely understood