Skip to content

Commit 4cdd4dc

Browse files
author
Marcos Mellado
committed
Updating arrow-parens rule to as-needed
1 parent 1ff7326 commit 4cdd4dc

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
An Airtame approach to Javascript and React
66

7-
TLDR; This eslint config follows Airbnb's [Javascript](https://github.com/airbnb/javascript) and [React](https://github.com/airbnb/javascript/tree/master/react) Styleguide, with a few additions for `import`/`export` validations and `jshint` validations and the exception of:
7+
TLDR; This eslint config follows Airbnb's [Javascript](https://github.com/airbnb/javascript) and [React](https://github.com/airbnb/javascript/tree/master/react) Styleguide, with a few additions for `import`/`export` and `jshint` validations and the exception of:
88

99
- [Identifier Names](https://github.com/airbnb/javascript#naming--descriptive)
10-
- [Arrow function's parentheses](https://github.com/airbnb/javascript#arrows--one-arg-parens)
1110
- [Using underscore to indicate privacy](https://github.com/airbnb/javascript/blob/master/README.md#naming--leading-underscore)
1211
- [White space in braces](https://github.com/airbnb/javascript#whitespace--in-braces)
1312

14-
1513
## Usage
1614

1715
Install as a development dependency to your project
@@ -79,21 +77,10 @@ Use implicit return on Arrow functions when possible
7977

8078
#### arrow-parens
8179

82-
Enforces all arrow functions to have parentheses on the parameter side, even when there's only one parameter
83-
84-
> Why? Consistency amongst all arrow functions
80+
Only use parenthesis when arrow functions have more than one parameter
8581

8682
```javascript
8783
// bad
88-
[1, 2, 3].map(number => {
89-
const nextNumber = number + 1;
90-
`A string containing the ${nextNumber}.`;
91-
});
92-
93-
// bad
94-
[1, 2, 3].map(number => `A string containing the ${number}.`);
95-
96-
// good
9784
[1, 2, 3].map((number) => {
9885
const nextNumber = number + 1;
9986
return `A string containing the ${nextNumber}.`;
@@ -103,6 +90,15 @@ Enforces all arrow functions to have parentheses on the parameter side, even whe
10390
[1, 2, 3].map((number, index) => ({
10491
[index]: number,
10592
}));
93+
94+
// good
95+
[1, 2, 3].map(number => {
96+
const nextNumber = number + 1;
97+
`A string containing the ${nextNumber}.`;
98+
});
99+
100+
// good
101+
[1, 2, 3].map(number => `A string containing the ${number}.`);
106102
```
107103

108104

eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"rules": {
4040
"array-bracket-spacing": [2],
4141
"arrow-body-style": [2, "as-needed"],
42-
"arrow-parens": [2, "always"],
42+
"arrow-parens": [2, "as-needed"],
4343
"arrow-spacing": [2],
4444
"brace-style": [2],
4545
"camelcase": [2, {"properties": "never"}],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-airtame",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "Airtame's ESLint configuration",
55
"scripts": {
66
"test": "mocha --reporter dot --compilers js:babel-register ./test/"

0 commit comments

Comments
 (0)