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

Commit

Permalink
Preset: add requireshorthandarrowfunctions rule to airbnb preset
Browse files Browse the repository at this point in the history
  • Loading branch information
iilei authored and markelog committed Mar 2, 2016
1 parent 4b97b03 commit f0b859b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion presets/airbnb.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
"validateQuoteMarks": { "mark": "'", "escape": true, "ignoreJSX": true },
"validateIndentation": 2,
"maximumLineLength": 100,
"disallowArrayDestructuringReturn": true
"disallowArrayDestructuringReturn": true,
"requireShorthandArrowFunctions": true
}
20 changes: 14 additions & 6 deletions test/data/options/preset/airbnb.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,15 @@
})();

(function () {
[1, 2, 3].map((x) => {
return x * x;
});
[1, 2, 3].map(x => x * x);
})();

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

// good
[1, 2, 3].reduce((total, n) => {
return total + n;
}, 0);
[1, 2, 3].reduce((total, n) => total + n, 0);
})();

(function () {
Expand Down Expand Up @@ -425,4 +421,16 @@
}
})();

// requireShorthandArrowFunctions
// https://github.com/airbnb/javascript#8.2
(function () {
[1, 2, 3].map(number => number * 2);
})();

(function () {
[1, 2, 3].map((number) => {
const nextNumber = number + 1;
return `A string containing the ${nextNumber}.`;
});
});
})(window);

0 comments on commit f0b859b

Please sign in to comment.