title: "ESLint no-loop-func rule" What to do when loop variables are required in a callback
body: <p>The company where I work for requires us to follow the no-loop-func ES-lint rule. I am in a situation where a loop variable is required in a callback. </p>
  
  <p>An example can be found bellow:</p>
  
  <pre class="lang-js prettyprint-override"><code>var itemsProcessed = 0;
  for (var index = 0; index &lt; uniqueIdentifiers.length; index++) {
    let uniqueIdentifier = uniqueIdentifiers[index];
  
    // ESLint: Don't make functions within a loop (no-loop-func)
    var removeFileReferenceCallback = function (removeReferenceError) {
      if (removeReferenceError !== null) {
        NotificationSystem.logReferenceNotRemoved(uniqueIdentifier, undefined);
      }
  
      // When all items are removed, use the callback
      if (++itemsProcessed === uniqueIdentifiers.length) {
        callback(null);
      }
    };
  
    // Remove the reference
    this.database.removeFileReference(uniqueIdentifier, removeFileReferenceCallback);
  }
  </code></pre>
  
  <p>How can the code be refactored so that the rule can be met?</p>