# Contributing to File Preview English | [็ฎ€ไฝ“ไธญๆ–‡](./CONTRIBUTING.zh-CN.md) Thank you for your interest in contributing to File Preview! This document provides guidelines and instructions for contributing. --- ## ๐Ÿ“– Table of Contents - [Code of Conduct](#code-of-conduct) - [Getting Started](#getting-started) - [Development Workflow](#development-workflow) - [Project Structure](#project-structure) - [Coding Standards](#coding-standards) - [Commit Guidelines](#commit-guidelines) - [Pull Request Process](#pull-request-process) - [Testing](#testing) - [Documentation](#documentation) --- ## Code of Conduct This project adheres to a code of conduct. By participating, you are expected to uphold this standard: - Be respectful and inclusive - Accept constructive criticism gracefully - Focus on what is best for the community - Show empathy towards other community members --- ## ๐Ÿš€ Getting Started ### Prerequisites - Node.js >= 18 - pnpm >= 8 ### Fork and Clone 1. Fork the repository on GitHub 2. Clone your fork locally: ```bash git clone https://github.com/YOUR_USERNAME/file-preview.git cd file-preview ``` 3. Add upstream remote: ```bash git remote add upstream https://github.com/wh131462/file-preview.git ``` ### Install Dependencies ```bash pnpm install ``` ### Verify Setup ```bash # Start React demo pnpm dev # Start Vue demo pnpm dev:vue # Start documentation site pnpm dev:docs ``` --- ## ๐Ÿ› ๏ธ Development Workflow ### Create a Feature Branch ```bash git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix ``` ### Make Your Changes 1. Edit files in the appropriate package 2. Test your changes locally 3. Add tests if applicable 4. Update documentation if needed ### Build and Test ```bash # Build all packages pnpm build # Build library only pnpm build:lib # Run linter pnpm lint # Run type checking pnpm type-check ``` ### Keep Your Branch Updated ```bash git fetch upstream git rebase upstream/master ``` --- ## ๐Ÿ“ Project Structure ``` file-preview/ โ”œโ”€โ”€ packages/ โ”‚ โ”œโ”€โ”€ file-preview-core/ # Framework-agnostic core โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ types/ # TypeScript type definitions โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ utils/ # Utility functions โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ loaders/ # File loaders and parsers โ”‚ โ”‚ โ””โ”€โ”€ package.json โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ react-file-preview/ # React bindings โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/ # React components โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ renderers/ # File type renderers โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ hooks/ # Custom React hooks โ”‚ โ”‚ โ””โ”€โ”€ package.json โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ vue-file-preview/ # Vue bindings โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Vue components โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ composables/ # Vue composables โ”‚ โ”‚ โ””โ”€โ”€ package.json โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ example/ # React demo app โ”‚ โ”œโ”€โ”€ vue-example/ # Vue demo app โ”‚ โ””โ”€โ”€ docs/ # VitePress documentation โ”‚ โ”œโ”€โ”€ openspec/ # OpenSpec change records โ””โ”€โ”€ pnpm-workspace.yaml ``` --- ## โœจ Coding Standards ### TypeScript - Use TypeScript for all new code - Define proper types, avoid `any` - Export public types from package entry points ### Code Style - Follow existing code style - Use ESLint configuration provided - Run `pnpm lint` before committing ### Naming Conventions - **Components**: PascalCase (e.g., `FilePreviewModal`) - **Files**: PascalCase for components, camelCase for utilities - **Variables/Functions**: camelCase - **Constants**: UPPER_SNAKE_CASE - **Types/Interfaces**: PascalCase ### Best Practices - Keep components focused and single-purpose - Extract reusable logic into hooks/composables - Write self-documenting code with clear names - Add comments for complex logic - Avoid deep nesting (max 3 levels) --- ## ๐Ÿ“ Commit Guidelines ### Commit Message Format Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: ``` ():