Skip to content

Commit

Permalink
Update no-array-callback-reference.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Apr 15, 2023
1 parent fb2a2ba commit d9d099d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/rules/no-array-callback-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<!-- end auto-generated rule header -->
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` -->

Passing functions to iterator methods can cause issues when the function is changed without realizing that the iterator passes 2 more parameters to it. **This also applies when using TypeScript,** albeit only if the function accepts the same parameter type used by the iterator method.

Suppose you have a `unicorn` module:

```js
Expand Down Expand Up @@ -37,6 +39,15 @@ const unicorn = require('unicorn');
//=> [2, 3, 5]
```

This rule helps safely call the function with the expected number of parameters:

```js
const unicorn = require('unicorn');

[1, 2, 3].map(x => unicorn(x));
//=> [2, 3, 4]
```

## Fail

```js
Expand Down

0 comments on commit d9d099d

Please sign in to comment.