From ae14a021bbea5117fe366ae4ed235e8f08dc65a8 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Fri, 27 Mar 2020 22:22:36 +0100 Subject: [PATCH] Fix: add end location to report in no-extra-bind (refs #12334) (#13083) --- lib/rules/no-extra-bind.js | 2 +- tests/lib/rules/no-extra-bind.js | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/rules/no-extra-bind.js b/lib/rules/no-extra-bind.js index d938c0f51b0..df695924ab5 100644 --- a/lib/rules/no-extra-bind.js +++ b/lib/rules/no-extra-bind.js @@ -64,7 +64,7 @@ module.exports = { context.report({ node: node.parent.parent, messageId: "unexpected", - loc: node.parent.property.loc.start, + loc: node.parent.property.loc, fix(fixer) { if (node.parent.parent.arguments.length && !isSideEffectFree(node.parent.parent.arguments[0])) { return null; diff --git a/tests/lib/rules/no-extra-bind.js b/tests/lib/rules/no-extra-bind.js index 3bfcda8c5d0..12197967176 100644 --- a/tests/lib/rules/no-extra-bind.js +++ b/tests/lib/rules/no-extra-bind.js @@ -36,18 +36,39 @@ ruleTester.run("no-extra-bind", rule, { { code: "var a = function() { return 1; }.bind(b)", output: "var a = function() { return 1; }", - errors + errors: [{ + messageId: "unexpected", + type: "CallExpression", + line: 1, + column: 34, + endLine: 1, + endColumn: 38 + }] }, { code: "var a = function() { return 1; }['bind'](b)", output: "var a = function() { return 1; }", - errors + errors: [{ + messageId: "unexpected", + type: "CallExpression", + line: 1, + column: 34, + endLine: 1, + endColumn: 40 + }] }, { code: "var a = function() { return 1; }[`bind`](b)", output: "var a = function() { return 1; }", parserOptions: { ecmaVersion: 6 }, - errors + errors: [{ + messageId: "unexpected", + type: "CallExpression", + line: 1, + column: 34, + endLine: 1, + endColumn: 40 + }] }, { code: "var a = (() => { return 1; }).bind(b)",