Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix: add end location to report in no-extra-bind (refs #12334) (#13083)
  • Loading branch information
mdjermanovic committed Mar 27, 2020
1 parent 105384c commit ae14a02
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-extra-bind.js
Expand Up @@ -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;
Expand Down
27 changes: 24 additions & 3 deletions tests/lib/rules/no-extra-bind.js
Expand Up @@ -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)",
Expand Down

0 comments on commit ae14a02

Please sign in to comment.