|
| 1 | +# Contribution Guidelines |
| 2 | + |
| 3 | +Thanks you for considering a contribution to FocusTrap! |
| 4 | + |
| 5 | +FocusTrap is built using tools written for |
| 6 | +[nodejs](http://nodejs.org). We recommend installing Node with |
| 7 | +[nvm](https://github.com/creationix/nvm). this also means that |
| 8 | +dependencies are managed with an [`npm`](https://npmjs.org) `package.json` |
| 9 | +file. |
| 10 | + |
| 11 | +You can install dependencies with: |
| 12 | + |
| 13 | +```bash |
| 14 | +npm install |
| 15 | +``` |
| 16 | + |
| 17 | +## Running |
| 18 | + |
| 19 | +A production build can be built by running: |
| 20 | + |
| 21 | +```bash |
| 22 | +npm run prepublish |
| 23 | +``` |
| 24 | + |
| 25 | +However most of the time developing with FocusTrap, you will want |
| 26 | +to reference the example app: |
| 27 | + |
| 28 | +```bash |
| 29 | +npm start |
| 30 | +``` |
| 31 | + |
| 32 | +This will host the demo at `http://localhost:8080`. |
| 33 | + |
| 34 | +## Testing |
| 35 | + |
| 36 | +FocusTrap uses [Karma](https://karma-runner.github.io). You can run tests |
| 37 | +with: |
| 38 | + |
| 39 | +```bash |
| 40 | +npm test |
| 41 | +``` |
| 42 | + |
| 43 | +Be sure to check the `./coverage` folder to verify all code paths are |
| 44 | +touched. |
| 45 | + |
| 46 | +## Conventions |
| 47 | + |
| 48 | +**Consider master unsafe**, use [`npm`](https://www.npmjs.com/package/microcosm) for the latest stable version. |
| 49 | + |
| 50 | +### Javascript |
| 51 | + |
| 52 | +FocusTrap uses ES6 Javascript (compiled using [Babel](babeljs.io)). As |
| 53 | +for style, shoot for: |
| 54 | + |
| 55 | +- No semicolons |
| 56 | +- Commas last, |
| 57 | +- 2 spaces for indentation (no tabs) |
| 58 | +- Prefer ' over ", use string interpolation |
| 59 | +- 80 character line length |
| 60 | + |
| 61 | +### Testing |
| 62 | + |
| 63 | +Additionally, we aspire for 100% code coverage. However 100% code |
| 64 | +coverage is not a foolproof indicator of good testing. Tests that |
| 65 | +cover as much surface area as possible (for the sake of coverage) |
| 66 | +should be avoided. This is a much softer measure than a style guide, |
| 67 | +and will fall to code review for enforcement. |
| 68 | + |
| 69 | +### Reviews |
| 70 | + |
| 71 | +All changes should be submitted through pull request. Ideally, at |
| 72 | +least two :+1:s should be given before a pull request is merge. |
0 commit comments