Use markdown
because the rst wasn't formatting and we use md for everything else in this repo, and in a document that talks about consistency...
This commit is contained in:
parent
dfe745c9e6
commit
56c73b68a9
1 changed files with 15 additions and 6 deletions
|
@ -8,7 +8,6 @@ at https://github.com/matrix-org/synapse/blob/master/docs/code_style.rst
|
||||||
|
|
||||||
General Style
|
General Style
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
- 4 spaces to indent, for consistency with Matrix Python.
|
- 4 spaces to indent, for consistency with Matrix Python.
|
||||||
- Max line width: 79 chars (with flexibility to overflow by a "few chars" if
|
- Max line width: 79 chars (with flexibility to overflow by a "few chars" if
|
||||||
the overflowing content is not semantically significant and avoids an
|
the overflowing content is not semantically significant and avoids an
|
||||||
|
@ -28,7 +27,8 @@ General Style
|
||||||
"bad" // Bad
|
"bad" // Bad
|
||||||
'good' // Good
|
'good' // Good
|
||||||
- Use parentheses instead of '\\' for line continuation where ever possible
|
- Use parentheses instead of '\\' for line continuation where ever possible
|
||||||
- Open braces on the same line (consistent with Node)::
|
- Open braces on the same line (consistent with Node):
|
||||||
|
```
|
||||||
if (x) {
|
if (x) {
|
||||||
console.log("I am a fish"); // Good
|
console.log("I am a fish"); // Good
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,9 @@ General Style
|
||||||
{
|
{
|
||||||
console.log("I am a fish"); // Bad
|
console.log("I am a fish"); // Bad
|
||||||
}
|
}
|
||||||
- Spaces after `if`, `for`, `else` etc, no space around the condition::
|
```
|
||||||
|
- Spaces after `if`, `for`, `else` etc, no space around the condition:
|
||||||
|
```
|
||||||
if (x) {
|
if (x) {
|
||||||
console.log("I am a fish"); // Good
|
console.log("I am a fish"); // Good
|
||||||
}
|
}
|
||||||
|
@ -49,9 +51,11 @@ General Style
|
||||||
if ( x ) {
|
if ( x ) {
|
||||||
console.log("I am a fish"); // Bad
|
console.log("I am a fish"); // Bad
|
||||||
}
|
}
|
||||||
|
```
|
||||||
- Declare one variable per var statement (consistent with Node). Unless they
|
- Declare one variable per var statement (consistent with Node). Unless they
|
||||||
are simple and closely related. If you put the next declaration on a new line,
|
are simple and closely related. If you put the next declaration on a new line,
|
||||||
treat yourself to another `var`::
|
treat yourself to another `var`:
|
||||||
|
```
|
||||||
var key = "foo",
|
var key = "foo",
|
||||||
comparator = function(x, y) {
|
comparator = function(x, y) {
|
||||||
return x - y;
|
return x - y;
|
||||||
|
@ -66,7 +70,9 @@ General Style
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0; // Also fine
|
var y = 0; // Also fine
|
||||||
- A single line `if` is fine, all others have braces. This prevents errors when adding to the code.::
|
```
|
||||||
|
- A single line `if` is fine, all others have braces. This prevents errors when adding to the code.:
|
||||||
|
```
|
||||||
if (x) return true; // Fine
|
if (x) return true; // Fine
|
||||||
|
|
||||||
if (x) {
|
if (x) {
|
||||||
|
@ -75,7 +81,9 @@ General Style
|
||||||
|
|
||||||
if (x)
|
if (x)
|
||||||
return true; // Not fine
|
return true; // Not fine
|
||||||
- Terminate all multi-line lists with commas::
|
```
|
||||||
|
- Terminate all multi-line lists with commas:
|
||||||
|
```
|
||||||
var mascots = [
|
var mascots = [
|
||||||
"Patrick",
|
"Patrick",
|
||||||
"Shirley",
|
"Shirley",
|
||||||
|
@ -91,6 +99,7 @@ General Style
|
||||||
"Susan",
|
"Susan",
|
||||||
"Sir Arthur David", // Good
|
"Sir Arthur David", // Good
|
||||||
];
|
];
|
||||||
|
```
|
||||||
- Use `null`, `undefined` etc consistently with node:
|
- Use `null`, `undefined` etc consistently with node:
|
||||||
Boolean variables and functions should always be either true or false. Don't set it to 0 unless it's supposed to be a number.
|
Boolean variables and functions should always be either true or false. Don't set it to 0 unless it's supposed to be a number.
|
||||||
When something is intentionally missing or removed, set it to null.
|
When something is intentionally missing or removed, set it to null.
|
Loading…
Reference in a new issue