diff --git a/lib/rules/arrow-body-style.js b/lib/rules/arrow-body-style.js index 79fde90f805..1b2d1996a67 100644 --- a/lib/rules/arrow-body-style.js +++ b/lib/rules/arrow-body-style.js @@ -18,7 +18,7 @@ module.exports = { schema: [ { - enum: ["always", "as-needed"] + enum: ["always", "as-needed", "never"] } ] }, @@ -26,6 +26,7 @@ module.exports = { create: function(context) { var always = context.options[0] === "always"; var asNeeded = !context.options[0] || context.options[0] === "as-needed"; + var never = context.options[0] === "never"; /** * Determines whether a arrow function body needs braces @@ -36,18 +37,26 @@ module.exports = { var arrowBody = node.body; if (arrowBody.type === "BlockStatement") { - var blockBody = arrowBody.body; - - if (blockBody.length !== 1) { - return; - } - - if (asNeeded && blockBody[0].type === "ReturnStatement") { + if (never) { context.report({ node: node, loc: arrowBody.loc.start, message: "Unexpected block statement surrounding arrow body." }); + } else { + var blockBody = arrowBody.body; + + if (blockBody.length !== 1) { + return; + } + + if (asNeeded && blockBody[0].type === "ReturnStatement") { + context.report({ + node: node, + loc: arrowBody.loc.start, + message: "Unexpected block statement surrounding arrow body." + }); + } } } else { if (always) {