mirror of
https://github.com/airbnb/javascript.git
synced 2026-04-25 03:00:19 -04:00
Merge pull request #594 from pigoz/parens-brackets-curlys
Make the spaces within parenthesis/brackes/curlys rules explicit
This commit is contained in:
45
README.md
45
README.md
@@ -1551,6 +1551,51 @@ Other Style Guides
|
||||
}
|
||||
```
|
||||
|
||||
- [18.9](#18.9) <a name='18.9'></a> Do not add spaces inside parentheses.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
function bar( foo ) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
// good
|
||||
function bar(foo) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
// bad
|
||||
if ( foo ) {
|
||||
console.log(foo);
|
||||
}
|
||||
|
||||
// good
|
||||
if (foo) {
|
||||
console.log(foo);
|
||||
}
|
||||
```
|
||||
|
||||
- [18.10](#18.10) <a name='18.10'></a> Do not add spaces inside brackets.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
const foo = [ 1, 2, 3 ];
|
||||
console.log(foo[ 0 ]);
|
||||
|
||||
// good
|
||||
const foo = [1, 2, 3];
|
||||
console.log(foo[0]);
|
||||
```
|
||||
|
||||
- [18.11](#18.11) <a name='18.11'></a> Add spaces inside curly braces.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
const foo = {clark: 'kent'};
|
||||
|
||||
// good
|
||||
const foo = { clark: 'kent' };
|
||||
```
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
'rules': {
|
||||
// enforce spacing inside array brackets
|
||||
'array-bracket-spacing': 0,
|
||||
'array-bracket-spacing': [2, 'never'],
|
||||
// enforce one true brace style
|
||||
'brace-style': [2, '1tbs', {'allowSingleLine': true }],
|
||||
// require camel case names
|
||||
@@ -10,8 +10,8 @@ module.exports = {
|
||||
'comma-spacing': [2, {'before': false, 'after': true}],
|
||||
// enforce one true comma style
|
||||
'comma-style': [2, 'last'],
|
||||
// require or disallow padding inside computed properties
|
||||
'computed-property-spacing': 0,
|
||||
// disallow padding inside computed properties
|
||||
'computed-property-spacing': [2, 'never'],
|
||||
// enforces consistent naming when capturing the current execution context
|
||||
'consistent-this': 0,
|
||||
// enforce newline at the end of file, with no multiple empty lines
|
||||
@@ -66,8 +66,8 @@ module.exports = {
|
||||
'no-underscore-dangle': 0,
|
||||
// disallow the use of Boolean literals in conditional expressions
|
||||
'no-unneeded-ternary': 0,
|
||||
// require or disallow padding inside curly braces
|
||||
'object-curly-spacing': 0,
|
||||
// require padding inside curly braces
|
||||
'object-curly-spacing': [2, 'always'],
|
||||
// allow just one var statement per function
|
||||
'one-var': [2, 'never'],
|
||||
// require assignment operator shorthand where possible or prohibit it entirely
|
||||
@@ -96,8 +96,8 @@ module.exports = {
|
||||
'space-before-blocks': 2,
|
||||
// require or disallow space before function opening parenthesis
|
||||
'space-before-function-paren': [2, 'never'],
|
||||
// require or disallow spaces inside parentheses
|
||||
'space-in-parens': 0,
|
||||
// disallow spaces inside parentheses
|
||||
'space-in-parens': [2, 'never'],
|
||||
// require spaces around operators
|
||||
'space-infix-ops': 2,
|
||||
// require a space after return, throw, and case
|
||||
|
||||
Reference in New Issue
Block a user