Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-react-jsx

Package Overview
Dependencies
Maintainers
6
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-react-jsx - npm Package Compare versions

Comparing version 7.14.5 to 7.14.9

45

lib/create-plugin.js

@@ -80,7 +80,10 @@ "use strict";

const self = _core.types.jsxAttribute(_core.types.jsxIdentifier("__self"), _core.types.jsxExpressionContainer(_core.types.thisExpression()));
const attributes = [];
const source = _core.types.jsxAttribute(_core.types.jsxIdentifier("__source"), _core.types.jsxExpressionContainer(makeSource(path, state)));
if (isThisAllowed(path)) {
attributes.push(_core.types.jsxAttribute(_core.types.jsxIdentifier("__self"), _core.types.jsxExpressionContainer(_core.types.thisExpression())));
}
path.pushContainer("attributes", [self, source]);
attributes.push(_core.types.jsxAttribute(_core.types.jsxIdentifier("__source"), _core.types.jsxExpressionContainer(makeSource(path, state))));
path.pushContainer("attributes", attributes);
}

@@ -220,2 +223,36 @@

function getThisFunctionParent(path) {
let scope = path.scope;
do {
if (scope.path.isFunctionParent() && !scope.path.isArrowFunctionExpression()) {
return scope.path;
}
} while (scope = scope.parent);
return null;
}
function isDerivedClass(classPath) {
return classPath.node.superClass !== null;
}
function isThisAllowed(path) {
const parentMethodOrFunction = getThisFunctionParent(path);
if (parentMethodOrFunction === null) {
return true;
}
if (!parentMethodOrFunction.isMethod()) {
return true;
}
if (parentMethodOrFunction.node.kind !== "constructor") {
return true;
}
return !isDerivedClass(parentMethodOrFunction.parentPath.parentPath);
}
function call(pass, name, args) {

@@ -376,3 +413,3 @@ const node = _core.types.callExpression(get(pass, `id/${name}`)(), args);

args.push((_extracted$key = extracted.key) != null ? _extracted$key : path.scope.buildUndefinedNode(), _core.types.booleanLiteral(children.length > 1), (_extracted$__source = extracted.__source) != null ? _extracted$__source : path.scope.buildUndefinedNode(), (_extracted$__self = extracted.__self) != null ? _extracted$__self : _core.types.thisExpression());
args.push((_extracted$key = extracted.key) != null ? _extracted$key : path.scope.buildUndefinedNode(), _core.types.booleanLiteral(children.length > 1), (_extracted$__source = extracted.__source) != null ? _extracted$__source : path.scope.buildUndefinedNode(), (_extracted$__self = extracted.__self) != null ? _extracted$__self : path.scope.buildUndefinedNode());
} else if (extracted.key !== undefined) {

@@ -379,0 +416,0 @@ args.push(extracted.key);

8

package.json
{
"name": "@babel/plugin-transform-react-jsx",
"version": "7.14.5",
"version": "7.14.9",
"description": "Turn JSX into React function calls",

@@ -24,3 +24,3 @@ "repository": {

"@babel/plugin-syntax-jsx": "^7.14.5",
"@babel/types": "^7.14.5"
"@babel/types": "^7.14.9"
},

@@ -31,5 +31,5 @@ "peerDependencies": {

"devDependencies": {
"@babel/core": "7.14.5",
"@babel/core": "7.14.8",
"@babel/helper-plugin-test-runner": "7.14.5",
"@babel/traverse": "7.14.5"
"@babel/traverse": "7.14.9"
},

@@ -36,0 +36,0 @@ "engines": {

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