|
2 | 2 |
|
3 | 3 | Thanks you for considering a contribution to FocusTrap!
|
4 | 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. |
| 5 | +## Before Starting |
10 | 6 |
|
11 |
| -You can install dependencies with: |
| 7 | +FocusTrap is built using tools written for [nodejs](http://nodejs.org). We recommend installing Node with [nvm](https://github.com/creationix/nvm). Dependencies are managed through `package.json`. |
| 8 | + |
| 9 | +You use the same node version we are developing with by running |
12 | 10 |
|
13 | 11 | ```bash
|
14 |
| -npm install |
| 12 | +nvm use |
15 | 13 | ```
|
16 | 14 |
|
| 15 | +> You may need to run `nvm install` if you haven't installed the node version we require. |
| 16 | +
|
| 17 | +## Getting Started |
| 18 | + |
| 19 | +All commands should be run using yarn. If you haven't switched to [yarn](https://yarnpkg.com/en/) yet, now's a great time! |
| 20 | + |
| 21 | +> If you are familiar with npm then using yarn should be a breeze. You can keep using npm if you'd prefer but you will miss out on the safety and security of yarn |
| 22 | +
|
17 | 23 | ## Running
|
18 | 24 |
|
19 | 25 | A production build can be built by running:
|
20 | 26 |
|
21 | 27 | ```bash
|
22 |
| -npm run prepublish |
| 28 | +yarn build |
23 | 29 | ```
|
24 | 30 |
|
25 |
| -However most of the time developing with FocusTrap, you will want |
26 |
| -to reference the example app: |
| 31 | +However most of the time developing with FocusTrap, you will want to work from the example app. Boot that up with: |
27 | 32 |
|
28 | 33 | ```bash
|
29 |
| -npm start |
| 34 | +yarn start |
30 | 35 | ```
|
31 | 36 |
|
32 |
| -This will host the demo at `http://localhost:8080`. |
| 37 | +This will host a local development server at `http://localhost:8080`. |
33 | 38 |
|
34 | 39 | ## Testing
|
35 | 40 |
|
36 |
| -FocusTrap uses [Karma](https://karma-runner.github.io). You can run tests |
37 |
| -with: |
| 41 | +FocusTrap uses [Karma](https://karma-runner.github.io). You can run tests with: |
38 | 42 |
|
39 | 43 | ```bash
|
40 |
| -npm test |
| 44 | +yarn test |
41 | 45 | ```
|
42 | 46 |
|
43 |
| -Be sure to check the `./coverage` folder to verify all code paths are |
44 |
| -touched. |
| 47 | +## Prettier |
45 | 48 |
|
46 |
| -## Conventions |
| 49 | +We use [prettier](https://github.com/prettier/prettier) to ensure consistent style across all packages. Automated tests continually check that code formatting is consistent, failing the build if it is not. Make sure this doesn't happen by running: |
47 | 50 |
|
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 |
| 51 | +```bash |
| 52 | +yarn format |
| 53 | +``` |
60 | 54 |
|
61 | 55 | ### Testing
|
62 | 56 |
|
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. |
| 57 | +Additionally, we aspire for 100% code coverage. However 100% code coverage is not a foolproof indicator of good testing. Tests that cover as much surface area as possible (for the sake of coverage) should be avoided. This is a much softer measure than a style guide, and will fall to code review for enforcement. |
68 | 58 |
|
69 | 59 | ### Reviews
|
70 | 60 |
|
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. |
| 61 | +All changes should be submitted through pull request. Ideally, at least two :+1:s should be given before a pull request is merge. |
0 commit comments