Thank you for considering contributing to the ComposeHooks project! This document provides guidelines for participating in project development.
Please respect all project participants and maintain a professional and friendly communication environment.
If you've found a bug or have a feature suggestion, please submit it through GitHub Issues and provide as much information as possible:
- Clear description of the issue
- Steps to reproduce
- Expected behavior vs actual behavior
- Relevant logs or screenshots
- Your environment information (OS, Kotlin version, Compose version, etc.)
- Fork this repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m '✨: add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Create a Pull Request
- File Header Declaration:
/*
Description: Brief description of the file
Author: Your Name
Date: ${DATE}-${TIME}
Email: [email protected]
Version: v1.0
*/
- Hook Implementation Guidelines:
- Return value should be named
XxxxHolder
- Ensure stability of the
Holder
- Do not return state values directly, wrap them in
State
- Put
State
first in the holder, followed by functions - Prefer using existing hooks over native Compose functions:
- Use
useState
instead ofderivedStateOf
- Use
useCreate
oruseRef
instead ofremember
- Use
useEffect
for side effects instead ofLaunchedEffect
- Use
- Use destructuring declaration syntax for holder function calls
- Declare type aliases for function members
- State Management:
- Use
State
wrapper for all state values - Follow Compose lifecycle guidelines
- Avoid unnecessary recompositions
- Ensure proper resource cleanup
- Handle edge cases and errors appropriately
To maintain consistency and readability in commit history, please follow these commit message guidelines:
-
Use Gitmoji: Each commit message should start with a relevant Gitmoji indicating the type of commit.
-
Common Gitmoji:
- ✨
:sparkles:
- Add new feature/hook - 🐛
:bug:
- Fix bug - 📝
:memo:
- Update documentation/comments - ⚡️
:zap:
- Refactor/optimize code - 🧑💻
:technologist:
- Update example code - 🩹
:adhesive_bandage:
- Fix/optimize/clean up code - ⬆️
:arrow_up:
- Update dependencies - 🔖
:bookmark:
- Version tags - 👷
:construction_worker:
- CI related changes - 💡
:bulb:
- Code/comment modifications - 💥
:boom:
- Breaking changes/migration - 🤖
:robot:
- Code cleanup/migration - 🎨
:art:
- Code formatting/structure optimization - 🔥
:fire:
- Remove code - 🧪
:test_tube:
- Add tests - 💩
:poop:
- Remove/refactor unreasonable code
- ✨
-
Message Format:
[Gitmoji] [Module]: Short description (max 50 chars)
Detailed description (optional, max 72 chars per line)
- Examples:
✨ [Network]: Add network state hook
Adds a hook for getting network state, including connection type and availability.
🐛 [Form]: Fix validation error in email field
Fixes an issue where email validation was not properly handling special characters.
📝 [Docs]: Update README with new hook examples
Adds comprehensive examples for useRequest and useForm hooks.
- Best Practices:
- Always use the most specific gitmoji that matches your changes
- Keep the first line under 50 characters
- Use the imperative mood in the first line
- Provide a detailed description when the change is complex
- Reference issues and pull requests liberally after the first line
- Consider starting the message with a verb
- Don't end the first line with a period
- Use the body to explain what and why vs. how
- Ensure PR title clearly describes the changes
- Provide detailed description of your changes in the PR, including the problem solved or feature added
- If your PR addresses an issue, link to it using keywords (e.g.,
Fixes #123
) - Ensure all tests pass
- Update relevant documentation if necessary
-
Naming Conventions:
- Hook function names should start with
use
, e.g.,useNetwork
- Names should clearly express functionality, avoid abbreviations
- Hook function names should start with
-
Documentation Requirements:
- Each hook must have complete KDoc documentation
- Documentation should include function description, parameter descriptions, return value description, and usage examples
-
Testing Requirements:
- Write unit tests for each hook
- Tests should cover normal usage scenarios and edge cases
- Include test cases for error conditions and edge cases
Provide example code for new hooks, demonstrating basic usage and common scenarios. Examples should be concise and easy to understand.
By contributing code, you agree that your contribution will be released under the project's license.
For any questions, please contact through GitHub Issues or reach out to the project maintainer: [email protected]