code: function getEnclosingFunctionScope(scope) {
      let currentScope = scope;
  
      while (currentScope.type !== "function" && currentScope.type !== "global") {
          currentScope = currentScope.upper;
      }
      return currentScope;
  }
docs: Finds the nearest function scope or global scope walking up the scope
  hierarchy.
  
  @param {eslint-scope.Scope} scope - The scope to traverse.
  @returns {eslint-scope.Scope} a function scope or global scope containing the given
  scope.