Contributing to Form Builder
Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
- Getting Started
- Development Setup
- Code Style
- Making Changes
- Testing
- Submitting Changes
- Code Review Process
This is a Lit-based web component project. We've recently migrated from React to Lit to reduce bundle size and stay closer to web standards.
- Node.js 20 or higher
- npm 9 or higher
- Git
-
Fork and clone the repository:
git clone https://github.com/yourusername/form-builder.git cd form-builder -
Install dependencies:
npm install
This will automatically set up Git hooks via Husky.
-
Verify your setup:
npm run build npm test npm run serve
If the build succeeds, tests pass, and the dev server starts, you're ready to contribute!
We use automated tooling to maintain consistent code style across the project.
- Prettier handles all code formatting automatically
- Pre-commit hooks will format your code before each commit
- Configuration is in
.prettierrc.json
- 2-space indentation
- Single quotes for strings
- Semicolons required
- 100 character line length
- ES6+ JavaScript features encouraged
- LF (Unix) line endings
- No trailing whitespace
- Single blank line at end of files
If you need to check or format code manually:
# Check formatting (doesn't modify files)
npm run lint:check
# Check ESLint rules
npm run lint
# Auto-fix formatting
npm run format-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes:
- Write clean, readable code
- Follow existing patterns in the codebase
- Add tests for new features
- Update documentation as needed
-
Commit your changes:
git add . git commit -m "Brief description of your changes"
Husky will automatically run lint-staged, which will:
- Format your code with Prettier
- Run ESLint with auto-fix
- Only process files you've staged for commit
-
Keep your branch updated:
git fetch origin git rebase origin/main
We use Web Test Runner for testing our Lit components.
# Run all tests with coverage
npm test
# Run tests in watch mode (great for TDD)
npm run test:watch
# Run tests for CI
npm run test:ci- Place test files next to the code they test with
.test.jsextension - Use descriptive test names that explain what is being tested
- Test user interactions, not implementation details
- Aim for high coverage of critical paths
Example test structure:
import { fixture, html, expect } from '@open-wc/testing';
import './your-component.js';
describe('YourComponent', () => {
it('renders with default properties', async () => {
const el = await fixture(html`<your-component></your-component>`);
expect(el.shadowRoot.querySelector('.container')).to.exist;
});
it('handles user interaction', async () => {
const el = await fixture(html`<your-component></your-component>`);
const button = el.shadowRoot.querySelector('button');
button.click();
await el.updateComplete;
// Assert expected behavior
});
});-
Push your branch:
git push origin feature/your-feature-name
-
Create a Pull Request:
- Go to the repository on GitHub
- Click "New Pull Request"
- Select your feature branch
- Fill out the PR template with:
- Clear description of changes
- Link to related issues
- Screenshots (if UI changes)
- Testing performed
-
Wait for CI checks:
- GitHub Actions will automatically run tests and checks
- All checks must pass before merging
- Fix any issues reported by CI
-
Automated Checks:
- Prettier formatting validation
- Test suite execution
- Build verification
- Bundle size check
-
Human Review:
- At least one maintainer will review your PR
- Respond to feedback constructively
- Make requested changes in new commits
- Mark conversations as resolved once addressed
-
Merging:
- PRs are squash-merged to keep history clean
- Your commits will be combined into one
- Write a clear commit message summarizing all changes
- Found a bug? Open an issue with steps to reproduce
- Have a question? Check existing issues or open a new one
- Want to propose a feature? Open an issue for discussion first
- Git hooks (Husky): Catches issues locally before they reach CI
- Automated formatting (lint-staged): Only processes changed files for speed
- Testing requirements: Ensures reliability and prevents regressions
- Code review: Maintains quality and shares knowledge
Thank you for contributing! Your efforts help make this project better for everyone.