UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

18 lines 538 B
/** * This will search first matched identifier in same and parent scopes. * Returns first matched identifer otherwise null. */ export function findIdentifierInParentScope({ scope, identifierName }) { let traversingScope = scope; while (traversingScope && traversingScope.type !== 'global') { const matchedVariable = traversingScope.variables.find(variable => variable.name === identifierName); if (matchedVariable) { return matchedVariable; } traversingScope = traversingScope.upper; } return null; }