Skip to content

Commit 89faafc

Browse files
authored
Tweak contributing guide and PR template (#7883)
* Tweak contributing guide and PR template * the
1 parent c3229b0 commit 89faafc

File tree

2 files changed

+118
-20
lines changed

2 files changed

+118
-20
lines changed

.github/CONTRIBUTING.md

Lines changed: 111 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
1-
# CONTRIBUTING
1+
# Contributing to the PlayCanvas Engine
22

3-
# HOW TO CONTRIBUTE
3+
Welcome! We're excited that you want to contribute to PlayCanvas. This guide will help you get started, whether you're fixing a typo or adding a major feature.
4+
5+
## Table of Contents
6+
- [Quick Start](#quick-start)
7+
- [Development Setup](#development-setup)
8+
- [How to Contribute](#how-to-contribute)
9+
- [Testing Your Changes](#testing-your-changes)
10+
- [Submitting Pull Requests](#submitting-pull-requests)
11+
- [Need Help?](#need-help)
12+
- [Coding Standards](#coding-standards)
13+
14+
## Quick Start
15+
16+
For **simple bug fixes or documentation updates**:
17+
18+
1. Fork the repository
19+
2. Create a branch: `git checkout -b fix-issue-123`
20+
3. Make your changes
21+
4. Run tests: `npm test`
22+
5. Submit a pull request
23+
24+
For **larger changes or new features**, please read the full guidelines below and consider opening an issue first to discuss your approach.
25+
26+
## Development Setup
27+
28+
1. **Fork and clone** the repository:
29+
```bash
30+
git clone https://github.com/YOUR_USERNAME/engine.git
31+
cd engine
32+
```
33+
34+
2. **Install dependencies**:
35+
```bash
36+
npm install
37+
```
38+
39+
3. **Run tests** to ensure everything works:
40+
```bash
41+
npm test
42+
```
43+
44+
4. **Build the engine** (optional, for testing):
45+
```bash
46+
npm run build
47+
```
48+
49+
## How to Contribute
450

551
1. Looking for ideas? Check out ["good first PR"](https://github.com/playcanvas/engine/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+PR%22) label.
652
2. Or start a conversation in [Issues](https://github.com/playcanvas/engine/issues) to get help and advice from community on PR ideas.
753
3. Read the coding standards below.
854
4. Keep PR simple and focused - one PR per feature.
955
5. Make a Pull Request.
10-
6. Complete the [Contributor License Agreement](https://docs.google.com/a/playcanvas.com/forms/d/1Ih69zQfJG-QDLIEpHr6CsaAs6fPORNOVnMv5nuo0cjk/viewform).
11-
7. Happy Days! 🎉
56+
6. Happy Days! 🎉
1257

1358
#### Tips
1459

@@ -18,11 +63,58 @@ If you are looking for ideas what to work on, head to [Issues](https://github.co
1863

1964
Try to keep PR focused on a single feature, small PR's are easier to review and will get merged faster. Too large PR's are better be broken into smaller ones so they can be merged and tested on its own.
2065

21-
# CODING STANDARDS
66+
## Testing Your Changes
67+
68+
PlayCanvas uses [Mocha](https://mochajs.org/) and [Chai](https://www.chaijs.com/) for unit testing.
69+
70+
### Running Tests
71+
```bash
72+
# Run all tests
73+
npm test
74+
75+
# Run tests with coverage report
76+
npm run test:coverage
77+
```
78+
79+
### Writing Tests
80+
- **Add tests for new features** - Write unit tests that prove your feature works
81+
- **Update existing tests** - Modify tests when changing existing behavior
82+
- **Test browser compatibility** - Ensure your changes work across target browsers
83+
- **Test with examples** - Check that relevant examples still work
84+
85+
### Test Guidelines
86+
- Place test files in the `test/` directory mirroring the source structure
87+
- Use `.test.mjs` extension for test files
88+
- Follow the existing test patterns and naming conventions
89+
- See [test/README.md](test/README.md) for detailed testing documentation
90+
91+
## Submitting Pull Requests
92+
93+
1. **Create a focused PR** - One feature or fix per pull request
94+
2. **Write a clear description** - Explain what changes and why
95+
3. **Reference issues** - Link to related issues with "Fixes #123"
96+
4. **Test thoroughly** - Ensure tests pass and no regressions
97+
5. **Follow code standards** - See detailed guidelines below
98+
6. **Be patient** - Reviews take time, especially for complex changes
99+
100+
### Git Workflow
101+
- Create feature branches from `main`: `git checkout -b feature-name`
102+
- Use clear commit messages describing what changed
103+
- Keep commits focused and atomic when possible
104+
- Rebase/squash if requested during review
105+
106+
## Need Help?
107+
108+
- **Questions about contributing?** Open a [Discussion](https://github.com/playcanvas/engine/discussions)
109+
- **Found a bug?** Check existing [Issues](https://github.com/playcanvas/engine/issues) first
110+
- **Want to chat?** Visit the [PlayCanvas Forum](http://forum.playcanvas.com/)
111+
- **Looking for ideas?** Check ["good first PR"](https://github.com/playcanvas/engine/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+PR%22) issues
112+
113+
## Coding Standards
22114

23-
## General
115+
### General
24116

25-
Our coding standards are derived from the [Google JavaScript Coding Standards](https://google.github.io/styleguide/javascriptguide.xml) which are based on ES5 (ECMA2009). Also we have a whitelist of modern JavaScript features (ES6+), explicitly listed below.
117+
Our coding standards are derived from established JavaScript best practices. We support modern JavaScript features (ES6+) as listed below, targeting current browser versions.
26118

27119
### Keep it simple
28120

@@ -44,10 +136,10 @@ You may use the following JavaScript language features in the engine codebase:
44136
* [Default parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters)
45137
* [Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
46138
* [Optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)
47-
* [Static keyword](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static)
139+
* [`static` keyword](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static)
48140
* [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
49-
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) - only functionality supported by all browsers, including Safari 8 - see the table at the end of the page. `for..of` type of loop should not be used to iterate a set as it is not supported on Safari 8.
50-
* [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) - only functionality supported by all browsers, including Safari 8 - see the table at the end of the page. `for..of` type of loop should not be used to iterate a map as it is not supported on Safari 8.
141+
* [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
142+
* [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
51143

52144
### Opening braces should be on the same line as the statement
53145

@@ -59,7 +151,7 @@ function inc() {
59151
}
60152
```
61153

62-
Also use the following style for 'if' statements:
154+
Also use the following style for `if` statements:
63155
```javascript
64156
if (test) {
65157
// do something
@@ -158,7 +250,7 @@ for (let i = 0; i < items.length; i++) {
158250
}
159251
```
160252

161-
## Naming
253+
### Naming
162254

163255
### Capitalization
164256

@@ -192,7 +284,7 @@ const THIS_IS_CONSTANT = "well, kind of";
192284
// Due to the lack of native enum support by JavaScript, the enums are
193285
// represented by constants. The constant name contains the enum name without
194286
// the underscores, followed by the values with optional underscores as
195-
// needed to improve the readibility. This is one possible implementation:
287+
// needed to improve the readability. This is one possible implementation:
196288
const CUBEFACE_POSX = 0;
197289
const CUBEFACE_POSY = 1;
198290
// and this is also acceptable
@@ -278,7 +370,7 @@ function foo(a, b) {
278370
```
279371

280372

281-
## Privacy
373+
### Privacy
282374

283375
### Make variables private if used only internally
284376

@@ -298,7 +390,7 @@ let foo = new Item();
298390
foo._a += "?"; // not good
299391
```
300392

301-
## Object Member Iteration
393+
### Object Member Iteration
302394

303395
The hasOwnProperty() function should be used when iterating over an object's members. This is to avoid accidentally picking up unintended members that may have been added to the object's prototype. For example:
304396

@@ -311,7 +403,7 @@ for (let key in values) {
311403
}
312404
```
313405

314-
## Source files
406+
### Source files
315407

316408
### Filenames should contain only class name
317409

@@ -324,9 +416,9 @@ asset-registry.js
324416
graph-node.js
325417
```
326418

327-
## Namespaces and Classes (ES6)
419+
### Namespaces and Classes (ES6)
328420

329-
The entire PlayCanvas API must be declared under the ```pc``` namespace. This is handled by build script, so ES6 notation of `import`/`export` should be used. The vast majority of the PlayCanvas codebase is made up of `class` definitions. These have the following structure (which should be adhered to):
421+
The entire PlayCanvas API must be declared under the `pc` namespace. This is handled by build script, so ES6 notation of `import`/`export` should be used. The vast majority of the PlayCanvas codebase is made up of `class` definitions. These have the following structure (which should be adhered to):
330422

331423
```javascript
332424
class Class {
@@ -348,7 +440,7 @@ class SubClass extends Class {
348440
}
349441

350442
someFunc(x) {
351-
// if method is overriden
443+
// if method is overridden
352444
// this is the way to call parent class method
353445
super.someFunc(x);
354446
}

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Description
2+
Brief description of what this PR does.
3+
14
Fixes #
25

3-
I confirm I have read the [contributing guidelines](https://github.com/playcanvas/engine/blob/master/.github/CONTRIBUTING.md) and signed the [Contributor License Agreement](https://docs.google.com/a/playcanvas.com/forms/d/1Ih69zQfJG-QDLIEpHr6CsaAs6fPORNOVnMv5nuo0cjk/viewform).
6+
## Checklist
7+
- [ ] I have read the [contributing guidelines](https://github.com/playcanvas/engine/blob/master/.github/CONTRIBUTING.md)
8+
- [ ] My code follows the project's coding standards
9+
- [ ] This PR focuses on a single change

0 commit comments

Comments
 (0)