From 2557a5bca6b66108d27684ae25c6471e899b0cd7 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Nov 2015 13:25:49 +0100 Subject: [PATCH 1/3] Add Section 18.9 - No spaces inside parentheses See #593 --- README.md | 23 ++++++++++++++++++++ packages/eslint-config-airbnb/rules/style.js | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9f895b9a55..0c0822d024 100644 --- a/README.md +++ b/README.md @@ -1551,6 +1551,29 @@ Other Style Guides } ``` + - [18.9](#18.9) 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); + } + ``` **[⬆ back to top](#table-of-contents)** diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index c9df867f37..54a9e2fef4 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -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 From ee3759a7eddd2ba96210c90b0d2ff87d9ba6d209 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Nov 2015 13:28:28 +0100 Subject: [PATCH 2/3] Add Section 18.10 - No spaces inside brackets See #593 --- README.md | 12 ++++++++++++ packages/eslint-config-airbnb/rules/style.js | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c0822d024..c5d42505e3 100644 --- a/README.md +++ b/README.md @@ -1575,6 +1575,18 @@ Other Style Guides } ``` + - [18.10](#18.10) 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]); + ``` + **[⬆ back to top](#table-of-contents)** ## Commas diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 54a9e2fef4..0b6fad09c4 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -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 From 6debbcdd733bd00fb7c7f155d86e130337f9709b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Nov 2015 13:29:12 +0100 Subject: [PATCH 3/3] Add Section 18.11 - Add spaces inside curly braces Fixes #593 --- README.md | 10 ++++++++++ packages/eslint-config-airbnb/rules/style.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c5d42505e3..a953188d0a 100644 --- a/README.md +++ b/README.md @@ -1587,6 +1587,16 @@ Other Style Guides console.log(foo[0]); ``` + - [18.11](#18.11) Add spaces inside curly braces. + + ```javascript + // bad + const foo = {clark: 'kent'}; + + // good + const foo = { clark: 'kent' }; + ``` + **[⬆ back to top](#table-of-contents)** ## Commas diff --git a/packages/eslint-config-airbnb/rules/style.js b/packages/eslint-config-airbnb/rules/style.js index 0b6fad09c4..90e5aae3b9 100644 --- a/packages/eslint-config-airbnb/rules/style.js +++ b/packages/eslint-config-airbnb/rules/style.js @@ -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