Skip to content

Commit

Permalink
no-array-callback-reference: Ignore primitive wrappers in `Array#ma…
Browse files Browse the repository at this point in the history
…p()` (#1642)
  • Loading branch information
fisker committed Dec 17, 2021
1 parent 0866b41 commit 0362c09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 6 additions & 6 deletions rules/no-array-callback-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,10 @@ const iteratorMethods = [
],
[
'flatMap',
{
ignore: [
'Boolean',
],
},
],
[
'forEach', {
'forEach',
{
returnsUndefined: true,
},
],
Expand All @@ -65,7 +61,11 @@ const iteratorMethods = [
{
extraSelector: '[callee.object.name!="types"]',
ignore: [
'String',
'Number',
'BigInt',
'Boolean',
'Symbol',
],
},
],
Expand Down
7 changes: 7 additions & 0 deletions test/no-array-callback-reference.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ test({
...reduceLikeMethods.map(method => `this.${method}(fn)`),

// `Boolean`
'foo.find(Boolean)',

// Primitive wrappers are ignored
'foo.map(String)',
'foo.map(Number)',
'foo.map(BigInt)',
'foo.map(Boolean)',
'foo.map(Symbol)',

// Not `CallExpression`
'new foo.map(fn);',
Expand Down

0 comments on commit 0362c09

Please sign in to comment.