Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-emotion-rename

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-emotion-rename - npm Package Compare versions

Comparing version 1.0.0-beta.24 to 1.0.0-beta.25

55

lib/index.js

@@ -45,2 +45,3 @@ "use strict";

var ALL_CSS_NAMES = {};
var hasEmotionImport = false;
var emotionStyledImportDeclaration = buildImportEmotionStyled();

@@ -147,2 +148,6 @@ var emotionReactImportDeclaration = buildImportEmotionReact();

var _path$node$body, _path$node$body2, _path$node$body2$tag;
if (!hasEmotionImport) {
return;
}
/**

@@ -155,3 +160,5 @@ * Collects all emotion `css` calls

MAP_CSS_LIST[cssVarName] = {
path: path
path: path,
_type: "afne",
name: cssVarName
};

@@ -162,2 +169,6 @@ }

var _path$parent$id2, _path$scope$block$bod, _path$scope$block$bod2, _path$scope$block$bod3, _path$scope$block$bod4, _path$scope$block$bod5, _path$scope$block$bod6, _path$scope$block$bod7, _path$scope$block$bod8, _path$scope$block$bod9, _path$scope$block$bod10, _path$scope$block$bod11;
if (!hasEmotionImport) {
return;
}
/**

@@ -173,3 +184,5 @@ * Collects all emotion `css` calls

MAP_CSS_LIST[cssVarName] = {
path: path
path: path,
_type: "fne",
name: cssVarName
};

@@ -183,3 +196,5 @@ }

MAP_CSS_LIST[cssVarName] = {
path: path
path: path,
_type: "fne",
name: cssVarName
};

@@ -190,2 +205,5 @@ }

var _path$node, _path$node$tag, _path$node$tag$object;
if (!hasEmotionImport) {
return;
}
if (((_path$node = path.node) === null || _path$node === void 0 ? void 0 : (_path$node$tag = _path$node.tag) === null || _path$node$tag === void 0 ? void 0 : _path$node$tag.name) === CSS_LOCAL_NAME) {

@@ -207,3 +225,4 @@ var _path$parentPath, _path$parentPath$scop, _path$parentPath$scop2, _path$parentPath$scop3, _path$parentPath$scop4;

path: path,
_type: "tte"
_type: "tte",
name: taggedCssVarName
};

@@ -237,4 +256,6 @@ ALL_CSS_NAMES[taggedCssVarName] = taggedMap;

path.node.source = t.stringLiteral("@emotion/css");
hasEmotionImport = true;
} else if (importPackageName === "react-emotion" || importPackageName == "emotion") {
var _path$node$specifiers, _path$node$specifiers2, _styledDefaultNode$lo;
hasEmotionImport = true;
var cssLocalName = (_path$node$specifiers = path.node.specifiers.find(function (s) {

@@ -298,3 +319,17 @@ var _s$imported;

CallExpression: function CallExpression(path) {
var node = path.node;
var isRequire = node.callee.name === "require" && node.arguments && node.arguments.length === 1 && t.isStringLiteral(node.arguments[0]);
var requiredPkg = isRequire ? node.arguments[0].value : "";
if (isRequire && /^(react-)?emotion$/.test(requiredPkg)) {
hasEmotionImport = true;
}
/**
* Skip files with no emotion/react-emotion import at all
*/
if (!hasEmotionImport) {
return;
}
/**
* Collect all styled's arguments with form of styled(a, b, c, ...)

@@ -341,6 +376,7 @@ */

if (((_path$parent3 = path.parent) === null || _path$parent3 === void 0 ? void 0 : (_path$parent3$id = _path$parent3.id) === null || _path$parent3$id === void 0 ? void 0 : _path$parent3$id.type) === "Identifier") {
var _path$parent4, _path$parent4$id;
var _path$parent4, _path$parent4$id, _path$parent5, _path$parent5$id;
MAP_CSS_LIST[(_path$parent4 = path.parent) === null || _path$parent4 === void 0 ? void 0 : (_path$parent4$id = _path$parent4.id) === null || _path$parent4$id === void 0 ? void 0 : _path$parent4$id.name] = {
_type: "callee",
path: path
path: path,
name: (_path$parent5 = path.parent) === null || _path$parent5 === void 0 ? void 0 : (_path$parent5$id = _path$parent5.id) === null || _path$parent5$id === void 0 ? void 0 : _path$parent5$id.name
};

@@ -354,5 +390,2 @@ }

*/
var node = path.node;
var isRequire = node.callee.name === "require" && node.arguments && node.arguments.length === 1 && t.isStringLiteral(node.arguments[0]);
var requiredPkg = node.arguments[0].value;
if (!isRequire || !/^(react-)?emotion$/.test(requiredPkg)) {

@@ -363,4 +396,4 @@ return;

if (requiredPkg === "react-emotion") {
var _path$parent5, _path$parent5$id, _path$parentPath5, _path$parentPath5$par, _path$parentPath5$par2;
if ((path === null || path === void 0 ? void 0 : (_path$parent5 = path.parent) === null || _path$parent5 === void 0 ? void 0 : (_path$parent5$id = _path$parent5.id) === null || _path$parent5$id === void 0 ? void 0 : _path$parent5$id.name) === STYLED_LOCAL_NAME) {
var _path$parent6, _path$parent6$id, _path$parentPath5, _path$parentPath5$par, _path$parentPath5$par2;
if ((path === null || path === void 0 ? void 0 : (_path$parent6 = path.parent) === null || _path$parent6 === void 0 ? void 0 : (_path$parent6$id = _path$parent6.id) === null || _path$parent6$id === void 0 ? void 0 : _path$parent6$id.name) === STYLED_LOCAL_NAME) {
path.node.arguments = [t.stringLiteral("@emotion/styled")];

@@ -367,0 +400,0 @@ return;

2

package.json
{
"name": "babel-plugin-emotion-rename",
"version": "1.0.0-beta.24",
"version": "1.0.0-beta.25",
"description": "Babel plugin to rename old Emotion 9 import to new Emotion 10+ import",

@@ -5,0 +5,0 @@ "main": "lib/index",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc