MCPcopy
hub / github.com/TanStack/query / getExternalRefs

Function getExternalRefs

packages/eslint-plugin-query/src/utils/ast-utils.ts:183–219  ·  view source on GitHub ↗
(params: {
    scopeManager: TSESLint.Scope.ScopeManager
    sourceCode: Readonly<TSESLint.SourceCode>
    node: TSESTree.Node
  })

Source from the content-addressed store, hash-verified

181 return scope.set.has(reference.identifier.name)
182 },
183 getExternalRefs(params: {
184 scopeManager: TSESLint.Scope.ScopeManager
185 sourceCode: Readonly<TSESLint.SourceCode>
186 node: TSESTree.Node
187 }): Array<TSESLint.Scope.Reference> {
188 const { scopeManager, sourceCode, node } = params
189 const scope = scopeManager.acquire(node)
190
191 if (scope === null) {
192 return []
193 }
194
195 const references = scope.references
196 .filter((x) => x.isRead() && !scope.set.has(x.identifier.name))
197 .map((x) => {
198 const referenceNode = ASTUtils.traverseUpOnly(x.identifier, [
199 AST_NODE_TYPES.MemberExpression,
200 AST_NODE_TYPES.Identifier,
201 ])
202
203 return {
204 variable: x,
205 node: referenceNode,
206 text: sourceCode.getText(referenceNode),
207 }
208 })
209
210 const localRefIds = new Set(
211 [...scope.set.values()].map((x) => sourceCode.getText(x.identifiers[0])),
212 )
213
214 const externalRefs = references.filter(
215 (x) => x.variable.resolved === null || !localRefIds.has(x.text),
216 )
217
218 return uniqueBy(externalRefs, (x) => x.text).map((x) => x.variable)
219 },
220 mapKeyNodeToText(
221 node: TSESTree.Node,
222 sourceCode: Readonly<TSESLint.SourceCode>,

Callers

nothing calls this directly

Calls 1

uniqueByFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…