Thank you for your interest in contributing to the Comic Vine SDK! This document provides guidelines and information to help you contribute effectively to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Code Standards
- Testing
- Submitting Changes
- Project Structure
- Resources
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to allymurray88@gmail.com.
Before you begin, ensure you have the following installed:
- Node.js: Version 20.0.0 or higher
- pnpm: Version 9.15.4+ (specified in package.json)
npm install -g pnpm@9.15.4
-
Fork and Clone
git clone https://github.com/your-username/comic-vine.git cd comic-vine -
Install Dependencies
pnpm install
-
Verify Setup
pnpm test
If all tests pass, you're ready to start developing!
-
Create a feature branch from
main:git checkout -b feature/your-feature-name # or git checkout -b fix/issue-description -
Use descriptive branch names:
feature/add-search-paginationfix/handle-rate-limitingdocs/update-readme-examples
- Write Code: Follow the Code Standards below
- Add Tests: Ensure new functionality has corresponding tests
- Run Tests:
pnpm testto run tests and linting - Build:
pnpm compileto ensure your changes compile correctly
Follow conventional commit format:
type(scope): description
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
feat(resources): add pagination support to character list
fix(http-client): handle network timeout errors
docs(readme): update installation instructions
- Type Safety: Prefer explicit types over
any - Interfaces: Use interfaces for object shapes
- Generics: Leverage generics for reusable components
- Strict Mode: The project uses strict TypeScript settings
The project uses ESLint and Prettier for code formatting:
# Auto-fix linting issues and format code
pnpm lint
# Check linting without fixing
npx eslint src --ext .tsKey Style Rules:
- Use camelCase for variables and functions
- Use PascalCase for classes and interfaces
- Prefer
constoverletwhen possible - Use meaningful variable names
- Add JSDoc comments for public APIs
Imports should be organized as follows:
// 1. Built-in Node.js modules
import { readFile } from 'fs/promises';
// 2. External dependencies
import axios from 'axios';
import { z } from 'zod';
// 3. Internal modules (ordered alphabetically)
import { BaseResource } from './base-resource';
import { HttpClient } from './http-client';# Run all tests with linting
pnpm test
# Run tests only (without linting)
pnpm test:run
# Run tests in watch mode
npx vitest --dir=src- Location: Place test files alongside source files with
.test.tsextension - Naming: Use descriptive test names that explain the behavior being tested
- Structure: Follow Arrange-Act-Assert pattern
Example Test:
import { describe, test, expect } from 'vitest';
describe('ResourceName', () => {
test('should return correct data when field list is specified', async () => {
// Arrange
const expectedFields = ['id', 'name'];
// Act
const result = await resource.retrieve(123, { fieldList: expectedFields });
// Assert
expect(Object.keys(result)).toEqual(expectedFields);
});
});- Write tests for all new functionality
- Include both success and error scenarios
- Mock external dependencies using nock for HTTP requests
- Test files are located in
src/__mocks__/for mock data
-
Update Documentation: Ensure README, JSDoc, and other docs reflect your changes
-
Verify Quality Checks: All checks must pass before merging
pnpm test:run # All tests pass pnpm lint # No linting errors pnpm compile # Code compiles successfully
-
Create Pull Request:
- Use a descriptive title
- Reference any related issues
- Provide clear description of changes
- Include examples if adding new features
-
Review Process:
- Maintainers will review your PR
- Address any feedback promptly
- See CODE_REVIEW.md for review criteria
The project uses Husky and lint-staged to ensure code quality:
- Auto-formatting: Prettier formats code on commit
- Linting: ESLint checks are enforced
- Type checking: TypeScript compilation is verified
If pre-commit hooks fail, fix the issues before committing:
pnpm lint # Fix linting issues
git add . # Stage the fixes
git commit # Try committing againsrc/
├── comic-vine.ts # Main SDK class
├── errors/ # Custom error classes
├── http-client/ # HTTP client and URL builder
├── options/ # Configuration options
├── resources/ # API resource implementations
│ ├── base-resource.ts # Base class for all resources
│ ├── character/ # Character-specific code
│ ├── issue/ # Issue-specific code
│ └── ... # Other Comic Vine resources
├── types/ # TypeScript type definitions
└── utils/ # Utility functions
When adding support for a new Comic Vine API resource:
- Create a new directory under
src/resources/ - Implement the resource class extending
BaseResource - Add TypeScript types in a
types/subdirectory - Write comprehensive tests
- Update the main
ComicVineclass to include the new resource - Add mock data for testing
- Issues: GitHub Issues
- Discussions: Use GitHub Discussions for questions
- Package Manager: pnpm
- Testing: Vitest
- Linting: ESLint + TypeScript ESLint
- Formatting: Prettier
- Git Hooks: Husky
Thank you for contributing to Comic Vine SDK! Your contributions help make this library better for everyone. 🚀