diff --git a/lib/hooks/ArrowFunctionExpression.js b/lib/hooks/ArrowFunctionExpression.js index 96d88fc..db3fd05 100644 --- a/lib/hooks/ArrowFunctionExpression.js +++ b/lib/hooks/ArrowFunctionExpression.js @@ -42,7 +42,15 @@ function shouldHandleParams(node) { } function shouldIndentBody(node, opts) { - // we don't want to indent the body twice if ObjectExpression or - // ArrayExpression or CallExpression - return node.body.type === 'BlockStatement' || !opts[node.body.type]; + var bodyFirstNonEmpty = tk.findNextNonEmpty(node.body.startToken); + + if (bodyFirstNonEmpty.value === '}') { + // noop + limit.after(node.body.startToken, 0); + return false; + } else { + // we don't want to indent the body twice if ObjectExpression or + // ArrayExpression or CallExpression + return node.body.type === 'BlockStatement' || !opts[node.body.type]; + } } diff --git a/test/compare/default/arrow_function_expression-in.js b/test/compare/default/arrow_function_expression-in.js index d5479a7..2b67972 100644 --- a/test/compare/default/arrow_function_expression-in.js +++ b/test/compare/default/arrow_function_expression-in.js @@ -7,6 +7,13 @@ arr.map(d => {return d * 2;}); arr.map( ( e , f , g) => e * f - g ); +// noop (#487) +const f1 = () => {}; +const f2 = ( ) => { }; +const f3 = ( ) => { + +}; + // default params (#285) let defaultParams = (x, y = 1, z = 2 ) => { return x + y + z; diff --git a/test/compare/default/arrow_function_expression-out.js b/test/compare/default/arrow_function_expression-out.js index d8cb4ce..3afbef9 100644 --- a/test/compare/default/arrow_function_expression-out.js +++ b/test/compare/default/arrow_function_expression-out.js @@ -10,6 +10,11 @@ arr.map(d => { }); arr.map((e, f, g) => e * f - g); +// noop (#487) +const f1 = () => {}; +const f2 = () => {}; +const f3 = () => {}; + // default params (#285) let defaultParams = (x, y = 1, z = 2) => { return x + y + z;