@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
23 lines (22 loc) • 735 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getIconSize = getIconSize;
var _eslintCodemodUtils = require("eslint-codemod-utils");
var _getStaticAttributeValue = require("./get-static-attribute-value");
/**
* Returns the static `size` prop value, defaulting to 'medium' if not present.
*/
function getIconSize(node) {
if (!(0, _eslintCodemodUtils.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 (0, _getStaticAttributeValue.getStaticAttributeValue)(sizeAttr);
}