From 3b504fa6d3eaf51b91c2b04e717256a0047dc9c8 Mon Sep 17 00:00:00 2001 From: Hao Cheng Date: Wed, 3 Jan 2024 10:48:36 +0100 Subject: [PATCH] `prefer-prototype-methods`: Fix argument of `isMethodCall` (#2247) --- rules/prefer-prototype-methods.js | 2 +- test/prefer-prototype-methods.mjs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rules/prefer-prototype-methods.js b/rules/prefer-prototype-methods.js index 673e86b4ed..e3bdb718a7 100644 --- a/rules/prefer-prototype-methods.js +++ b/rules/prefer-prototype-methods.js @@ -30,7 +30,7 @@ function create(context) { // `[].foo.{apply,bind,call}(…)` // `({}).foo.{apply,bind,call}(…)` isMethodCall(callExpression, { - names: ['apply', 'bind', 'call'], + methods: ['apply', 'bind', 'call'], optionalCall: false, optionalMember: false, }) diff --git a/test/prefer-prototype-methods.mjs b/test/prefer-prototype-methods.mjs index a414a04da2..6dadca6953 100644 --- a/test/prefer-prototype-methods.mjs +++ b/test/prefer-prototype-methods.mjs @@ -33,6 +33,9 @@ test.snapshot({ 'foo.bar.bind(bar)', 'foo[{}].call(bar)', 'Object.hasOwn(bar)', + 'const foo = [].push.notApply(bar, elements);', + 'const push = [].push.notBind(foo)', + '[].forEach.notCall(foo, () => {})', ], invalid: [ 'const foo = [].push.apply(bar, elements);',