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

babel-plugin-react-display-name

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.0.3 to 2.0.0

38

lib/index.js

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

});
var _temporalUndefined = {};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _temporalAssertDefined(val, name, undef) { if (val === undef) { throw new ReferenceError(name + " is not defined - temporal dead zone"); } return true; }
var _path = require("path");
var _path2 = _interopRequireDefault(_path);
exports["default"] = function (_ref) {

@@ -18,4 +27,4 @@ var Plugin = _ref.Plugin;

var prop = props[i];
var key = t.toComputedKey(prop);
if (t.isLiteral(key, { value: "displayName" })) {
var key = (_temporalAssertDefined(t, "t", _temporalUndefined) && t).toComputedKey(prop);
if ((_temporalAssertDefined(t, "t", _temporalUndefined) && t).isLiteral(key, { value: "displayName" })) {
safe = false;

@@ -27,3 +36,3 @@ break;

if (safe) {
props.unshift(t.property("init", t.identifier("displayName"), t.literal(id)));
props.unshift((_temporalAssertDefined(t, "t", _temporalUndefined) && t).property("init", (_temporalAssertDefined(t, "t", _temporalUndefined) && t).identifier("displayName"), (_temporalAssertDefined(t, "t", _temporalUndefined) && t).literal(id)));
}

@@ -35,3 +44,3 @@ }

function isCreateClass(node) {
if (!node || !t.isCallExpression(node)) return false;
if (!node || !(_temporalAssertDefined(t, "t", _temporalUndefined) && t).isCallExpression(node)) return false;

@@ -47,3 +56,3 @@ // not React.createClass call member object

var first = args[0];
if (!t.isObjectExpression(first)) return false;
if (!(_temporalAssertDefined(t, "t", _temporalUndefined) && t).isObjectExpression(first)) return false;

@@ -61,3 +70,10 @@ return true;

if (isCreateClass(node.declaration)) {
addDisplayName(file.opts.basename, node.declaration);
var displayName = file.opts.basename;
// ./{module name}/index.js
if (displayName === "index") {
displayName = _path2["default"].basename(_path2["default"].dirname(file.opts.filename));
}
addDisplayName(displayName, node.declaration);
}

@@ -69,9 +85,9 @@ },

if (t.isAssignmentExpression(node)) {
if ((_temporalAssertDefined(t, "t", _temporalUndefined) && t).isAssignmentExpression(node)) {
left = node.left;
right = node.right;
} else if (t.isProperty(node)) {
} else if ((_temporalAssertDefined(t, "t", _temporalUndefined) && t).isProperty(node)) {
left = node.key;
right = node.value;
} else if (t.isVariableDeclarator(node)) {
} else if ((_temporalAssertDefined(t, "t", _temporalUndefined) && t).isVariableDeclarator(node)) {
left = node.id;

@@ -81,7 +97,7 @@ right = node.init;

if (t.isMemberExpression(left)) {
if ((_temporalAssertDefined(t, "t", _temporalUndefined) && t).isMemberExpression(left)) {
left = left.property;
}
if (t.isIdentifier(left) && isCreateClass(right)) {
if ((_temporalAssertDefined(t, "t", _temporalUndefined) && t).isIdentifier(left) && isCreateClass(right)) {
addDisplayName(left.name, right);

@@ -88,0 +104,0 @@ }

{
"name": "babel-plugin-react-display-name",
"version": "1.0.3",
"version": "2.0.0",
"description": "Add displayName to React.createClass calls",

@@ -5,0 +5,0 @@ "repository": "babel-plugins/babel-plugin-react-display-name",

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