Socket
Socket
Sign inDemoInstall

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.5 to 1.0.0-beta.6

43

lib/index.js

@@ -24,7 +24,14 @@ "use strict";

function getStyled(path) {
if (!path.node.source.value === "react-emotion") {
return {
hasStyled: [],
nonStyled: []
};
}
var hasStyled = path.node.specifiers.filter(function (s) {
return s.local.name === "styled";
return s.type === "ImportDefaultSpecifier";
});
var nonStyled = path.node.specifiers.filter(function (s) {
return s.local.name !== "styled";
return s.type !== "ImportDefaultSpecifier";
});

@@ -39,2 +46,4 @@ return {

var buildImportEmotionReact = (0, _template["default"])("\n import { css as css2 } from '@emotion/react';\n");
var CSS_LOCAL_NAME = "css";
var STYLED_LOCAL_NAME = "styled";
var REP = [{

@@ -95,3 +104,3 @@ replacement: "@emotion/css",

}
}); // console.log(">>>", filterTags, MAP_STYLED_VARS);
}); // console.log(">>>11", cssList, MAP_STYLED_VARS);

@@ -109,3 +118,3 @@ if (filterTags.length) {

*/
if (((_path$scope$block$bod = path.scope.block.body) === null || _path$scope$block$bod === void 0 ? void 0 : (_path$scope$block$bod2 = _path$scope$block$bod.body[0]) === null || _path$scope$block$bod2 === void 0 ? void 0 : (_path$scope$block$bod3 = _path$scope$block$bod2.argument) === null || _path$scope$block$bod3 === void 0 ? void 0 : _path$scope$block$bod3.type) === "TaggedTemplateExpression" && ((_path$scope$block$bod4 = path.scope.block.body) === null || _path$scope$block$bod4 === void 0 ? void 0 : (_path$scope$block$bod5 = _path$scope$block$bod4.body[0]) === null || _path$scope$block$bod5 === void 0 ? void 0 : (_path$scope$block$bod6 = _path$scope$block$bod5.argument) === null || _path$scope$block$bod6 === void 0 ? void 0 : (_path$scope$block$bod7 = _path$scope$block$bod6.tag) === null || _path$scope$block$bod7 === void 0 ? void 0 : _path$scope$block$bod7.name) === "css") {
if (((_path$scope$block$bod = path.scope.block.body) === null || _path$scope$block$bod === void 0 ? void 0 : (_path$scope$block$bod2 = _path$scope$block$bod.body[0]) === null || _path$scope$block$bod2 === void 0 ? void 0 : (_path$scope$block$bod3 = _path$scope$block$bod2.argument) === null || _path$scope$block$bod3 === void 0 ? void 0 : _path$scope$block$bod3.type) === "TaggedTemplateExpression" && ((_path$scope$block$bod4 = path.scope.block.body) === null || _path$scope$block$bod4 === void 0 ? void 0 : (_path$scope$block$bod5 = _path$scope$block$bod4.body[0]) === null || _path$scope$block$bod5 === void 0 ? void 0 : (_path$scope$block$bod6 = _path$scope$block$bod5.argument) === null || _path$scope$block$bod6 === void 0 ? void 0 : (_path$scope$block$bod7 = _path$scope$block$bod6.tag) === null || _path$scope$block$bod7 === void 0 ? void 0 : _path$scope$block$bod7.name) === CSS_LOCAL_NAME) {
var _path$parent$id;

@@ -122,3 +131,3 @@

if (((_path$node$tag$object = path.node.tag.object) === null || _path$node$tag$object === void 0 ? void 0 : _path$node$tag$object.name) === "styled") {
if (((_path$node$tag$object = path.node.tag.object) === null || _path$node$tag$object === void 0 ? void 0 : _path$node$tag$object.name) === STYLED_LOCAL_NAME) {
var templateVars = path.node.quasi.expressions.map(function (exp) {

@@ -136,2 +145,24 @@ return exp.name;

ImportDeclaration: function ImportDeclaration(path, state) {
if (path.node.source.value === "react-emotion") {
var _path$node$specifiers, _path$node$specifiers2, _styledDefaultNode$lo;
var cssLocalName = (_path$node$specifiers = path.node.specifiers.find(function (s) {
var _s$imported;
return ((_s$imported = s.imported) === null || _s$imported === void 0 ? void 0 : _s$imported.name) === "css";
})) === null || _path$node$specifiers === void 0 ? void 0 : (_path$node$specifiers2 = _path$node$specifiers.local) === null || _path$node$specifiers2 === void 0 ? void 0 : _path$node$specifiers2.name;
var styledDefaultNode = path.node.specifiers.find(function (s) {
return s.type === "ImportDefaultSpecifier";
});
var styledLocalName = (_styledDefaultNode$lo = styledDefaultNode.local) === null || _styledDefaultNode$lo === void 0 ? void 0 : _styledDefaultNode$lo.name;
CSS_LOCAL_NAME = cssLocalName || "css";
STYLED_LOCAL_NAME = styledLocalName || "styled";
} else if (path.node.source.value === "@emotion/styled") {
var _styledDefaultNode = path.node.specifiers.find(function (s) {
return s.type === "ImportDefaultSpecifier";
});
_styledDefaultNode.local.name = STYLED_LOCAL_NAME;
}
var _getStyled = getStyled(path),

@@ -143,3 +174,3 @@ hasStyled = _getStyled.hasStyled,

path.node.specifiers = path.node.specifiers.filter(function (s) {
return s.local.name !== "styled";
return s.type !== "ImportDefaultSpecifier";
});

@@ -146,0 +177,0 @@ }

2

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

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

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