From 197f4432fca70a574028e5568c48afad12213224 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Mon, 26 Aug 2019 19:27:28 +0200 Subject: [PATCH] Fix: func-name-matching crash on descriptor-like arguments (#12100) --- lib/rules/func-name-matching.js | 1 + tests/lib/rules/func-name-matching.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/rules/func-name-matching.js b/lib/rules/func-name-matching.js index 3c4ee510dbc..83430ffadfc 100644 --- a/lib/rules/func-name-matching.js +++ b/lib/rules/func-name-matching.js @@ -118,6 +118,7 @@ module.exports = { return false; } return node.type === "CallExpression" && + node.callee.type === "MemberExpression" && node.callee.object.name === objName && node.callee.property.name === funcName; } diff --git a/tests/lib/rules/func-name-matching.js b/tests/lib/rules/func-name-matching.js index efb7987d420..72ee66b41ed 100644 --- a/tests/lib/rules/func-name-matching.js +++ b/tests/lib/rules/func-name-matching.js @@ -255,6 +255,10 @@ ruleTester.run("func-name-matching", rule, { code: "Reflect.defineProperty(foo, 'bar', { value() {} })", options: ["never", { considerPropertyDescriptor: true }], parserOptions: { ecmaVersion: 6 } + }, + { + code: "foo({ value: function value() {} })", + options: ["always", { considerPropertyDescriptor: true }] } ], invalid: [ @@ -446,6 +450,13 @@ ruleTester.run("func-name-matching", rule, { errors: [ { messageId: "notMatchProperty", data: { funcName: "bar", name: "bar" } } ] + }, + { + code: "foo({ value: function bar() {} })", + options: ["always", { considerPropertyDescriptor: true }], + errors: [ + { messageId: "matchProperty", data: { funcName: "bar", name: "value" } } + ] } ] });