Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const transformCssCallExpression = ({ babel, state, path }: *) => {
let t = babel.types
let sourceMap = ''
if (t.isTaggedTemplateExpression(path)) {
const expressions = getExpressionsFromTemplateLiteral(path.node.quasi, t)
if (state.emotionSourceMap && path.node.quasi.loc !== undefined) {
sourceMap = getSourceMap(path.node.quasi.loc.start, state)
}
path.replaceWith(t.callExpression(path.node.tag, expressions))
}
if (t.isCallExpression(path)) {
const label = getLabelFromPath(path, t)
let isPure = true
path.get('arguments').forEach(node => {
if (!node.isPure()) {
isPure = false
}
if (t.isObjectExpression(node)) {
node.replaceWith(simplifyObject(node.node, t))
}
})
if (label) {
appendStringToExpressions(path.node.arguments, `label:${label};`, t)
}
if (state.emotionSourceMap) {
sourceMap = getSourceMap(styledCallPath.node.quasi.loc.start, state)
}
styledCallPath.replaceWith(
t.callExpression(styledCallPath.node.tag, expressions)
)
}
}
if (t.isCallExpression(reference.parentPath)) {
reference.parentPath.node.arguments[1] = t.objectExpression([
t.objectProperty(
t.identifier('target'),
t.stringLiteral(getTargetClassName(state, t))
),
t.objectProperty(
t.identifier('label'),
t.stringLiteral(getLabelFromPath(reference.parentPath, t))
)
])
}
if (t.isCallExpression(reference.parentPath.parentPath)) {
if (state.emotionSourceMap) {
if (
!sourceMap &&
reference.parentPath.parentPath.node.loc !== undefined
) {
sourceMap = getSourceMap(
reference.parentPath.parentPath.node.loc.start,
state
)
}
appendStringToExpressions(