You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
6
52
2. Or start a conversation in [Issues](https://github.com/playcanvas/engine/issues) to get help and advice from community on PR ideas.
7
53
3. Read the coding standards below.
8
54
4. Keep PR simple and focused - one PR per feature.
9
55
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! 🎉
12
57
13
58
#### Tips
14
59
@@ -18,11 +63,58 @@ If you are looking for ideas what to work on, head to [Issues](https://github.co
18
63
19
64
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.
20
65
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
22
114
23
-
## General
115
+
###General
24
116
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.
26
118
27
119
### Keep it simple
28
120
@@ -44,10 +136,10 @@ You may use the following JavaScript language features in the engine codebase:
*[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.
// Due to the lack of native enum support by JavaScript, the enums are
193
285
// represented by constants. The constant name contains the enum name without
194
286
// 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:
196
288
constCUBEFACE_POSX=0;
197
289
constCUBEFACE_POSY=1;
198
290
// and this is also acceptable
@@ -278,7 +370,7 @@ function foo(a, b) {
278
370
```
279
371
280
372
281
-
## Privacy
373
+
###Privacy
282
374
283
375
### Make variables private if used only internally
284
376
@@ -298,7 +390,7 @@ let foo = new Item();
298
390
foo._a+="?"; // not good
299
391
```
300
392
301
-
## Object Member Iteration
393
+
###Object Member Iteration
302
394
303
395
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:
304
396
@@ -311,7 +403,7 @@ for (let key in values) {
311
403
}
312
404
```
313
405
314
-
## Source files
406
+
###Source files
315
407
316
408
### Filenames should contain only class name
317
409
@@ -324,9 +416,9 @@ asset-registry.js
324
416
graph-node.js
325
417
```
326
418
327
-
## Namespaces and Classes (ES6)
419
+
###Namespaces and Classes (ES6)
328
420
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):
330
422
331
423
```javascript
332
424
classClass {
@@ -348,7 +440,7 @@ class SubClass extends Class {
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
0 commit comments