General Principles
Ensure you check your code changes before committing and raising a PR. While ESLint handles most formatting, always review your diffs.Style Rules
Indentation and Spacing
Use 2 spaces for indentation. No tabs, just spaces – keeps everything neat and uniform.
Quotes and Semicolons
- Stick to single quotes for strings in JavaScript
- Use double quotes for JSX/TSX attributes (React convention)
- Always add semicolons at the end of statements
Arrow Functions
Always use parentheses around parameters in arrow functions, even for single params. Consistency is key.
Braces and Line Breaks
- Put opening braces on the same line
- Minimum 2 elements for multiline constructs
- No newlines inside function parentheses
- Space before and after the arrow:
() => {} - No space between function name and parentheses:
func()notfunc ()
Trailing Commas
No trailing commas. Keep it clean, no extra commas hanging around.
React Guidelines
Hook Imports
Custom Hooks for Logic
- MUST: Prefer custom hooks for business logic, data fetching, and side-effects
- MUST: Avoid
useEffectunless absolutely needed. Prefer derived state and event handlers - SHOULD: Memoize only when necessary (
useMemo/useCallback), prefer moving logic into hooks first
Styled Components vs Tailwind
- Use styled component’s theme prop for CSS colors, not CSS variables
- Styled Components define both self and children component styles
- Tailwind classes are used specifically for layout-based styles
- Styled Component CSS might also change layout, but Tailwind classes shouldn’t define colors
Testing Attributes
Add
data-testid to testable elements for Playwright E2E tests.Component Organization
- Co-locate utilities that are truly component-specific next to the component
- Place shared items under a common folder
- Keep components focused and single-purpose
Testing Standards
Test Philosophy
Behavior-Driven
Test real expected output and observable behavior, not internal implementation
High-Value Focus
Prioritize critical, complex, or likely-to-break behavior over coverage numbers
Minimize Mocking
Use real flows where practical; mock only external services or non-deterministic behavior
Readable Tests
Optimize for clarity over cleverness with descriptive names and minimal setup
Test Requirements
Add Tests for Changes
Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created.
Cover Key Paths
Cover both the “happy path” and realistically problematic paths. Validate expected success behavior and error handling.
Ensure Determinism
Ensure tests are deterministic and reproducible. No randomness, timing dependencies, or environment-specific assumptions without explicit control.
Test Examples
- Write behavior-driven tests, not implementation-driven ones
- Minimize mocking unless it meaningfully increases clarity
- Keep tests readable and maintainable
- Avoid overfitting tests to current behavior
- Use consistent patterns and helper utilities
- Tests should be fast enough to run continuously
Code Quality
Readability and Abstractions
- Function names need to be concise and descriptive
- Add JSDoc comments to add more details to abstractions if needed
- Follow functional programming but just enough to be readable
- Avoid single line abstractions where all that’s being done is increasing the call stack
- Add meaningful comments instead of obvious ones where complex code flow needs explanation
Comments
Add meaningful comments that explain why, not what. The code already shows what it does.
Linting
Bruno uses ESLint with custom configuration:Pre-commit Hooks
The project uses Husky and nano-staged to run linting on staged files:Code Review Checklist
Before submitting a PR, ensure:- Code follows style guidelines (2 spaces, single quotes, semicolons)
- React hooks are imported directly, not via namespace
- Custom hooks used for business logic and side effects
- Styled components for colors, Tailwind for layout
- Tests added for new functionality
- Tests are behavior-driven, not implementation-driven
- No unnecessary abstractions or single-line wrappers
- Function names are clear and descriptive
- Comments explain “why”, not “what”
-
data-testidadded to testable UI elements - No trailing commas
- No unnecessary whitespace changes
- ESLint passes without errors
Enforcement
These standards are enforced through:- ESLint: Automated linting catches most issues
- Pre-commit hooks: Husky runs lint:fix before commits
- CI/CD: GitHub Actions runs tests and linting
- Code review: Maintainers review for adherence
Questions?
If something doesn’t fit perfectly or you’re unsure about a guideline:- Ask in the PR comments
- Open a discussion on GitHub
- Join our Discord community