8000 docs: add limitation section in `no-loop-func` (#19287) · eslint/eslint@eff7c57 · GitHub
[go: up one dir, main page]

Skip to content

Commit eff7c57

Browse files
docs: add limitation section in no-loop-func (#19287)
* docs: add limitation in no-loop-func * fix heading
1 parent 8efc2d0 commit eff7c57

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/src/rules/no-loop-func.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,20 @@ for (var i = 0; i < 5; i++) {
140140
```
141141

142142
:::
143+
144+
## Known Limitations
145+
146+
The rule cannot identify whether the function instance is just immediately invoked and then discarded, or possibly stored for later use.
147+
148+
```js
149+
const foo = [1, 2, 3, 4];
150+
var i = 0;
151+
152+
while(foo.some(e => e > i)){
153+
i += 1;
154+
}
155+
```
156+
157+
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.
158+
159+
`eslint-disable` comments can be used in such cases.

0 commit comments

Comments
 (0)
0