Thank you for considering contributing to our UI Library! This guide will help you understand our development process, standards, and workflows.
- Node.js (v20 or higher)
- yarn (v3 or higher)
- Git
- A code editor with TypeScript support (we recommend WebStorm or VSCode)
- Fork & Clone
git clone https://github.com/KhaledSMQ/avati
cd avati
- Install Dependencies
yarn install
- VSCode Setup Install recommended extensions:
- ESLint
- Prettier
- TypeScript and TSLint
- Jest Runner
avati/
├── packages/ # Package directory
├── scripts/ # Build and maintenance scripts
├── docs/ # Documentation
└── package.json # Root package.json
- Start Development Server
yarn run dev
- Watch Mode with Type Checking
yarn run dev:types
- Testing During Development
yarn run test
When creating a new package:
- Create Package Structure
yarn run create-package package-name
- Package Requirements
README.md
with:- Package description
- Installation instructions
- Usage examples
- API documentation
CHANGELOG.md
package.json
with proper metadata- TypeScript configuration
- Test setup
# Full build
npm run build
# Test single package
npm run test --workspace=@avati/package-name
# Test coverage
npm run test:coverage
# Lint code
npm run lint
# Format code
npm run format
- Type Safety
// ✅ Good
interface ButtonProps {
variant: 'primary' | 'secondary';
onClick: (event: React.MouseEvent) => void;
}
// ❌ Bad
interface ButtonProps {
variant: string;
onClick: any;
}
- Use TypeScript Features
// ✅ Good
type Theme = 'light' | 'dark';
type Size = 'sm' | 'md' | 'lg';
// ❌ Bad
const theme: string = 'light';
- Documentation
/**
* Button component props
* @property {string} variant - Button style variant
* @property {() => void} onClick - Click handler
*/
interface ButtonProps {
variant: 'primary' | 'secondary';
onClick: () => void;
}
- Functional Components
// ✅ Good
const Button = ({ variant, children }: ButtonProps) => {
return <button className={`btn-${variant}`}>{children}</button>;
};
// ❌ Bad
class Button extends React.Component {}
- Props Interface
// ✅ Good
interface Props {
required: string;
optional?: number;
}
// ❌ Bad
const Component = (props: any) => {};
- Default Props
// ✅ Good
const Button = ({ variant = 'primary' }: ButtonProps) => {};
// ❌ Bad
Button.defaultProps = {
variant: 'primary',
};
- Test Coverage Requirements
- Minimum 80% coverage for new code
- 100% coverage for utilities and hooks
- Test Structure
describe('Component', () => {
describe('rendering', () => {
it('renders default state correctly', () => {});
it('renders with custom props', () => {});
});
describe('behavior', () => {
it('handles click events', () => {});
it('updates state correctly', () => {});
});
});
- Test Best Practices
- Test component behavior, not implementation
- Use meaningful test descriptions
- Group related tests
- Mock external dependencies
main
└── develop
├── feature/scope-description
├── fix/scope-description
└── docs/scope-description
- Commit Types
feat
: New featurefix
: Bug fixdocs
: Documentationstyle
: Code stylerefactor
: Code refactoringperf
: Performancetest
: Testingchore
: Maintenance
- Commit Format
type(scope): subject
body
footer
- Examples
feat(signal): add size variants
- Add small, medium, and large sizes
- Update documentation
- Add tests for new variants
BREAKING CHANGE: Changed size prop type
- PR Title Format
type(scope): description
Example:
feat(button): add new variants
- PR Description Template
## Description
[Detailed description of changes]
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] Types updated
- [ ] Changelogs updated
- [ ] All checks passing
## Screenshots/Videos
[If applicable]
## Additional Notes
[Any additional information]
- Prepare Release
npm run version-packages
- Review Changes
- Review changelogs
- Check documentation
- Verify tests
- Publish
npm run publish-packages
- Build Failures
npm run clean
npm install
npm run build
- Test Failures
npm run test:debug
- Type Errors
npm run type-check
- Search existing issues
- Check troubleshooting guide
- Create a new issue with:
- Environment details
- Steps to reproduce
- Expected vs actual behavior
By following these guidelines, you help maintain the quality and consistency of our codebase. Thank you for contributing!