Skip to content

Latest commit

Β 

History

History
executable file
Β·
362 lines (267 loc) Β· 7.98 KB

CONTRIBUTING.md

File metadata and controls

executable file
Β·
362 lines (267 loc) Β· 7.98 KB

Contributing to Expressive Tea Packages

Thank you for your interest in contributing to Expressive Tea! πŸŽ‰

This document provides guidelines for contributing to the @expressive-tea/commons and @expressive-tea/plugin packages.

πŸ“‹ Table of Contents

Code of Conduct

This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to support@expressive-tea.io.

Getting Started

Prerequisites

  • Node.js >= 18.0.0
  • Yarn 4.11.0 (package manager)
  • Git for version control
  • TypeScript >= 5.0.0 knowledge

Find an Issue

  1. Browse existing issues
  2. Look for good-first-issue or help-wanted labels
  3. Comment on the issue to let others know you're working on it

Ask Questions

Development Setup

1. Fork and Clone

# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/expresive-tea.git
cd expresive-tea/packages

2. Install Dependencies

# Enable Corepack (for Yarn 4)
corepack enable

# Install dependencies
yarn install

3. Build Packages

# Clean and build all packages
yarn clean && yarn build

4. Run Tests

# Run all tests
yarn test

# Run tests in watch mode
yarn test:watch

# Run tests with coverage
yarn test

5. Verify Setup

# Lint code
yarn lint

# Type check
npx tsc --noEmit -p packages/commons
npx tsc --noEmit -p packages/plugin

Making Changes

Create a Branch

# Create a new branch from master
git checkout -b feature/my-new-feature
# or
git checkout -b fix/my-bug-fix

Branch naming conventions:

  • feature/ - New features
  • fix/ - Bug fixes
  • docs/ - Documentation updates
  • refactor/ - Code refactoring
  • test/ - Test updates
  • chore/ - Build/tooling changes

Make Your Changes

  1. Write code following our coding standards
  2. Add tests for new functionality
  3. Update documentation (JSDoc, README, etc.)
  4. Run tests to ensure everything works
  5. Lint your code to catch style issues

Commit Messages

Follow Conventional Commits:

<type>(<scope>): <subject>

<body>

<footer>

Types:

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation changes
  • style: - Code style changes (formatting)
  • refactor: - Code refactoring
  • test: - Test updates
  • chore: - Build/tooling changes

Examples:

feat(plugin): add support for async stage methods

Added ability to use async/await in @Stage decorated methods.
This allows plugins to perform asynchronous operations during
boot stages.

Closes #123
fix(commons): resolve metadata memory leak in WeakMap

Fixed issue where metadata storage was not properly garbage
collected due to strong references.

Fixes #456

Testing

Writing Tests

  • Place tests in packages/*/src/__test__/unit/ directory
  • Name test files as *.spec.ts
  • Follow existing test patterns
  • Aim for >90% code coverage

Example test:

import { Metadata } from '../../classes/Metadata';

describe('Metadata', () => {
  describe('set and get', () => {
    it('should store and retrieve metadata', () => {
      class TestClass {}
      Metadata.set('test-key', 'test-value', TestClass);
      const result = Metadata.get('test-key', TestClass);
      expect(result).toBe('test-value');
    });
  });
});

Running Tests

# Run all tests
yarn test

# Run specific package tests
cd packages/commons && yarn test
cd packages/plugin && yarn test

# Run specific test file
npx jest packages/commons/src/__test__/unit/metadata.spec.ts

# Run with coverage
yarn test --coverage

Submitting Changes

Before Submitting

Ensure your changes pass all checks:

# 1. Clean and build
yarn clean && yarn build

# 2. Run linter
yarn lint

# 3. Run all tests
yarn test

# 4. Type check
npx tsc --noEmit -p packages/commons
npx tsc --noEmit -p packages/plugin

Create a Pull Request

  1. Push your branch to your fork

    git push origin feature/my-new-feature
  2. Open a Pull Request on GitHub

    • Use our PR template
    • Link related issues
    • Provide clear description
    • Add screenshots (if applicable)
  3. Wait for review

    • Address review comments
    • Keep PR updated with master
    • Be patient and respectful

PR Review Process

  1. Automated checks run (tests, linting, build)
  2. Maintainer review (code quality, design, tests)
  3. Revisions if needed
  4. Approval and merge

Coding Standards

TypeScript

  • Use TypeScript 5.x features
  • Enable strict mode
  • Prefer interfaces over type aliases for objects
  • Use explicit return types for public methods
  • Avoid any except in tests or reflect-metadata contexts

Code Style

  • Prettier formats all code (120 char line length)
  • ESLint enforces code quality rules
  • Use 2 spaces for indentation
  • Use single quotes for strings
  • Include semicolons
  • No trailing commas

Documentation

  • Add JSDoc to all public APIs
  • Include @param, @returns, @since tags
  • Provide @example code blocks
  • Use TypeScript in examples

Example:

/**
 * Store metadata on a class or property
 *
 * @param key - Metadata key identifier
 * @param value - Value to store
 * @param target - Target class constructor
 * @param propertyKey - Optional property name
 * @since 2.0.0
 *
 * @example
 * ```typescript
 * Metadata.set('my-key', 'value', MyClass);
 * ```
 */
static set(key: string, value: any, target: any, propertyKey?: string): void {
  // ...
}

File Naming

  • Use kebab-case for file names: object-helper.ts
  • Test files end with .spec.ts
  • Keep files focused and single-purpose

Project Structure

packages/
β”œβ”€β”€ .github/              # GitHub templates
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ commons/          # @expressive-tea/commons
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ classes/
β”‚   β”‚   β”‚   β”œβ”€β”€ helpers/
β”‚   β”‚   β”‚   β”œβ”€β”€ interfaces/
β”‚   β”‚   β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”‚   └── __test__/unit/
β”‚   β”‚   β”œβ”€β”€ dist/         # Build output (gitignored)
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”‚   └── jest.config.js
β”‚   └── plugin/           # @expressive-tea/plugin
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ classes/
β”‚       β”‚   β”œβ”€β”€ decorators/
β”‚       β”‚   β”œβ”€β”€ helpers/
β”‚       β”‚   β”œβ”€β”€ libs/
β”‚       β”‚   β”œβ”€β”€ exceptions/
β”‚       β”‚   └── __test__/unit/
β”‚       β”œβ”€β”€ dist/         # Build output (gitignored)
β”‚       β”œβ”€β”€ package.json
β”‚       β”œβ”€β”€ tsconfig.json
β”‚       └── jest.config.js
β”œβ”€β”€ package.json          # Root workspace config
β”œβ”€β”€ jest.config.js        # Root test config
β”œβ”€β”€ eslint.config.js      # ESLint v9 flat config
β”œβ”€β”€ tsconfig.base.json    # Shared TS config
└── README.md

Need Help?

Recognition

Contributors are recognized in:

  • Project README
  • Release notes
  • GitHub contributors page

Thank you for contributing to Expressive Tea! πŸ™

Your efforts help make this project better for everyone.