no-loop-func
Configuration
rslint.config.ts
Disallow function declarations that contain unsafe references inside loop statements.
Rule Details
This is the TypeScript-aware version of the ESLint no-loop-func rule. It reports any function created inside a loop body that closes over a variable that may be modified across iterations, which typically indicates a mistake — every closure ends up reading the final value of the variable instead of the value at the time the closure was created.
Type-only references (used as TypeScript type annotations) are not flagged, because they have no runtime impact.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
When Not To Use It
If you do not want to be notified about functions defined inside loops, you can safely disable this rule.