Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit f0b859b

Browse files
iileimarkelog
authored andcommitted
Preset: add requireshorthandarrowfunctions rule to airbnb preset
See https://github.com/airbnb/javascript#8.2 Closes gh-2152
1 parent 4b97b03 commit f0b859b

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

presets/airbnb.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,6 @@
7676
"validateQuoteMarks": { "mark": "'", "escape": true, "ignoreJSX": true },
7777
"validateIndentation": 2,
7878
"maximumLineLength": 100,
79-
"disallowArrayDestructuringReturn": true
79+
"disallowArrayDestructuringReturn": true,
80+
"requireShorthandArrowFunctions": true
8081
}

test/data/options/preset/airbnb.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,15 @@
216216
})();
217217

218218
(function () {
219-
[1, 2, 3].map((x) => {
220-
return x * x;
221-
});
219+
[1, 2, 3].map(x => x * x);
222220
})();
223221

224222
(function () {
225223
// good
226224
[1, 2, 3].map(x => x * x);
227225

228226
// good
229-
[1, 2, 3].reduce((total, n) => {
230-
return total + n;
231-
}, 0);
227+
[1, 2, 3].reduce((total, n) => total + n, 0);
232228
})();
233229

234230
(function () {
@@ -425,4 +421,16 @@
425421
}
426422
})();
427423

424+
// requireShorthandArrowFunctions
425+
// https://github.com/airbnb/javascript#8.2
426+
(function () {
427+
[1, 2, 3].map(number => number * 2);
428+
})();
429+
430+
(function () {
431+
[1, 2, 3].map((number) => {
432+
const nextNumber = number + 1;
433+
return `A string containing the ${nextNumber}.`;
434+
});
435+
});
428436
})(window);

0 commit comments

Comments
 (0)