Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the spaces within parenthesis/brackes/curlys rules explicit #594

Merged
merged 3 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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