@atlaskit/eslint-plugin-ui-styling-standard
Version:
The eslint plugin to enforce and educate on Atlassian's UI Styling Standard
23 lines • 949 B
JavaScript
export function walkStyleCallProperties(styleCall, visitor, options) {
const skipTopLevel = !(options !== null && options !== void 0 && options.includeTopLevel) && (styleCall.styleFunction === 'cssMap' || styleCall.styleFunction === 'keyframes');
for (const argument of styleCall.node.arguments) {
if (argument.type === 'ObjectExpression') {
walkStyleObject(argument, visitor, skipTopLevel);
} else if (argument.type === 'ArrowFunctionExpression' && argument.expression && argument.body.type === 'ObjectExpression') {
walkStyleObject(argument.body, visitor, skipTopLevel);
}
}
}
function walkStyleObject(object, visitor, skipVisitor) {
for (const property of object.properties) {
if (property.type !== 'Property') {
continue;
}
if (!skipVisitor) {
visitor(property);
}
if (property.value.type === 'ObjectExpression') {
walkStyleObject(property.value, visitor, false);
}
}
}