From 92ec2cb1731b7b6e0ac66336d583fbb782504290 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Fri, 16 Aug 2019 06:40:42 +0200 Subject: [PATCH] Fix: Allow bind call with a single spread element in no-extra-bind (#12088) --- lib/rules/no-extra-bind.js | 1 + tests/lib/rules/no-extra-bind.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/rules/no-extra-bind.js b/lib/rules/no-extra-bind.js index 5380cf217f4..cc0b1f84372 100644 --- a/lib/rules/no-extra-bind.js +++ b/lib/rules/no-extra-bind.js @@ -98,6 +98,7 @@ module.exports = { grandparent.type === "CallExpression" && grandparent.callee === parent && grandparent.arguments.length === 1 && + grandparent.arguments[0].type !== "SpreadElement" && parent.type === "MemberExpression" && parent.object === node && astUtils.getStaticPropertyName(parent) === "bind" diff --git a/tests/lib/rules/no-extra-bind.js b/tests/lib/rules/no-extra-bind.js index e9c72bca61a..cc2b164e8ec 100644 --- a/tests/lib/rules/no-extra-bind.js +++ b/tests/lib/rules/no-extra-bind.js @@ -21,6 +21,7 @@ const errors = [{ messageId: "unexpected", type: "CallExpression" }]; ruleTester.run("no-extra-bind", rule, { valid: [ "var a = function(b) { return b }.bind(c, d)", + { code: "var a = function(b) { return b }.bind(...c)", parserOptions: { ecmaVersion: 6 } }, "var a = function() { this.b }()", "var a = function() { this.b }.foo()", "var a = f.bind(a)",