Skip to content

Commit

Permalink
Fix: func-name-matching crash on descriptor-like arguments (#12100)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored and kaicataldo committed Aug 26, 2019
1 parent 644ce33 commit 197f443
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rules/func-name-matching.js
Expand Up @@ -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;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/func-name-matching.js
Expand Up @@ -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: [
Expand Down Expand Up @@ -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" } }
]
}
]
});

0 comments on commit 197f443

Please sign in to comment.