Skip to content

Commit 80ab95a

Browse files
committed
Merge pull request #451 from timss/gh-contributing
Add contribution guidelines, superseding HACKING
2 parents 52829f3 + 0e13fbd commit 80ab95a

File tree

2 files changed

+218
-153
lines changed

2 files changed

+218
-153
lines changed

CONTRIBUTING.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
Contributing
2+
============
3+
4+
Thank you for contributing to vimperator-labs!
5+
6+
Following are some guidelines designed to make the progress as smooth as
7+
possible. If you have any questions, feel free to drop by
8+
`#vimperator@freenode` or create an issue.
9+
10+
Issues
11+
------
12+
13+
A few things to keep in mind when creating a new issue:
14+
15+
- Follow the issue template
16+
- Attach relevant configuration or RC file if applicable (e.g. your
17+
`.vimperatorrc` or part of it).
18+
- Check if a fresh profile solves the issue
19+
- `$ firefox -no-remote -P`
20+
- Confirm if it works without your configuration
21+
- `$ firefox -no-remote -P <fresh profile> -vimperator "+u NONE"`
22+
23+
Pull requests
24+
-------------
25+
26+
- Title and commit message(s) should include relevant issue ID(s)
27+
- For any new or changed feature, AsciiDoc documentation and an entry in the
28+
NEWS file is required for the patch to be accepted.
29+
30+
Development installation
31+
------------------------
32+
33+
Creating and installing a new XPI file after each update is cumbersome.
34+
Instead, create an extension linking to the vimperator directory, for example
35+
of a Git clone.
36+
37+
1. Find the location your [Firefox profile](http://kb.mozillazine.org/Profile_folder_-_Firefox)
38+
- E.g. `/home/user/.mozilla/firefox/<hash>.default`
39+
2. Go into the `extensions` directory
40+
3. Delete `[email protected]`
41+
4. Create a `[email protected]` text file
42+
- Add the absolute path to your Vimperator directory
43+
- E.g. `/home/user/code/vimperator-labs/vimperator`
44+
5. Restart Firefox
45+
46+
Hacking
47+
-------
48+
49+
If you've taken to hacking Vimperator source code, we hope that you'll share
50+
your changes. In case you do, please keep the following in mind, and we'll be
51+
happy to accept your patches.
52+
53+
### Documentation
54+
55+
First of all, all new features and all user-visible changes to existing
56+
features need to be documented. That means editing the appropriate help files
57+
and adding a NEWS entry where appropriate. When editing the NEWS file, you
58+
should add your change to the top of the list of changes. If your change alters
59+
an interface (key binding, command) and is likely to cause trouble, prefix it
60+
with `IMPORTANT:`, otherwise, place it below the other `IMPORTANT` entries. If
61+
you're not sure if your change merits a news entry, or if it's important,
62+
please ask.
63+
64+
### Coding Style
65+
66+
In general: Just look at the existing source code!
67+
68+
We try to target experienced JavaScript developers who do not necessarily need
69+
to have a good understanding of Vimperator's source code, nor necessarily
70+
understand in-depth concepts of other languages like Lisp or Python. Therefore,
71+
the coding style should feel natural to any JavaScript developer. Of course,
72+
this does not mean, you have to avoid all new JavaScript features like list
73+
comprehension or generators. Use them, when they make sense, but don't use them
74+
when the resulting code is hard to read.
75+
76+
**Please stick to using only standards compliant JavaScript.**
77+
78+
#### The most important style issues are:
79+
80+
- Use 4 spaces to indent things, no tabs, not 2, nor 8 spaces. If you use Vim,
81+
this should be taken care of automatically by the modeline (like the one
82+
below).
83+
84+
- No trailing whitespace.
85+
86+
- Use `"` for enclosing strings instead of `'`, unless using `'` avoids
87+
escaping of lots of `"`:
88+
89+
```javascript
90+
alert("foo")
91+
92+
alert('foo')
93+
```
94+
95+
- Use `//` regexp literals rather than RegExp constructors, unless you're
96+
constructing an expression on the fly, or RegExp constructors allow you to
97+
escape less `/s` than the additional escaping of special characters required
98+
by string quoting:
99+
100+
```javascript
101+
// Good
102+
/application\/xhtml\+xml/
103+
RegExp("http://(www\\.)vimperator.org/(.*)/(.*)")
104+
105+
// Bad
106+
RegExp("application/xhtml\\+xml")
107+
/http:\/\/(www\.)vimperator.org\/(.*)\/(.*)/
108+
```
109+
110+
- Exactly one space after `if/for/while/catch` etc. and after a comma, but none
111+
after a parenthesis or after a function call:
112+
113+
```javascript
114+
for (pre; condition; post)
115+
alert("foo");
116+
```
117+
118+
- Bracing is formatted as follows:
119+
120+
```javascript
121+
function myFunction () {
122+
if (foo)
123+
return bar;
124+
else {
125+
baz = false;
126+
return baz;
127+
}
128+
}
129+
var quux = frob("you",
130+
{
131+
a: 1,
132+
b: 42,
133+
c: {
134+
hoopy: "frood"
135+
}
136+
});
137+
```
138+
139+
When in doubt, look for similar code.
140+
141+
- No braces for one-line conditional statements:
142+
143+
```javascript
144+
if (foo)
145+
frob();
146+
else
147+
unfrob();
148+
```
149+
150+
- Prefer the use of `let` over `var` i.e. only use `var` when required.
151+
152+
For more details, see:
153+
https://developer.mozilla.org/en/New_in_JavaScript_1.7#Block_scope_with_let
154+
155+
- Reuse common local variable names. E.g. `elem` is generally used for element,
156+
`win` for windows, `func` for functions, `ret` for return values etc.
157+
158+
- Prefer `//` over `/* */` comments (exceptions for big comments are usually
159+
OK):
160+
161+
```javascript
162+
// Good
163+
if (HACK) // TODO: remove hack
164+
165+
// Bad
166+
if (HACK) /* TODO: remove hack */
167+
```
168+
169+
- Documentation comment blocks use `/** ... */` Wrap these lines at 80
170+
characters.
171+
172+
- Only wrap lines if it makes the code obviously clearer. Lines longer than 132
173+
characters should probably be broken up rather than wrapped anyway.
174+
175+
- Use UNIX new lines (`\n`), not windows (`\r\n`) or old Mac ones (`\r`).
176+
177+
- Prefer Array iterator functions `Array#forEach` and `Array#map` over loops
178+
and array comprehensions.
179+
180+
- Avoid using `new` with constructors where possible, and use `[]` and
181+
`{}` rather than `new Array` or `new Object`:
182+
183+
```javascript
184+
// Good
185+
RegExp("^" + foo + "$")
186+
Function(code)
187+
new Date
188+
189+
// Bad
190+
new RegExp("^" + foo + "$")
191+
new Function(code)
192+
Date() // Right if you want a string-representation of the date
193+
```
194+
195+
- Don't use abbreviations for public methods:
196+
197+
```javascript
198+
// Good
199+
function splitString()...
200+
let commands = ...;
201+
let cmds = ...; // Since it's only used locally, abbreviations are ok, but so are the full names
202+
203+
// Bad
204+
function splitStr()
205+
```
206+
207+
Testing/Optimization
208+
--------------------
209+
210+
**TODO:**
211+
212+
- Add some information here about testing/validation/etc.
213+
- Information about how/when to use `:regressions` might be nice.
214+
- Additionally, maybe there should be some benchmark information here,
215+
something to let a developer know what's "too" slow...? Or general guidelines
216+
about optimization?
217+
218+
<!-- vim: set ft=markdown sw=4 ts=4 sts=4 et ai: -->

HACKING

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)