no-loop-func
Configuration
rslint.config.ts
Disallow function declarations that contain unsafe references inside loop statements.
Rule Details
Writing functions within loops tends to result in errors due to the way the function creates a closure around the loop. For example:
Generally speaking, it is safer to keep the closure code outside of the loop, or to use let / const for loop variables so each iteration produces a fresh binding.
This rule disallows any function within a loop that contains unsafe references (e.g. to modified variables).
Examples of incorrect code for this rule:
Examples of correct code for this rule: