Skip to content

Commit 7465c14

Browse files
committed
docs: add CONTRIBUTING.md
1 parent 766d314 commit 7465c14

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

CONTRIBUTING.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Contributing to lua-state
2+
3+
Thank you for your interest in contributing to lua-state! This document provides guidelines and information for contributors.
4+
5+
## Quick Start for Contributors
6+
7+
```bash
8+
git clone https://github.com/quaternion/node-lua-state.git
9+
cd node-lua-state
10+
npm i
11+
npm run test
12+
```
13+
14+
## Development Setup
15+
16+
### Option 1: Dev Container (Recommended)
17+
18+
This project includes a dev container configuration for a consistent development environment with all necessary tools and dependencies preinstalled.
19+
20+
**Prerequisites:**
21+
22+
- [Docker](https://www.docker.com/get-started)
23+
- [VS Code](https://code.visualstudio.com/) with [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
24+
25+
**Setup:**
26+
27+
1. Clone the repository:
28+
29+
```bash
30+
git clone https://github.com/quaternion/node-lua-state.git
31+
cd node-lua-state
32+
```
33+
34+
2. Open in VS Code and use Command Palette: `Dev Containers: Reopen in Container`
35+
36+
### Option 2: Local Development
37+
38+
**Prerequisites:**
39+
40+
- **Node.js 18+** - Required runtime
41+
- **tar** - System tool for extracting archives (or install via npm)
42+
- **C++ build environment** - For compiling native addons:
43+
- Linux: `build-essential` (Ubuntu/Debian) or equivalent
44+
- macOS: Xcode Command Line Tools
45+
- Windows: Visual Studio Build Tools
46+
47+
**Installation:**
48+
49+
1. Clone the repository:
50+
51+
```bash
52+
git clone https://github.com/quaternion/node-lua-state.git
53+
cd node-lua-state
54+
```
55+
56+
2. Install dependencies and build the native addon:
57+
58+
```bash
59+
npm i
60+
```
61+
62+
## Development Workflow
63+
64+
### Code Quality
65+
66+
This project uses [Biome](https://biomejs.dev/) for code formatting and linting:
67+
68+
- **Format code**: `npm run format`
69+
- **Check code**: `npm run lint`
70+
71+
All code must pass linting checks before submission.
72+
73+
### Testing
74+
75+
Run the test suite:
76+
77+
```bash
78+
npm run test
79+
```
80+
81+
Tests are written using Node.js built-in test runner and cover JavaScript integration with the native addon.
82+
83+
### Benchmarking
84+
85+
Run performance benchmarks:
86+
87+
```bash
88+
npm run bench
89+
```
90+
91+
This helps ensure changes don't negatively impact performance.
92+
93+
### Building Native Binaries
94+
95+
During local development, prefer running:
96+
97+
```bash
98+
./bin/lua-state.js install --force [options]
99+
```
100+
101+
rather than `npx lua-state install`, as npx may trigger duplicate builds. See the [README](README.md) for detailed build options.
102+
103+
## Pull Request Process
104+
105+
1. **Fork** the repository and create a feature branch:
106+
107+
```bash
108+
git checkout -b feature/your-feature-name
109+
```
110+
111+
2. **Make changes** following the code style and guidelines
112+
113+
3. **Test thoroughly**:
114+
115+
- Run `npm run test` to ensure all tests pass
116+
- Run `npm run lint` to check code quality
117+
- Run `npm run bench` to verify performance
118+
119+
4. **Update documentation** if needed (README, types, etc.)
120+
121+
5. **Commit** with clear, descriptive messages:
122+
123+
```bash
124+
git commit -m "feat: add new feature description"
125+
```
126+
127+
6. **Push** to your fork and create a **Pull Request**
128+
129+
### Commit Message Format
130+
131+
Follow conventional commit format:
132+
133+
- `feat:` - New features
134+
- `fix:` - Bug fixes
135+
- `docs:` - Documentation changes
136+
- `style:` - Code style changes
137+
- `refactor:` - Code refactoring
138+
- `test:` - Test additions/changes
139+
- `chore:` - Maintenance tasks
140+
141+
## Code Guidelines
142+
143+
### TypeScript
144+
145+
- Use TypeScript for all new code
146+
- Provide proper type annotations
147+
- Type definitions live in `types/` and are published with the package.
148+
149+
### C++ Code
150+
151+
- Follow the existing code style in `src/`
152+
- Use modern C++ features compatible with the target compilers
153+
- Ensure thread-safety for Node.js integration
154+
155+
### JavaScript/Node.js
156+
157+
- This project uses CommonJS; avoid ESM imports unless necessary.
158+
- Follow Node.js best practices
159+
- Handle errors properly with detailed messages
160+
161+
## Testing Guidelines
162+
163+
- Write tests for new features
164+
- Test edge cases and error conditions
165+
- Ensure cross-platform compatibility
166+
- Test with different Lua versions when applicable
167+
168+
## Reporting Issues
169+
170+
When reporting bugs:
171+
172+
1. Use the issue templates when available
173+
2. Include your environment (OS, Node.js version, Lua version)
174+
3. Provide minimal reproduction steps
175+
4. Include error messages and stack traces
176+
177+
## Security
178+
179+
- Report security vulnerabilities privately to the maintainers
180+
- Do not commit sensitive information
181+
- Follow secure coding practices
182+
183+
## License
184+
185+
By contributing, you agree that your contributions will be licensed under the same MIT License as the project.
186+
187+
## Getting Help
188+
189+
- Check existing issues and documentation first
190+
- Join discussions in GitHub issues
191+
- Ask questions in pull request comments
192+
193+
Thank you for contributing to lua-state! 🎉

0 commit comments

Comments
 (0)