- Created `scripts/check-code-style.js` to enforce coding standards. - Includes ESLint, Prettier checks, and custom semicolon rule validation. - Outputs actionable feedback for style violations. - Updated `CONTRIBUTING.md` to document new code style workflows and commands. - Added style commands to `package.json`: - `lint`, `lint:fix`, `format`, `check-format`, and `check-style`. - Refactored `demo/index.html` to use `Object.defineProperty` for better global property management and prevent conflicts. These changes enhance the automation of code quality checks, streamline developer workflows, and improve reliability in global property handling for the demo.
3.2 KiB
Contributing to Brainy
Thank you for your interest in contributing to Brainy! This document provides guidelines and instructions for contributing to the project.
We welcome contributions of all kinds, including bug fixes, feature additions, documentation improvements, and more. By participating in this project, you agree to abide by our Code of Conduct.
Commit Message Guidelines
When contributing to this project, please write clear and descriptive commit messages that explain the purpose of your changes. Good commit messages help maintainers understand your contributions and make the review process smoother.
Best Practices
- Keep the first line concise (ideally under 50 characters)
- Use the imperative mood ("Add feature" not "Added feature")
- Reference issues and pull requests where appropriate
- When necessary, provide more detailed explanations in the commit body
Examples
Add vector normalization option
Fix distance calculation in HNSW search
Update API documentation
Add support for IndexedDB storage
Change API parameter order
Simplify vector comparison logic
Update build dependencies
Pull Request Process
- Ensure your code follows the project's coding standards
- Update the documentation if necessary
- Use conventional commit messages in your PR
- Your PR will be reviewed by maintainers and merged if approved
Development Setup
- Fork and clone the repository
- Install dependencies:
npm install - Build the project:
npm run build
Code Style
This project uses ESLint and Prettier for code formatting and style checking. The configuration can be found in the package.json file. Please ensure your code follows these standards:
- Use 2 spaces for indentation
- Use single quotes for strings
- No semicolons
- Trailing commas are not used
- Maximum line length is 80 characters
You can check your code style by running:
npm run check-style
This will run all code style checks, including a specific check for semicolons.
You can also run individual checks:
npm run lint # Run ESLint to check for code issues
npm run lint:fix # Automatically fix linting issues
npm run format # Format your code with Prettier
npm run check-format # Check if your code is properly formatted
Branching Strategy
main- The main branch contains the latest stable releasedevelop- The development branch contains the latest development changes- Feature branches - Create a branch from
developfor your feature or fix
When working on a new feature or fix:
- Create a new branch from
developwith a descriptive name (e.g.,feature/add-vector-normalizationorfix/distance-calculation) - Make your changes in that branch
- Submit a pull request to merge your branch into
develop
Issue Reporting
Before submitting a new issue, please search existing issues to avoid duplicates.
- For bugs, use the bug report template
- For feature requests, use the feature request template
- Be as detailed as possible in your description
- Include code examples, error messages, and screenshots if applicable
Thank you for contributing to Brainy!