UNPKG

1.63 kBMarkdownView Raw
1First of all thank you for contributing.
2
3## Overview
4We try our best to adhere to the [airbnb](https://github.com/airbnb/javascript/blob/master/README.md) javascript style guidelines.
5
6If you spot non compliant code in our codebase do not hesitate to flag it or even submit a pull request.
7Running `npm run lint` can help.
8
9We do not ask that you agree with our guidelines but if you want to contribute you will have to respect them.
10
11## Pull-requests
12
13LokiJS puts a strong emphasis on performance. Make sure to benchmark performance on your machine before and after you apply a change and ensure performance is unchanged (or unnoticeable), even better if it is improved.
14Verify your changes are non-breaking by running `npm test`, and if you're adding a feature make sure to add a test somewhere in the relevant file in `spec/` (or a brand new file if the test cannot be included in existing files).
15
16## A few things we recommend
17
18Most of these are included in the airbnb style guide but we feel like highlighting them:
19
20* use shortcuts in if conditions, and always follow with a statements in curly brackets. Do not do:
21`if (something) return;` instead do `if (something) { return; }`
22* Name callbacks, when possible try to declare them as functions that can be cached to save memory as well making your code more readable. i.e. instead of
23```javascript
24result.filter(function () { /* ... */ });
25```
26try to do:
27```javascript
28function doFilter(obj) {
29 // ...
30}
31result.filter(doFilter);
32```
33
34## A few things we will not accept
35
36* comma first
37* avoid-semicolon-at-all-cost stupidity
38* general hipster code
39* coffeescript/TypeScript