babel-plugin-emotion
Advanced tools
Comparing version 10.0.7 to 10.0.8
{ | ||
"name": "babel-plugin-emotion", | ||
"version": "10.0.7", | ||
"version": "10.0.8", | ||
"description": "A recommended babel preprocessing plugin for emotion, The Next Generation of CSS-in-JS.", | ||
@@ -15,3 +15,3 @@ "main": "dist/babel-plugin-emotion.cjs.js", | ||
"@emotion/memoize": "0.7.1", | ||
"@emotion/serialize": "^0.11.4", | ||
"@emotion/serialize": "^0.11.5", | ||
"babel-plugin-macros": "^2.0.0", | ||
@@ -18,0 +18,0 @@ "babel-plugin-syntax-jsx": "^6.18.0", |
@@ -38,6 +38,41 @@ // @flow | ||
let pascalCaseRegex = /^[A-Z][A-Za-z]+/ | ||
function getDeclaratorName(path, t) { | ||
// $FlowFixMe | ||
const parent = path.findParent(p => p.isVariableDeclarator()) | ||
return parent && t.isIdentifier(parent.node.id) ? parent.node.id.name : '' | ||
const parent = path.findParent( | ||
p => | ||
p.isVariableDeclarator() || | ||
p.isFunctionDeclaration() || | ||
p.isFunctionExpression() || | ||
p.isArrowFunctionExpression() | ||
) | ||
if (!parent) { | ||
return '' | ||
} | ||
if (parent.isVariableDeclarator()) { | ||
// we probably have a css call assigned to a variable | ||
// so we'll just return the variable name | ||
return parent.node.id.name | ||
} | ||
// we probably have an inline css prop usage | ||
if (parent.isFunctionDeclaration()) { | ||
let { name } = parent.node.id | ||
if (pascalCaseRegex.test(name)) { | ||
return name | ||
} | ||
return '' | ||
} | ||
let variableDeclarator = path.findParent(p => p.isVariableDeclarator()) | ||
if (!variableDeclarator) { | ||
return '' | ||
} | ||
let { name } = variableDeclarator.node.id | ||
if (pascalCaseRegex.test(name)) { | ||
return name | ||
} | ||
return '' | ||
} | ||
@@ -44,0 +79,0 @@ |
100925
2623
Updated@emotion/serialize@^0.11.5