Skip to content
James Holding edited this page Apr 2, 2017 · 3 revisions

Contributing Guide

Style Guide

We use js-beautify to help simplify our code style.

If you are using VSCode, the plugin to automatically apply the correct style is here: https://github.com/HookyQR/VSCodeBeautify

Generally, the style is:

  • 4 spaces for an indent
  • UpperCamelCase for functions and properties
  • lowerCamelCase for variables
  • Use Symbol() for any class variables that shouldn't be altered post-construction
    • It is fine to create a get property to return this if it is required
  • Any data fetched from a network location should be cached
    • We use cache-manager to cache data, so users can choose their storage method
    • Defaults to memory cache
  • Each file should expose one class/object or a collection of functions
    • Don't expose an array of classes, it gets messy and IDEs can't auto-complete them easily
  • Use Promises throughout the library
    • It's OK to create a helper function to use the classic callback style on top of a Promise function
    • Internally, make use of Promises
  • Throw errors on construction errors
  • Reject Promises on all other function errors

Run the following to test the library formatting

npm run lint

Testing

To test the library, run the following:

npm run lint && NODE_DEBUG=themeparks npm run testdev

This will run the code format check, and then run the unit tests (with NODE_DEBUG set, so we get debug output).

No code should be committed until this succeeds!

Documenting

** TODO **

npm run docs
Clone this wiki locally