| 1 |
# How to contribute |
| 2 |
|
| 3 |
- [Getting help](#getting-help) |
| 4 |
- [Submitting bug reports](#submitting-bug-reports) |
| 5 |
- [Contributing code](#contributing-code) |
| 6 |
|
| 7 |
## Getting help |
| 8 |
|
| 9 |
Community discussion, questions, and informal bug reporting is done on the |
| 10 |
[discuss.CodeMirror forum](http://discuss.codemirror.net). |
| 11 |
|
| 12 |
## Submitting bug reports |
| 13 |
|
| 14 |
The preferred way to report bugs is to use the |
| 15 |
[GitHub issue tracker](http://github.com/codemirror/CodeMirror/issues). Before |
| 16 |
reporting a bug, read these pointers. |
| 17 |
|
| 18 |
**Note:** The issue tracker is for *bugs*, not requests for help. Questions |
| 19 |
should be asked on the |
| 20 |
[discuss.CodeMirror forum](http://discuss.codemirror.net) instead. |
| 21 |
|
| 22 |
### Reporting bugs effectively |
| 23 |
|
| 24 |
- CodeMirror is maintained by volunteers. They don't owe you anything, so be |
| 25 |
polite. Reports with an indignant or belligerent tone tend to be moved to the |
| 26 |
bottom of the pile. |
| 27 |
|
| 28 |
- Include information about **the browser in which the problem occurred**. Even |
| 29 |
if you tested several browsers, and the problem occurred in all of them, |
| 30 |
mention this fact in the bug report. Also include browser version numbers and |
| 31 |
the operating system that you're on. |
| 32 |
|
| 33 |
- Mention which release of CodeMirror you're using. Preferably, try also with |
| 34 |
the current development snapshot, to ensure the problem has not already been |
| 35 |
fixed. |
| 36 |
|
| 37 |
- Mention very precisely what went wrong. "X is broken" is not a good bug |
| 38 |
report. What did you expect to happen? What happened instead? Describe the |
| 39 |
exact steps a maintainer has to take to make the problem occur. We can not |
| 40 |
fix something that we can not observe. |
| 41 |
|
| 42 |
- If the problem can not be reproduced in any of the demos included in the |
| 43 |
CodeMirror distribution, please provide an HTML document that demonstrates |
| 44 |
the problem. The best way to do this is to go to |
| 45 |
[jsbin.com](http://jsbin.com/ihunin/edit), enter it there, press save, and |
| 46 |
include the resulting link in your bug report. |
| 47 |
|
| 48 |
## Contributing code |
| 49 |
|
| 50 |
Note that we are not accepting any new addons or modes into the main |
| 51 |
distribution. If you've written such a module, please distribute it as |
| 52 |
a separate NPM package. |
| 53 |
|
| 54 |
- Make sure you have a [GitHub Account](https://github.com/signup/free) |
| 55 |
- Fork [CodeMirror](https://github.com/codemirror/CodeMirror/) |
| 56 |
([how to fork a repo](https://help.github.com/articles/fork-a-repo)) |
| 57 |
- Make your changes |
| 58 |
- If your changes are easy to test or likely to regress, add tests. |
| 59 |
Tests for the core go into `test/test.js`, some modes have their own |
| 60 |
test suite under `mode/XXX/test.js`. Feel free to add new test |
| 61 |
suites to modes that don't have one yet (be sure to link the new |
| 62 |
tests into `test/index.html`). |
| 63 |
- Follow the general code style of the rest of the project (see |
| 64 |
below). Run `bin/lint` to verify that the linter is happy. |
| 65 |
- Make sure all tests pass. Visit `test/index.html` in your browser to |
| 66 |
run them. |
| 67 |
- Submit a pull request |
| 68 |
([how to create a pull request](https://help.github.com/articles/fork-a-repo)). |
| 69 |
Don't put more than one feature/fix in a single pull request. |
| 70 |
|
| 71 |
By contributing code to CodeMirror you |
| 72 |
|
| 73 |
- agree to license the contributed code under CodeMirror's [MIT |
| 74 |
license](https://codemirror.net/5/LICENSE). |
| 75 |
|
| 76 |
- confirm that you have the right to contribute and license the code |
| 77 |
in question. (Either you hold all rights on the code, or the rights |
| 78 |
holder has explicitly granted the right to use it like this, |
| 79 |
through a compatible open source license or through a direct |
| 80 |
agreement with you.) |
| 81 |
|
| 82 |
### Coding standards |
| 83 |
|
| 84 |
- 2 spaces per indentation level, no tabs. |
| 85 |
|
| 86 |
- Note that the linter (`bin/lint`) which is run after each commit |
| 87 |
complains about unused variables and functions. Prefix their names |
| 88 |
with an underscore to muffle it. |
| 89 |
|
| 90 |
- CodeMirror does *not* follow JSHint or JSLint prescribed style. |
| 91 |
Patches that try to 'fix' code to pass one of these linters will be |
| 92 |
unceremoniously discarded. |