Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-react-display-name

Package Overview
Dependencies
54
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.21.4-esm.4 to 7.22.5

39

lib/index.js

@@ -1,5 +0,11 @@

import { declare } from "@babel/helper-plugin-utils";
import path from "path";
import { types as t } from "@babel/core";
export default declare(api => {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _path = require("path");
var _core = require("@babel/core");
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);

@@ -11,7 +17,7 @@ function addDisplayName(id, call) {

const prop = props[i];
if (t.isSpreadElement(prop)) {
if (_core.types.isSpreadElement(prop)) {
continue;
}
const key = t.toComputedKey(prop);
if (t.isStringLiteral(key, {
const key = _core.types.toComputedKey(prop);
if (_core.types.isStringLiteral(key, {
value: "displayName"

@@ -24,11 +30,11 @@ })) {

if (safe) {
props.unshift(t.objectProperty(t.identifier("displayName"), t.stringLiteral(id)));
props.unshift(_core.types.objectProperty(_core.types.identifier("displayName"), _core.types.stringLiteral(id)));
}
}
const isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
const isCreateClassAddon = callee => t.isIdentifier(callee, {
const isCreateClassCallExpression = _core.types.buildMatchMemberExpression("React.createClass");
const isCreateClassAddon = callee => _core.types.isIdentifier(callee, {
name: "createReactClass"
});
function isCreateClass(node) {
if (!node || !t.isCallExpression(node)) return false;
if (!node || !_core.types.isCallExpression(node)) return false;
if (!isCreateClassCallExpression(node.callee) && !isCreateClassAddon(node.callee)) {

@@ -40,3 +46,3 @@ return false;

const first = args[0];
if (!t.isObjectExpression(first)) return false;
if (!_core.types.isObjectExpression(first)) return false;
return true;

@@ -52,5 +58,5 @@ }

const filename = state.filename || "unknown";
let displayName = path.basename(filename, path.extname(filename));
let displayName = _path.basename(filename, _path.extname(filename));
if (displayName === "index") {
displayName = path.basename(path.dirname(filename));
displayName = _path.basename(_path.dirname(filename));
}

@@ -79,6 +85,6 @@ addDisplayName(displayName, node.declaration);

if (!id) return;
if (t.isMemberExpression(id)) {
if (_core.types.isMemberExpression(id)) {
id = id.property;
}
if (t.isIdentifier(id)) {
if (_core.types.isIdentifier(id)) {
addDisplayName(id.name, node);

@@ -90,3 +96,4 @@ }

});
exports.default = _default;
//# sourceMappingURL=index.js.map
{
"name": "@babel/plugin-transform-react-display-name",
"version": "7.21.4-esm.4",
"version": "7.22.5",
"description": "Add displayName to React.createClass calls",

@@ -20,10 +20,10 @@ "repository": {

"dependencies": {
"@babel/helper-plugin-utils": "7.21.4-esm.4"
"@babel/helper-plugin-utils": "^7.22.5"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0 || ^7.21.4-esm.2"
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "7.21.4-esm.4",
"@babel/helper-plugin-test-runner": "7.21.4-esm.4"
"@babel/core": "^7.22.5",
"@babel/helper-plugin-test-runner": "^7.22.5"
},

@@ -34,3 +34,3 @@ "engines": {

"author": "The Babel Team (https://babel.dev/team)",
"type": "module"
"type": "commonjs"
}

Sorry, the diff of this file is not supported yet

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