Socket
Socket
Sign inDemoInstall

babel-plugin-styled-components

Package Overview
Dependencies
Maintainers
3
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-styled-components - npm Package Compare versions

Comparing version 1.12.1 to 1.13.0-test

27

lib/visitors/displayNameAndId.js

@@ -39,2 +39,14 @@ "use strict";

const existingConfig = getExistingConfig(t)(path);
if (existingConfig && existingConfig.arguments.length && !existingConfig.arguments[0].properties.some(prop => ['displayName', 'componentId'].includes(prop.key.name))) {
existingConfig.arguments[0].properties.push(...withConfigProps);
return;
}
if (path.node.callee && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name == 'withConfig' && path.node.callee.arguments.length && !path.node.callee.arguments[0].properties.some(prop => ['displayName', 'componentId'].includes(prop.key.name))) {
path.node.callee.arguments[0].properties.push(...withConfigProps);
return;
}
if (path.node.tag) {

@@ -48,2 +60,12 @@ // Replace x`...` with x.withConfig({ })`...`

const getExistingConfig = t => path => {
if (path.node.callee && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name == 'withConfig') {
return path.node.callee;
}
if (path.node.callee && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.object && path.node.callee.callee.object.callee && path.node.callee.callee.object.callee.property && path.node.callee.callee.object.callee.property.name === 'withConfig') {
return path.node.callee.callee.object;
}
};
const getBlockName = file => {

@@ -132,3 +154,3 @@ const name = _path.default.basename(file.opts.filename, _path.default.extname(file.opts.filename));

// Prefix the identifier with a character because CSS classes cannot start with a number
return `${(0, _options.useNamespace)(state)}${(0, _prefixDigit.default)(getFileHash(state))}-${getNextId(state)}`;
return `${(0, _options.useNamespace)(state)}sc-${getFileHash(state)}-${getNextId(state)}`;
};

@@ -141,3 +163,4 @@

(0, _detectors.isStyled)(t)(path.node.callee, state) && !t.isMemberExpression(path.node.callee.callee) || // styled(x).attrs()({})
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name !== 'withConfig') {
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name !== 'withConfig' || // styled(x).withConfig({})
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name == 'withConfig' && !path.node.callee.arguments[0].properties.some(prop => ['displayName', 'componentId'].includes(prop.key.name))) {
const displayName = (0, _options.useDisplayName)(state) && getDisplayName(t)(path, (0, _options.useFileName)(state) && state);

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

4

lib/visitors/transpileCssProp.js

@@ -164,7 +164,7 @@ "use strict";

while (!t.isProgram(parent.parentPath)) {
while (!t.isProgram(parent)) {
parent = parent.parentPath;
}
injector = nodeToInsert => parent.insertBefore(nodeToInsert);
injector = nodeToInsert => parent.pushContainer('body', nodeToInsert);
}

@@ -171,0 +171,0 @@

{
"version": "1.12.1",
"version": "1.13.0-test",
"name": "babel-plugin-styled-components",

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

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