New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-react-remove-display-name

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-react-remove-display-name - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

30

lib/index.js

@@ -38,9 +38,19 @@ "use strict";

function isExistsReactComponent(node, reactComponentsSet) {
if (t.isMemberExpression(node) &&
return (t.isMemberExpression(node) &&
t.isIdentifier(node.object) &&
reactComponentsSet.has(node.object.name)) {
return true;
}
return false;
reactComponentsSet.has(node.object.name));
}
function isValidHoc(node, reactComponentsSet) {
return (t.isIdentifier(node.callee) &&
node.callee.name.startsWith('with') &&
node.arguments.some((arg) => {
if (t.isIdentifier(arg) && reactComponentsSet.has(arg.name)) {
return true;
}
else if (t.isCallExpression(arg)) {
return isValidHoc(arg, reactComponentsSet);
}
return false;
}));
}
function displayNameTransform({ template }) {

@@ -80,2 +90,12 @@ const wrapWithEnvCheck = template(`

},
VariableDeclarator(path, state) {
const reactComponentsSet = state.get(stateProp);
if (!t.isIdentifier(path.node.id) ||
path.node.id.name.charAt(0) !== path.node.id.name.charAt(0).toUpperCase() ||
!t.isCallExpression(path.node.init) ||
!isValidHoc(path.node.init, reactComponentsSet)) {
return;
}
reactComponentsSet.add(path.node.id.name);
},
AssignmentExpression(path, state) {

@@ -82,0 +102,0 @@ const { node } = path;

2

package.json
{
"name": "babel-plugin-transform-react-remove-display-name",
"description": "Make React component `displayName` property available only in none production environment during the build",
"version": "1.0.0",
"version": "1.1.0",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "author": "felixmosh",

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