UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

25 lines (24 loc) 749 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findIdentifierInParentScope = findIdentifierInParentScope; /** * This will search first matched identifier in same and parent scopes. * Returns first matched identifer otherwise null. */ 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; }