Socket
Socket
Sign inDemoInstall

babel-plugin-styled-components

Package Overview
Dependencies
77
Maintainers
3
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.1 to 1.7.2

lib/visitors/transpileCssProp.js

37

lib/index.js

@@ -8,2 +8,4 @@ "use strict";

var _pluginSyntaxJsx = _interopRequireDefault(require("@babel/plugin-syntax-jsx"));
var _pure = _interopRequireDefault(require("./visitors/pure"));

@@ -19,8 +21,43 @@

var _transpileCssProp = _interopRequireDefault(require("./visitors/transpileCssProp"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _default(_ref) {
var t = _ref.types;
return {
inherits: _pluginSyntaxJsx.default,
visitor: {
// These visitors insert newly generated code and missing import/require statements
Program: {
enter(path, state) {
state.required = false;
state.items = [];
},
exit(path, state) {
var _path$node$body;
(_path$node$body = path.node.body).push.apply(_path$node$body, _toConsumableArray(state.items));
}
},
JSXAttribute(path, state) {
(0, _transpileCssProp.default)(t)(path, state);
},
CallExpression(path, state) {
(0, _displayNameAndId.default)(t)(path, state);
(0, _pure.default)(t)(path, state);
},
TaggedTemplateExpression(path, state) {

@@ -27,0 +64,0 @@ (0, _minify.default)(t)(path, state);

10

lib/utils/options.js

@@ -6,3 +6,3 @@ "use strict";

});
exports.usePureAnnotation = exports.useTranspileTemplateLiterals = exports.useMinify = exports.useFileName = exports.useSSR = exports.useDisplayName = void 0;
exports.useCssProp = exports.usePureAnnotation = exports.useTranspileTemplateLiterals = exports.useMinify = exports.useFileName = exports.useSSR = exports.useDisplayName = void 0;

@@ -49,2 +49,8 @@ function getOption(_ref, name) {

exports.usePureAnnotation = usePureAnnotation;
exports.usePureAnnotation = usePureAnnotation;
var useCssProp = function useCssProp(state) {
return getOption(state, 'cssProp', true);
};
exports.useCssProp = useCssProp;

12

lib/visitors/displayNameAndId.js

@@ -38,6 +38,10 @@ "use strict";

withConfigProps.push(t.objectProperty(t.identifier('componentId'), t.stringLiteral(componentId)));
} // Replace x`...` with x.withConfig({ })`...`
}
path.node.tag = t.callExpression(t.memberExpression(path.node.tag, t.identifier('withConfig')), [t.objectExpression(withConfigProps)]);
if (path.node.tag) {
// Replace x`...` with x.withConfig({ })`...`
path.node.tag = t.callExpression(t.memberExpression(path.node.tag, t.identifier('withConfig')), [t.objectExpression(withConfigProps)]);
} else {
path.replaceWith(t.callExpression(t.callExpression(t.memberExpression(path.node.callee, t.identifier('withConfig')), [t.objectExpression(withConfigProps)]), path.node.arguments));
}
};

@@ -132,3 +136,3 @@ };

return function (path, state) {
if ((0, _detectors.isStyled)(t)(path.node.tag, state)) {
if (path.node.tag ? (0, _detectors.isStyled)(t)(path.node.tag, state) : (0, _detectors.isStyled)(t)(path.node.callee, state) && path.node.callee.property && path.node.callee.property.name !== 'withConfig') {
var displayName = (0, _options.useDisplayName)(state) && getDisplayName(t)(path, (0, _options.useFileName)(state) && state);

@@ -135,0 +139,0 @@ addConfig(t)(path, displayName && displayName.replace(/[^_a-zA-Z0-9-]/g, ''), (0, _options.useSSR)(state) && getComponentId(state));

@@ -19,4 +19,4 @@ "use strict";

if ((0, _options.usePureAnnotation)(state)) {
if ((0, _detectors.isStyled)(path.node, state) || (0, _detectors.isStyled)(path.node.callee, state) || (0, _detectors.isPureHelper)(path.node.callee, state)) {
if (path.parent.type == 'VariableDeclarator' || path.parent.type == 'TaggedTemplateExpression') {
if ((0, _detectors.isStyled)(t)(path.node, state) || (0, _detectors.isStyled)(t)(path.node.callee, state) || (0, _detectors.isPureHelper)(t)(path.node.tag || path.node.callee, state)) {
if (path.parent.type === 'VariableDeclarator' || path.parent.type === 'TaggedTemplateExpression') {
(0, _helperAnnotateAsPure.default)(path);

@@ -23,0 +23,0 @@ }

{
"version": "1.7.1",
"version": "1.7.2",
"name": "babel-plugin-styled-components",

@@ -30,2 +30,3 @@ "description": "Improve the debugging experience and add server-side rendering support to styled-components",

"@babel/helper-annotate-as-pure": "^7.0.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"lodash": "^4.17.10"

@@ -32,0 +33,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc