From 0655f66525d167ca1288167b79a77087cfc8fcf6 Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Fri, 26 Jun 2020 03:26:29 +0900 Subject: [PATCH] Update: improve report location in arrow-body-style (refs #12334) (#13424) --- lib/rules/arrow-body-style.js | 4 ++-- tests/lib/rules/arrow-body-style.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/rules/arrow-body-style.js b/lib/rules/arrow-body-style.js index 9d5c77d8573..5954cf4a18d 100644 --- a/lib/rules/arrow-body-style.js +++ b/lib/rules/arrow-body-style.js @@ -136,7 +136,7 @@ module.exports = { context.report({ node, - loc: arrowBody.loc.start, + loc: arrowBody.loc, messageId, fix(fixer) { const fixes = []; @@ -201,7 +201,7 @@ module.exports = { if (always || (asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression")) { context.report({ node, - loc: arrowBody.loc.start, + loc: arrowBody.loc, messageId: "expectedBlock", fix(fixer) { const fixes = []; diff --git a/tests/lib/rules/arrow-body-style.js b/tests/lib/rules/arrow-body-style.js index 7c1bea64ef8..c624a847c6a 100644 --- a/tests/lib/rules/arrow-body-style.js +++ b/tests/lib/rules/arrow-body-style.js @@ -53,6 +53,8 @@ ruleTester.run("arrow-body-style", rule, { { line: 1, column: 17, + endLine: 1, + endColumn: 18, type: "ArrowFunctionExpression", messageId: "expectedBlock" } @@ -440,6 +442,8 @@ ruleTester.run("arrow-body-style", rule, { { line: 1, column: 17, + endLine: 3, + endColumn: 2, type: "ArrowFunctionExpression", messageId: "unexpectedSingleBlock" } @@ -452,6 +456,8 @@ ruleTester.run("arrow-body-style", rule, { { line: 1, column: 17, + endLine: 2, + endColumn: 13, type: "ArrowFunctionExpression", messageId: "unexpectedSingleBlock" } @@ -464,6 +470,8 @@ ruleTester.run("arrow-body-style", rule, { { line: 1, column: 17, + endLine: 2, + endColumn: 2, type: "ArrowFunctionExpression", messageId: "unexpectedSingleBlock" } @@ -508,6 +516,8 @@ ruleTester.run("arrow-body-style", rule, { { line: 2, column: 31, + endLine: 7, + endColumn: 16, type: "ArrowFunctionExpression", messageId: "unexpectedObjectBlock" }