-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Closed
Copy link
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusiondocumentationRelates to ESLint's documentationRelates to ESLint's documentationrepro:yesIssues with a reproducible exampleIssues with a reproducible exampleruleRelates to ESLint's core rulesRelates to ESLint's core rules
Description
Environment
Node version: v22.11.0
npm version: v10.9.0
Local ESLint version: v9.14.0 (Currently used)
Global ESLint version: Not found
Operating System: linux 6.8.0-48-generic
What parser are you using?
Default (Espree)
What did you do?
Configuration
export default [{rules: {"no-loop-func": 2}}];
const array = [5, 7, 8, 3];
let idx = 0;
while(array.some(elm => elm > idx))
idx += 1;
What did you expect to happen?
No error reported as there are no unsafe references.
What actually happened?
An error was reported, citing the arrow function inside the condition of the while statement.
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Additional comments
Functions inside of the condition are evaluated once per loop and are thus safe to reference variables that are modified. This is a false positive.
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusiondocumentationRelates to ESLint's documentationRelates to ESLint's documentationrepro:yesIssues with a reproducible exampleIssues with a reproducible exampleruleRelates to ESLint's core rulesRelates to ESLint's core rules
Type
Projects
Status
Complete