Skip to content
1 min read · 107 words

Function: collectImportBindings() ​

ts
function collectImportBindings(ast: Program): ImportBindings;

Defined in: src/eslint/rules/common.ts:105

Collects the file's import bindings, so resolveCalleeName can map a local callee name to the export it denotes.

Parameters ​

ParameterType
astProgram

Returns ​

ImportBindings

Remarks ​

Call once at the top of a rule's Program() visitor and keep the result in the rule's closure — ESLint walks the AST depth-first, so a call can lexically precede its own import statement. A later import of the same local name overwrites the earlier one; imports in one scope cannot legally collide, so this only ever resolves a genuine redeclaration.