Clear guidelines for maintaining code quality and consistency
All code must be formatted using our automated tools before commit. Install required extensions now to enable auto-formatting on save.
๐ง Required Setup:
๐ Key Standards:
๐ก Quick Setup:
npm run lint
to verifyUse clear, descriptive names that explain purpose. Variables should be nouns, functions should be verbs. No abbreviations except for common terms.
โ Naming Conventions:
๐ Examples:
// Good
const userData = fetchUserData();
const isActive = true;
function calculateTotal() {}
// Avoid
const data = fetchData();
const flag = true;
function calc() {}
๐ซ Never use:
Components should be small, focused, and follow our standard structure. Use functional components with hooks by default.
๐ Component Structure:
// imports ordered by: react, libs, components, hooks, utils
import React from 'react';
import { useQuery } from '@tanstack/react-query';
interface Props {
// required props first
userId: string;
// optional props last
className?: string;
}
export function UserProfile({ userId, className }: Props) {
// hooks first
const { data } = useQuery(...);
// handlers next
const handleClick = () => {...};
// render helpers last
const renderItems = () => {...};
return (...);
}
๐ฏ Guidelines:
We use trunk-based development with short-lived feature branches. All changes require PR review before merging to main.
๐ณ Branch Naming:
๐ Commit Messages:
type(scope): concise description
- Detailed bullet points
- Breaking changes noted
๐ Workflow Steps:
PRs should be focused, well-documented, and easy to review. Keep changes small and related to a single concern.
๐ PR Requirements:
โ PR Template:
## Changes
- Added X feature
- Fixed Y bug
## Testing
1. Step-by-step guide
2. Expected results
## Screenshots
[If applicable]
๐ก Best Practices:
Resolve conflicts locally before pushing updates. Keep main branch clean and deployable at all times.
๐ Conflict Resolution:
โ ๏ธ Never force push to:
๐ก Prevention Tips:
All new code requires tests. Coverage minimum is 80%, with critical paths at 100%. Tests must be meaningful, not just for coverage.
โ Required Tests:
๐ Test Structure:
describe('ComponentName', () => {
it('should handle primary use case', () => {
// Arrange
// Act
// Assert
});
});
๐ฏ Coverage Rules:
Test files mirror source structure with .test.ts extension. Group related tests using describe blocks, use clear test names.
๐ Test Organization:
describe('UserProfile', () => {
describe('with valid data', () => {
it('displays user info')
it('shows edit button')
});
describe('with errors', () => {
it('shows error message')
it('retries on button click')
});
});
๐งช Naming Convention:
Mock external dependencies and network calls. Keep component tests focused on component logic, not implementation details.
๐ญ Mocking Guidelines:
๐ Mock Examples:
jest.mock('api', () => ({
fetchUser: jest.fn(),
updateUser: jest.fn(),
}));
// Test file
beforeEach(() => {
fetchUser.mockResolvedValue(mockUser);
});
โ ๏ธ Don't Mock:
All pages must meet Core Web Vitals thresholds. Run performance checks locally before PR submission.
๐ Performance Targets:
๐ Check Points: