UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

16 lines (15 loc) 543 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'; } const sizeAttr = node.openingElement.attributes.find(a => a.type === 'JSXAttribute' && a.name.name === 'size'); if (!sizeAttr) { return 'medium'; } return getStaticAttributeValue(sizeAttr); }