Exception to rule 4327 (no `this` aliasing) for generator functions

Versions: SQ 8.3, scanner 4.3.0, TS plugin 2.1, JS plugin 6.2.1

The subject rule flags all cases where this is assigned to a local variable, to discourage the common pattern of using self or that to refer to the context of a containing scope. I agree that it’s better if at all possible, but it is not possible to define generator functions (containing a yield statement) using arrow syntax, so an alias is required.

const _self = this;
return function*(){
  let curr: IteratorResult<T> = _self.next();
  while (!curr.done) {
    yield f(curr.value);
    curr = _self.next();

The rule should not flag aliases for this if they are referenced inside a generator function.