diff --git a/lib/rules/arrow-body-style.js b/lib/rules/arrow-body-style.js index 6d84c7adfb1..8d3b400037a 100644 --- a/lib/rules/arrow-body-style.js +++ b/lib/rules/arrow-body-style.js @@ -175,10 +175,10 @@ module.exports = { } /* - * If the first token of the reutrn value is `{`, + * If the first token of the reutrn value is `{` or the return value is a sequence expression, * enclose the return value by parentheses to avoid syntax error. */ - if (astUtils.isOpeningBraceToken(firstValueToken)) { + if (astUtils.isOpeningBraceToken(firstValueToken) || blockBody[0].argument.type === "SequenceExpression") { fixes.push( fixer.insertTextBefore(firstValueToken, "("), fixer.insertTextAfter(lastValueToken, ")") diff --git a/tests/lib/rules/arrow-body-style.js b/tests/lib/rules/arrow-body-style.js index 2c4fa953acc..4e755c2cab6 100644 --- a/tests/lib/rules/arrow-body-style.js +++ b/tests/lib/rules/arrow-body-style.js @@ -162,6 +162,18 @@ ruleTester.run("arrow-body-style", rule, { } ] }, + { + code: "var foo = () => { return a, b }", + output: "var foo = () => (a, b)", + errors: [ + { + line: 1, + column: 17, + type: "ArrowFunctionExpression", + messageId: "unexpectedSingleBlock" + } + ] + }, { code: "var foo = () => { return };", output: null, // not fixed