Specify whitespace rules for parentheses

Based on existing examples and <http://sideeffect.kr/popularconvention/#javascript>.
This commit is contained in:
Tomek Wiszniewski
2015-04-02 04:10:21 +02:00
parent 520b6d658f
commit 2e51880f10

View File

@@ -803,6 +803,30 @@
});
```
- Place 1 space before the opening parenthesis in control statements (`if`, `while` etc.). Place no space before the argument list in function calls and declarations.
```javascript
// bad
if(isJedi) {
fight ();
}
// good
if (isJedi) {
fight();
}
// bad
function fight () {
console.log ('Swooosh!');
}
// good
function fight() {
console.log('Swooosh!');
}
```
- Set off operators with spaces.
```javascript