Skip to content

Commit 7af9a6f

Browse files
authored
no-array-callback-reference: Ignore jQuery methods (#1457)
1 parent 153eb2c commit 7af9a6f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

rules/no-array-callback-reference.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ const ignoredCallee = [
8282
'Async',
8383
'async',
8484
'this',
85+
'$',
86+
'jQuery',
8587
];
8688

8789
function getProblem(context, node, method, options) {
@@ -164,6 +166,10 @@ const create = context => {
164166
return;
165167
}
166168

169+
if (node.callee.object.type === 'CallExpression' && isNodeMatches(node.callee.object.callee, ignoredCallee)) {
170+
return;
171+
}
172+
167173
const [iterator] = node.arguments;
168174
return getProblem(context, iterator, method, options, sourceCode);
169175
};

test/no-array-callback-reference.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ test({
8686
'Children.forEach(children, fn)', // `import {Children} from 'react';`
8787
'Vue.filter(name, fn)',
8888

89+
// #1376
90+
'$(this).find(tooltip)',
91+
'$.map(realArray, function(value, index) {});',
92+
'$(this).filter(tooltip)',
93+
'jQuery(this).find(tooltip)',
94+
'jQuery.map(realArray, function(value, index) {});',
95+
'jQuery(this).filter(tooltip)',
96+
8997
// First argument is not a function
9098
...notFunctionTypes.map(data => `foo.map(${data})`),
9199

0 commit comments

Comments
 (0)