From d9d099d1518ccfcf866a2060572ffc506bacaff5 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Sat, 15 Apr 2023 17:45:43 +0800 Subject: [PATCH] Update no-array-callback-reference.md --- docs/rules/no-array-callback-reference.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/rules/no-array-callback-reference.md b/docs/rules/no-array-callback-reference.md index b031dda61f..7e4a71ca72 100644 --- a/docs/rules/no-array-callback-reference.md +++ b/docs/rules/no-array-callback-reference.md @@ -7,6 +7,8 @@ +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 @@ -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