Skip to content

Commit

Permalink
no-array-callback-reference: Ignore jQuery methods (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovalov committed Aug 2, 2021
1 parent 153eb2c commit 7af9a6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rules/no-array-callback-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const ignoredCallee = [
'Async',
'async',
'this',
'$',
'jQuery',
];

function getProblem(context, node, method, options) {
Expand Down Expand Up @@ -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);
};
Expand Down
8 changes: 8 additions & 0 deletions test/no-array-callback-reference.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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})`),

Expand Down

0 comments on commit 7af9a6f

Please sign in to comment.