@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
19 lines • 609 B
JavaScript
/**
* This will search first matched identifier in same and parent scopes.
* Returns first matched identifer otherwise null.
*/
export function findIdentifierInParentScope(_ref) {
var scope = _ref.scope,
identifierName = _ref.identifierName;
var traversingScope = scope;
while (traversingScope && traversingScope.type !== 'global') {
var matchedVariable = traversingScope.variables.find(function (variable) {
return variable.name === identifierName;
});
if (matchedVariable) {
return matchedVariable;
}
traversingScope = traversingScope.upper;
}
return null;
}