Spaces:
Paused
Contributing to WidgetBoard
Thank you for your interest in contributing to WidgetBoard! This document provides guidelines and instructions for contributing to the project.
Code of Conduct
We are committed to providing a welcoming and inclusive environment. Please be respectful and professional in all interactions.
Code Style Guidelines
EMOJIS ARE STRICTLY FORBIDDEN in all code, comments, documentation, and commit messages. Never use emojis anywhere in the codebase.
Getting Started
Prerequisites
- Node.js 18+ or 20+
- npm 9+
- Git
- Familiarity with React, TypeScript, and modern web development
Setup Development Environment
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/WidgeTDC.git cd WidgeTDC - Add upstream remote:
git remote add upstream https://github.com/Clauskraft/WidgeTDC.git - Install dependencies:
npm install --legacy-peer-deps - Copy environment template:
cp .env.example .env.local - Start development server:
npm run dev
Development Workflow
Branch Naming Convention
feature/description- New featuresfix/description- Bug fixesdocs/description- Documentation updatesrefactor/description- Code refactoringtest/description- Test additions or modificationssecurity/description- Security fixes
Making Changes
Create a new branch:
git checkout -b feature/your-feature-nameMake your changes following our coding standards
Write or update tests:
npm testRun linter:
npm run lintFormat your code:
npm run formatCommit your changes:
git commit -m "feat: add amazing feature"
Commit Message Convention
We follow the Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Test additions or modificationschore: Build process or tooling changessecurity: Security improvements
Examples:
feat(widgets): add email RAG widget
fix(security): prevent XSS in input fields
docs(readme): update installation instructions
test(utils): add security utility tests
Coding Standards
TypeScript
- Use TypeScript for all new code
- Define types for all function parameters and return values
- Avoid
anytype unless absolutely necessary - Use interfaces for object shapes
- Use enums for fixed sets of values
React
- Use functional components with hooks
- Keep components small and focused (< 300 lines)
- Extract complex logic into custom hooks
- Use memo/useMemo/useCallback for performance optimization
- Implement error boundaries for widget isolation
Security
- Sanitize all user input
- Validate all external data
- Use parameterized queries
- Implement rate limiting
- Follow OWASP guidelines
- Never commit secrets or API keys
Testing
- Write tests for all new features
- Maintain minimum 70% code coverage
- Test both happy paths and error cases
- Use descriptive test names
- Mock external dependencies
Code Style
- Use Prettier for formatting
- Follow ESLint rules
- Use meaningful variable names
- Add comments for complex logic
- Keep functions small (< 50 lines)
- Maximum line length: 100 characters
Testing
Running Tests
# Run all tests
npm test
# Run specific test file
npm test -- security.test.ts
# Run with coverage
npm run test:coverage
# Run in watch mode
npm run test
Writing Tests
import { describe, it, expect } from 'vitest';
import { sanitizeInput } from './security';
describe('sanitizeInput', () => {
it('should remove XSS attempts', () => {
const input = '<script>alert("xss")</script>';
const result = sanitizeInput(input);
expect(result).not.toContain('<script>');
});
});
Pull Request Process
Before Submitting
- Tests pass:
npm test - Linter passes:
npm run lint - Code formatted:
npm run format - Build succeeds:
npm run build - Documentation updated (if needed)
- Changelog updated (for significant changes)
Submitting PR
Push your branch to your fork:
git push origin feature/your-feature-nameOpen a Pull Request on GitHub
Fill out the PR template completely
Link related issues
Request review from maintainers
PR Template
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing completed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings
- [ ] Tests pass locally
Review Process
- At least one approval required
- All checks must pass
- No unresolved conversations
- Branch up to date with main
- Squash and merge preferred
Documentation
Code Documentation
- Add JSDoc comments for functions:
/** * Sanitize user input to prevent XSS attacks * @param input - Raw user input string * @returns Sanitized string safe for display */ export function sanitizeInput(input: string): string { // Implementation }
Architecture Decisions
Document significant architectural decisions in docs/ADR/:
# ADR-001: Use Circuit Breaker Pattern
## Status
Accepted
## Context
Need fault tolerance for external service calls
## Decision
Implement circuit breaker pattern in MCP client
## Consequences
- Improved resilience
- Faster failure detection
- Additional complexity
Security Guidelines
Security-First Mindset
- Assume all input is malicious
- Validate on server and client
- Use allowlists over denylists
- Fail securely
- Log security events
Common Vulnerabilities to Avoid
XSS (Cross-Site Scripting)
- Sanitize all user input
- Use Content Security Policy
- Escape HTML entities
SQL Injection
- Use parameterized queries
- Validate input types
- Implement least privilege
CSRF (Cross-Site Request Forgery)
- Use CSRF tokens
- Validate origin headers
- SameSite cookies
Authentication Issues
- Use strong passwords
- Implement MFA
- Secure session management
Reporting Security Vulnerabilities
DO NOT open public issues for security vulnerabilities.
Email: security@widgetboard.example.com
Include:
- Description of vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (optional)
Performance Guidelines
Optimization Techniques
- Lazy load components
- Implement code splitting
- Use React.memo for expensive components
- Debounce user input
- Throttle scroll/resize handlers
- Optimize images and assets
Performance Testing
import { logger } from './utils/logger';
const endTimer = logger.startTimer('Operation Name');
// ... your code ...
endTimer(); // Logs: Performance: Operation Name { duration: "12.34ms" }
Getting Help
Resources
Communication Channels
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: Questions and general discussion
- Email: dev@widgetboard.example.com
Recognition
Contributors will be recognized in:
- README.md acknowledgments section
- Release notes
- GitHub contributors page
Thank you for contributing to WidgetBoard!