UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

18 lines (17 loc) 567 B
import { isNodeOfType } from 'eslint-codemod-utils'; import { getStaticAttributeValue } from './get-static-attribute-value'; /** * Returns the static `size` prop value, defaulting to 'medium' if not present. */ export function getIconSize(node) { if (!isNodeOfType(node.openingElement, 'JSXOpeningElement')) { return 'medium'; } var sizeAttr = node.openingElement.attributes.find(function (a) { return a.type === 'JSXAttribute' && a.name.name === 'size'; }); if (!sizeAttr) { return 'medium'; } return getStaticAttributeValue(sizeAttr); }