Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/src/rules/no-loop-func.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,20 @@ for (var i = 0; i < 5; i++) {
```

:::

## Known Limitations

The rule cannot identify whether the function instance is just immediately invoked and then discarded, or possibly stored for later use.

```js
const foo = [1, 2, 3, 4];
var i = 0;

while(foo.some(e => e > i)){
i += 1;
}
```

Here the `some` method immediately executes the callback function for each element in the array and then discards the function instance. The function is not stored or reused beyond the scope of the loop iteration. So, this will work as intended.

`eslint-disable` comments can be used in such cases.
Loading