From 7af9a6f1a34bbed9549216f0d7d6dee016dca68b Mon Sep 17 00:00:00 2001 From: Pavel Pustovalov Date: Mon, 2 Aug 2021 11:46:41 +0300 Subject: [PATCH] `no-array-callback-reference`: Ignore jQuery methods (#1457) --- rules/no-array-callback-reference.js | 6 ++++++ test/no-array-callback-reference.mjs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/rules/no-array-callback-reference.js b/rules/no-array-callback-reference.js index cd8040f12e..066dcf00f7 100644 --- a/rules/no-array-callback-reference.js +++ b/rules/no-array-callback-reference.js @@ -82,6 +82,8 @@ const ignoredCallee = [ 'Async', 'async', 'this', + '$', + 'jQuery', ]; function getProblem(context, node, method, options) { @@ -164,6 +166,10 @@ const create = context => { return; } + if (node.callee.object.type === 'CallExpression' && isNodeMatches(node.callee.object.callee, ignoredCallee)) { + return; + } + const [iterator] = node.arguments; return getProblem(context, iterator, method, options, sourceCode); }; diff --git a/test/no-array-callback-reference.mjs b/test/no-array-callback-reference.mjs index a3915fc4d6..274848c5de 100644 --- a/test/no-array-callback-reference.mjs +++ b/test/no-array-callback-reference.mjs @@ -86,6 +86,14 @@ test({ 'Children.forEach(children, fn)', // `import {Children} from 'react';` 'Vue.filter(name, fn)', + // #1376 + '$(this).find(tooltip)', + '$.map(realArray, function(value, index) {});', + '$(this).filter(tooltip)', + 'jQuery(this).find(tooltip)', + 'jQuery.map(realArray, function(value, index) {});', + 'jQuery(this).filter(tooltip)', + // First argument is not a function ...notFunctionTypes.map(data => `foo.map(${data})`),