Skip to content

Commit

Permalink
Do not check LogicalExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 24, 2020
1 parent 705ada0 commit 97d4fb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rules/prefer-array-some.js
Expand Up @@ -19,7 +19,7 @@ const arrayFindCallSelector = methodSelector({
const create = context => {
return {
[arrayFindCallSelector](node) {
if (isBooleanNode(node) || node.parent.type === 'LogicalExpression') {
if (isBooleanNode(node)) {
node = node.callee.property;
context.report({
node,
Expand Down
7 changes: 4 additions & 3 deletions test/prefer-array-some.js
Expand Up @@ -24,6 +24,7 @@ test({
valid: [
// Not `boolean`
'const bar = foo.find(fn)',
'const bar = foo.find(fn) || baz',

// Not matched `CallExpression`
...[
Expand Down Expand Up @@ -65,10 +66,10 @@ test({
suggestionOutput: 'console.log(foo /* comment 1 */ . /* comment 2 */ some /* comment 3 */ (fn) ? a : b)'
}),
// This should not be reported, but `jQuery.find()` is always `truly`,
// It should not use in a LogicalExpression
// It should not use as a boolean
invalidCase({
code: 'const el = anotherElement || jQuery.find(".outer > div");',
suggestionOutput: 'const el = anotherElement || jQuery.some(".outer > div");'
code: 'if (jQuery.find(".outer > div")) {}',
suggestionOutput: 'if (jQuery.some(".outer > div")) {}'
}),
// Actual messages
{
Expand Down

0 comments on commit 97d4fb5

Please sign in to comment.