diff --git a/README.md b/README.md
index e478830ca8..25fbd7f567 100644
--- a/README.md
+++ b/README.md
@@ -418,7 +418,7 @@ Other Style Guides
});
// good
- [1, 2, 3].map(x => x + 1);
+ [1, 2, 3].map((x) => x + 1);
// bad - no returned value means `acc` becomes undefined after the first iteration
[[0, 1], [2, 3], [4, 5]].reduce((acc, item, index) => {
@@ -955,13 +955,16 @@ Other Style Guides
```javascript
// bad
- [1, 2, 3].map(number => {
+ [1, 2, 3].map((number) => {
const nextNumber = number + 1;
`A string containing the ${nextNumber}.`;
});
+ // bad
+ [1, 2, 3].map((number) => `A string containing the ${number}.`);
+
// good
- [1, 2, 3].map(number => `A string containing the ${number + 1}.`);
+ [1, 2, 3].map((number) => `A string containing the ${number + 1}.`);
// good
[1, 2, 3].map((number) => {
@@ -1000,14 +1003,14 @@ Other Style Guides
```javascript
// bad
- ['get', 'post', 'put'].map(httpMethod => Object.prototype.hasOwnProperty.call(
+ ['get', 'post', 'put'].map((httpMethod) => Object.prototype.hasOwnProperty.call(
httpMagicObjectWithAVeryLongName,
httpMethod,
)
);
// good
- ['get', 'post', 'put'].map(httpMethod => (
+ ['get', 'post', 'put'].map((httpMethod) => (
Object.prototype.hasOwnProperty.call(
httpMagicObjectWithAVeryLongName,
httpMethod,
@@ -1016,22 +1019,27 @@ Other Style Guides
```
- - [8.4](#arrows--one-arg-parens) If your function takes a single argument and doesn’t use braces, omit the parentheses. Otherwise, always include parentheses around arguments for clarity and consistency. Note: it is also acceptable to always use parentheses, in which case use the [“always” option](https://eslint.org/docs/rules/arrow-parens#always) for eslint. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html)
+ - [8.4](#arrows--one-arg-parens) Always include parentheses around arguments for clarity and consistency. eslint: [`arrow-parens`](https://eslint.org/docs/rules/arrow-parens.html)
- > Why? Less visual clutter.
+ > Why? Minimizes diff churn when adding or removing arguments.
```javascript
// bad
- [1, 2, 3].map((x) => x * x);
-
- // good
[1, 2, 3].map(x => x * x);
// good
+ [1, 2, 3].map((x) => x * x);
+
+ // bad
[1, 2, 3].map(number => (
`A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`
));
+ // good
+ [1, 2, 3].map((number) => (
+ `A long string with the ${number}. It’s so long that we don’t want it to take up space on the .map line!`
+ ));
+
// bad
[1, 2, 3].map(x => {
const y = x + 1;
@@ -1050,13 +1058,13 @@ Other Style Guides
```javascript
// bad
- const itemHeight = item => item.height <= 256 ? item.largeSize : item.smallSize;
+ const itemHeight = (item) => item.height <= 256 ? item.largeSize : item.smallSize;
// bad
const itemHeight = (item) => item.height >= 256 ? item.largeSize : item.smallSize;
// good
- const itemHeight = item => (item.height <= 256 ? item.largeSize : item.smallSize);
+ const itemHeight = (item) => (item.height <= 256 ? item.largeSize : item.smallSize);
// good
const itemHeight = (item) => {
@@ -1070,16 +1078,16 @@ Other Style Guides
```javascript
// bad
- foo =>
+ (foo) =>
bar;
- foo =>
+ (foo) =>
(bar);
// good
- foo => bar;
- foo => (bar);
- foo => (
+ (foo) => bar;
+ (foo) => (bar);
+ (foo) => (
bar
)
```
@@ -1448,7 +1456,7 @@ Other Style Guides
});
// best (keeping it functional)
- const increasedByOne = numbers.map(num => num + 1);
+ const increasedByOne = numbers.map((num) => num + 1);
```
@@ -3028,7 +3036,7 @@ Other Style Guides
// bad - raises exception
const luke = {}
const leia = {}
- [luke, leia].forEach(jedi => jedi.father = 'vader')
+ [luke, leia].forEach((jedi) => jedi.father = 'vader')
// bad - raises exception
const reaction = "No! That’s impossible!"
diff --git a/packages/eslint-config-airbnb-base/rules/es6.js b/packages/eslint-config-airbnb-base/rules/es6.js
index 9c6328700e..dac5f4b98f 100644
--- a/packages/eslint-config-airbnb-base/rules/es6.js
+++ b/packages/eslint-config-airbnb-base/rules/es6.js
@@ -21,9 +21,7 @@ module.exports = {
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
- 'arrow-parens': ['error', 'as-needed', {
- requireForBlockBody: true,
- }],
+ 'arrow-parens': ['error', 'always'],
// require space before/after arrow function's arrow
// https://eslint.org/docs/rules/arrow-spacing
diff --git a/packages/eslint-config-airbnb-base/test/test-base.js b/packages/eslint-config-airbnb-base/test/test-base.js
index 07d17b1027..181e04f453 100644
--- a/packages/eslint-config-airbnb-base/test/test-base.js
+++ b/packages/eslint-config-airbnb-base/test/test-base.js
@@ -26,7 +26,7 @@ Object.keys(files).forEach((
// scan rules for react/ and fail if any exist
const reactRuleIds = Object.keys(config.rules)
- .filter(ruleId => ruleId.indexOf('react/') === 0);
+ .filter((ruleId) => ruleId.indexOf('react/') === 0);
t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
});
});
diff --git a/packages/eslint-config-airbnb/test/test-base.js b/packages/eslint-config-airbnb/test/test-base.js
index 807191dfe3..c283c3410c 100644
--- a/packages/eslint-config-airbnb/test/test-base.js
+++ b/packages/eslint-config-airbnb/test/test-base.js
@@ -28,7 +28,7 @@ Object.keys(files).forEach((name) => {
// scan rules for react/ and fail if any exist
const reactRuleIds = Object.keys(config.rules)
- .filter(ruleId => ruleId.indexOf('react/') === 0);
+ .filter((ruleId) => ruleId.indexOf('react/') === 0);
t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
});
});