2013-05-13 16:53:09 +04:00
|
|
|
|
# How to contribute
|
|
|
|
|
|
|
|
|
|
I love pull requests. And following this simple guidelines will make your pull request easier to merge.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Submitting pull requests
|
|
|
|
|
|
|
|
|
|
1. Create a new branch, please don’t work in master directly.
|
2014-04-10 11:01:30 +04:00
|
|
|
|
2. Add failing tests (if there’re any tests in project) for the change you want to make. Run tests (see below) to see the tests fail.
|
2013-05-13 16:53:09 +04:00
|
|
|
|
3. Hack on.
|
|
|
|
|
4. Run tests to see if the tests pass. Repeat steps 2–4 until done.
|
|
|
|
|
5. Update the documentation to reflect any changes.
|
|
|
|
|
6. Push to your fork and submit a pull request.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## JavaScript code style
|
|
|
|
|
|
2014-04-10 10:18:35 +04:00
|
|
|
|
See [JSHint](.jshintrc) and [JSCS](.jscs.json) config files for more details.
|
|
|
|
|
|
2013-05-13 17:03:12 +04:00
|
|
|
|
- Tab indentation.
|
|
|
|
|
- Single-quotes.
|
|
|
|
|
- Semicolon.
|
|
|
|
|
- Strict mode.
|
|
|
|
|
- No trailing whitespace.
|
|
|
|
|
- Variables where needed.
|
|
|
|
|
- Multiple variable statements.
|
|
|
|
|
- Space after keywords and between arguments and operators.
|
2013-05-13 16:53:09 +04:00
|
|
|
|
- Use === and !== over == and !=.
|
2013-05-13 17:03:12 +04:00
|
|
|
|
- Return early.
|
|
|
|
|
- Limit line lengths to 120 chars.
|
|
|
|
|
- Prefer readability over religion.
|
2013-05-13 16:53:09 +04:00
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
function foo(bar, fum) {
|
|
|
|
|
if (!bar) return;
|
|
|
|
|
|
|
|
|
|
var hello = 'Hello';
|
|
|
|
|
var ret = 0;
|
|
|
|
|
for (var barIdx = 0; barIdx < bar.length; barIdx++) {
|
|
|
|
|
if (bar[barIdx] === hello) {
|
|
|
|
|
ret += fum(bar[barIdx]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Other notes
|
|
|
|
|
|
|
|
|
|
- If you have commit access to repo and want to make big change or not sure about something, make a new branch and open pull request.
|
|
|
|
|
- Don’t commit generated files: compiled from Stylus CSS, minified JavaScript, etc.
|
2013-11-12 14:41:26 +04:00
|
|
|
|
- Don’t change version number and changelog.
|
2013-05-13 16:53:09 +04:00
|
|
|
|
- Install [EditorConfig](http://editorconfig.org/) plugin for your code editor.
|
|
|
|
|
- Feel free to [ask me](http://sapegin.me/contacts) anything you need.
|
2013-05-29 10:59:54 +04:00
|
|
|
|
|
|
|
|
|
|
2014-04-10 11:01:30 +04:00
|
|
|
|
## Building and running tests
|
2013-05-29 10:59:54 +04:00
|
|
|
|
|
|
|
|
|
`cd` to `src` folder first.
|
|
|
|
|
|
2013-05-29 11:00:39 +04:00
|
|
|
|
Install dependencies:
|
2013-05-29 10:59:54 +04:00
|
|
|
|
|
|
|
|
|
```bash
|
2014-04-10 11:01:30 +04:00
|
|
|
|
npm install grunt-cli -g
|
2013-05-29 10:59:54 +04:00
|
|
|
|
npm install
|
|
|
|
|
```
|
|
|
|
|
|
2013-05-29 11:00:39 +04:00
|
|
|
|
Hack on:
|
2013-05-29 10:59:54 +04:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
grunt watch
|
|
|
|
|
```
|
|
|
|
|
|
2014-04-10 11:01:30 +04:00
|
|
|
|
Build / run tests:
|
2013-05-29 10:59:54 +04:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
grunt
|
|
|
|
|
```
|