Socket
Socket
Sign inDemoInstall

hermes-transform

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hermes-transform - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

86

dist/generated/node-types.js

@@ -36,2 +36,3 @@ /**

CatchClause: true,
ChainExpression: true,
ClassBody: true,

@@ -41,4 +42,2 @@ ClassDeclaration: true,

ClassImplements: true,
ClassPrivateProperty: true,
ClassProperty: true,
ConditionalExpression: true,

@@ -74,3 +73,2 @@ ContinueStatement: true,

ExportNamedDeclaration: true,
ExportNamespaceSpecifier: true,
ExportSpecifier: true,

@@ -134,7 +132,6 @@ ExpressionStatement: true,

OpaqueType: true,
OptionalCallExpression: true,
OptionalIndexedAccessType: true,
OptionalMemberExpression: true,
PrivateName: true,
PrivateIdentifier: true,
Property: true,
PropertyDefinition: true,
QualifiedTypeIdentifier: true,

@@ -191,2 +188,3 @@ RestElement: true,

exports.CatchClause = CatchClause;
exports.ChainExpression = ChainExpression;
exports.ClassBody = ClassBody;

@@ -196,4 +194,2 @@ exports.ClassDeclaration = ClassDeclaration;

exports.ClassImplements = ClassImplements;
exports.ClassPrivateProperty = ClassPrivateProperty;
exports.ClassProperty = ClassProperty;
exports.ConditionalExpression = ConditionalExpression;

@@ -229,3 +225,2 @@ exports.ContinueStatement = ContinueStatement;

exports.ExportNamedDeclaration = ExportNamedDeclaration;
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
exports.ExportSpecifier = ExportSpecifier;

@@ -289,7 +284,6 @@ exports.ExpressionStatement = ExpressionStatement;

exports.OpaqueType = OpaqueType;
exports.OptionalCallExpression = OptionalCallExpression;
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
exports.OptionalMemberExpression = OptionalMemberExpression;
exports.PrivateName = PrivateName;
exports.PrivateIdentifier = PrivateIdentifier;
exports.Property = Property;
exports.PropertyDefinition = PropertyDefinition;
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;

@@ -514,3 +508,3 @@ exports.RestElement = RestElement;

function ClassBody({
function ChainExpression({
parent,

@@ -520,3 +514,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ClassBody',
type: 'ChainExpression',
...props

@@ -528,3 +522,3 @@ });

function ClassDeclaration({
function ClassBody({
parent,

@@ -534,3 +528,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ClassDeclaration',
type: 'ClassBody',
...props

@@ -542,3 +536,3 @@ });

function ClassExpression({
function ClassDeclaration({
parent,

@@ -548,3 +542,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ClassExpression',
type: 'ClassDeclaration',
...props

@@ -556,3 +550,3 @@ });

function ClassImplements({
function ClassExpression({
parent,

@@ -562,3 +556,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ClassImplements',
type: 'ClassExpression',
...props

@@ -570,3 +564,3 @@ });

function ClassPrivateProperty({
function ClassImplements({
parent,

@@ -576,3 +570,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ClassPrivateProperty',
type: 'ClassImplements',
...props

@@ -584,14 +578,2 @@ });

function ClassProperty({
parent,
...props
}) {
const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ClassProperty',
...props
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
}
function ConditionalExpression({

@@ -941,14 +923,2 @@ parent,

function ExportNamespaceSpecifier({
parent,
...props
}) {
const node = (0, _detachedNode.detachedProps)(parent, {
type: 'ExportNamespaceSpecifier',
...props
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
}
function ExportSpecifier({

@@ -1622,14 +1592,2 @@ parent,

function OptionalCallExpression({
parent,
...props
}) {
const node = (0, _detachedNode.detachedProps)(parent, {
type: 'OptionalCallExpression',
...props
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
}
function OptionalIndexedAccessType({

@@ -1647,3 +1605,3 @@ parent,

function OptionalMemberExpression({
function PrivateIdentifier({
parent,

@@ -1653,3 +1611,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'OptionalMemberExpression',
type: 'PrivateIdentifier',
...props

@@ -1661,3 +1619,3 @@ });

function PrivateName({
function Property({
parent,

@@ -1667,3 +1625,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'PrivateName',
type: 'Property',
...props

@@ -1675,3 +1633,3 @@ });

function Property({
function PropertyDefinition({
parent,

@@ -1681,3 +1639,3 @@ ...props

const node = (0, _detachedNode.detachedProps)(parent, {
type: 'Property',
type: 'PropertyDefinition',
...props

@@ -1684,0 +1642,0 @@ });

@@ -46,2 +46,3 @@ "use strict";

function performInsertStatementMutation(mutationContext, mutation) {
mutationContext.assertNotDeleted(mutation.target, `Attempted to insert ${mutation.side} a deleted ${mutation.target.type} node. This likely means that you attempted to mutate around the target after it was deleted/replaced.`);
const insertionParent = (0, _getStatementParent.getStatementParent)(mutation.target); // enforce that if we are inserting module declarations - they are being inserted in a valid location

@@ -48,0 +49,0 @@

@@ -49,4 +49,3 @@ "use strict";

// ClassMember
case 'ClassProperty':
case 'ClassPrivateProperty':
case 'PropertyDefinition':
case 'MethodDefinition':

@@ -74,2 +73,10 @@ assertParent('ClassBody');

case 'JSXAttribute':
assertParent('JSXOpeningElement');
return 'attributes';
case 'ImportDeclaration':
assertParent('Program');
return 'body';
case 'ObjectTypeCallProperty':

@@ -166,3 +173,3 @@ assertParent('ObjectTypeAnnotation');

if (idx === -1) {
throw new _Errors.InvalidRemovalError(`Could not find target in array of \`${parent.type}.${key}\`.`);
throw new _Errors.InvalidRemovalError(`Could not find target in array of \`${node.parent.type}.${key}\`.`);
}

@@ -169,0 +176,0 @@

@@ -36,12 +36,22 @@ /**

return originalCode;
} // prettier fully expects the parent pointers are NOT set and
// certain cases can crash due to prettier infinite-looping
// whilst naively traversing the parent property
// https://github.com/prettier/prettier/issues/11793
}
_SimpleTraverser.SimpleTraverser.traverse(ast, {
enter(node) {
// prettier fully expects the parent pointers are NOT set and
// certain cases can crash due to prettier infinite-looping
// whilst naively traversing the parent property
// https://github.com/prettier/prettier/issues/11793
// $FlowExpectedError[cannot-write]
delete node.parent;
delete node.parent; // prettier currently relies on the AST being in the old-school, deprecated AST format for optional chaining
// so we have to apply their transform to our AST so it can actually format it.
if (node.type === 'ChainExpression') {
const newNode = transformChainExpression(node.expression); // $FlowExpectedError[cannot-write]
delete node.expression; // $FlowExpectedError[prop-missing]
// $FlowExpectedError[cannot-write]
Object.assign(node, newNode);
}
},

@@ -66,2 +76,24 @@

});
} // https://github.com/prettier/prettier/blob/d962466a828f8ef51435e3e8840178d90b7ec6cd/src/language-js/parse/postprocess/index.js#L161-L182
function transformChainExpression(node) {
switch (node.type) {
case 'CallExpression':
// $FlowExpectedError[cannot-write]
node.type = 'OptionalCallExpression'; // $FlowExpectedError[cannot-write]
node.callee = transformChainExpression(node.callee);
break;
case 'MemberExpression':
// $FlowExpectedError[cannot-write]
node.type = 'OptionalMemberExpression'; // $FlowExpectedError[cannot-write]
node.object = transformChainExpression(node.object);
break;
// No default
}
return node;
}
{
"name": "hermes-transform",
"version": "0.7.0",
"version": "0.8.0",
"description": "Tools built on top of Hermes-ESTree to enable codebase transformation",

@@ -15,4 +15,4 @@ "main": "dist/index.js",

"flow-enums-runtime": "^0.0.6",
"hermes-eslint": "0.7.0",
"hermes-estree": "0.7.0"
"hermes-eslint": "0.8.0",
"hermes-estree": "0.8.0"
},

@@ -19,0 +19,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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