Skip to content

Commit

Permalink
Merge pull request #594 from pigoz/parens-brackets-curlys
Browse files Browse the repository at this point in the history
Make the spaces within parenthesis/brackes/curlys rules explicit
  • Loading branch information
ljharb committed Nov 30, 2015
2 parents e032613 + 6debbcd commit 33e23fb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand Down
14 changes: 7 additions & 7 deletions packages/eslint-config-airbnb/rules/style.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 33e23fb

Please sign in to comment.