diff --git a/rules/prefer-array-some.js b/rules/prefer-array-some.js index 5465290aa9..d738ad47fe 100644 --- a/rules/prefer-array-some.js +++ b/rules/prefer-array-some.js @@ -3,6 +3,7 @@ const {methodCallSelector, matches, memberExpressionSelector} = require('./selec const {checkVueTemplate} = require('./utils/rule.js'); const {isBooleanNode} = require('./utils/boolean.js'); const {getParenthesizedRange} = require('./utils/parentheses.js'); +const {isNodeValueNotFunction} = require('./utils/index.js'); const {removeMemberExpressionProperty} = require('./fix/index.js'); const {isLiteral, isUndefined} = require('./ast/index.js'); @@ -94,6 +95,11 @@ const create = context => ({ }; }, [arrayFilterCallSelector](filterCall) { + const [firstArgument] = filterCall.arguments; + if (!firstArgument || isNodeValueNotFunction(firstArgument)) { + return; + } + const filterProperty = filterCall.callee.property; return { node: filterProperty, diff --git a/test/prefer-array-some.mjs b/test/prefer-array-some.mjs index c379001a50..4c8f288758 100644 --- a/test/prefer-array-some.mjs +++ b/test/prefer-array-some.mjs @@ -183,6 +183,9 @@ test.snapshot({ 'array?.filter(fn).length > 0', 'array.notFilter(fn).length > 0', 'array.filter.length > 0', + + // `jQuery#filter` + '$element.filter(":visible").length > 0', ], invalid: [ 'array.filter(fn).length > 0',