Socket
Socket
Sign inDemoInstall

hermes-transform

Package Overview
Dependencies
6
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.0 to 0.10.0

dist/generated/special-case-node-types/Comment.js

36

dist/detachedNode.js

@@ -15,6 +15,4 @@ "use strict";

var _getVisitorKeys = require("./getVisitorKeys");
var _hermesParser = require("hermes-parser");
var _SimpleTraverser = require("./traverse/SimpleTraverser");
/**

@@ -61,4 +59,3 @@ * Copyright (c) Meta Platforms, Inc. and affiliates.

function detachedProps(parent, props, config = { ...null
}) {
function detachedProps(parent, props, config = {}) {
// $FlowExpectedError[incompatible-type]

@@ -123,7 +120,9 @@ const detachedNode = { ...props,

function shallowCloneNode(node, newProps, config = { ...null
}) {
function shallowCloneNode(node, newProps, config = {}) {
var _config$preserveLocat, _config$originalNode;
return detachedProps(null, Object.assign({}, node, newProps), {
return detachedProps(null, // $FlowFixMe[cannot-spread-interface]
{ ...node,
...newProps
}, {
preserveLocation: (_config$preserveLocat = config.preserveLocation) != null ? _config$preserveLocat : true,

@@ -157,12 +156,3 @@ originalNode: (_config$originalNode = config.originalNode) != null ? _config$originalNode : node

function setParentPointersInDirectChildren(node) {
for (const key of (0, _getVisitorKeys.getVisitorKeys)(node)) {
if ((0, _getVisitorKeys.isNode)( // $FlowExpectedError[prop-missing]
node[key])) {
node[key].parent = node;
} else if (Array.isArray(node[key])) {
for (const child of node[key]) {
child.parent = node;
}
}
}
_hermesParser.astNodeMutationHelpers.setParentPointersInDirectChildren(node);
}

@@ -175,11 +165,3 @@ /**

function updateAllParentPointers(node) {
_SimpleTraverser.SimpleTraverser.traverse(node, {
enter(node, parent) {
// $FlowExpectedError[cannot-write]
node.parent = parent;
},
leave() {}
});
_hermesParser.astNodeMutationHelpers.updateAllParentPointers(node);
}

@@ -6,189 +6,57 @@ "use strict";

});
exports.ArrowFunctionExpression = ArrowFunctionExpression;
exports.BigIntLiteral = BigIntLiteral;
exports.BlockComment = BlockComment;
exports.BooleanLiteral = BooleanLiteral;
exports.ClassDeclaration = ClassDeclaration;
exports.Identifier = Identifier;
exports.LineComment = LineComment;
exports.NullLiteral = NullLiteral;
exports.NumericLiteral = NumericLiteral;
exports.RegExpLiteral = RegExpLiteral;
exports.StringLiteral = StringLiteral;
exports.TemplateElement = TemplateElement;
var _detachedNode = require("../detachedNode");
var _Comment = require("./special-case-node-types/Comment");
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
Object.keys(_Comment).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _Comment[key]) return;
exports[key] = _Comment[key];
});
/*
These are a number of special-case node creation functions that we can't auto-generate.
The list of exported functions here must be kept in sync with the `NODES_WITH_SPECIAL_HANDLING`
list in `scripts/genTransformNodeTypes` to ensure there's no duplicates
*/
function ArrowFunctionExpression(props) {
const node = (0, _detachedNode.detachedProps)(props.parent, {
type: 'ArrowFunctionExpression',
id: null,
// $FlowExpectedError[incompatible-use]
expression: props.body.type !== 'BlockStatement',
params: props.params.map(n => (0, _detachedNode.asDetachedNode)(n)),
body: (0, _detachedNode.asDetachedNode)(props.body),
typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
returnType: (0, _detachedNode.asDetachedNode)(props.returnType),
predicate: (0, _detachedNode.asDetachedNode)(props.predicate),
async: props.async
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
}
var _DeclareExportDeclaration = require("./special-case-node-types/DeclareExportDeclaration");
function ClassDeclaration(props) {
var _props$decorators, _props$implements;
Object.keys(_DeclareExportDeclaration).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _DeclareExportDeclaration[key]) return;
exports[key] = _DeclareExportDeclaration[key];
});
const node = (0, _detachedNode.detachedProps)(props.parent, {
type: 'ClassDeclaration',
id: (0, _detachedNode.asDetachedNode)(props.id),
typeParameters: (0, _detachedNode.asDetachedNode)(props.typeParameters),
superClass: (0, _detachedNode.asDetachedNode)(props.superClass),
superTypeParameters: (0, _detachedNode.asDetachedNode)(props.superTypeParameters),
decorators: ((_props$decorators = props.decorators) != null ? _props$decorators : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
implements: ((_props$implements = props.implements) != null ? _props$implements : []).map(n => (0, _detachedNode.asDetachedNode)(n)),
body: (0, _detachedNode.asDetachedNode)(props.body)
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
} // pattern/flags are on a subobject in the estree spec, but are flat on the hermes types
// also the value is supposed to be a RegExp instance
var _ExportNamedDeclaration = require("./special-case-node-types/ExportNamedDeclaration");
Object.keys(_ExportNamedDeclaration).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _ExportNamedDeclaration[key]) return;
exports[key] = _ExportNamedDeclaration[key];
});
function RegExpLiteral(props) {
const value = new RegExp(props.pattern, props.flags);
return (0, _detachedNode.detachedProps)(props.parent, {
type: 'Literal',
value,
raw: value.toString(),
regex: {
pattern: props.pattern,
flags: props.flags
}
});
} // raw/cooked are on a subobject in the estree spec, but are flat on the hermes types
var _Literal = require("./special-case-node-types/Literal");
Object.keys(_Literal).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _Literal[key]) return;
exports[key] = _Literal[key];
});
function TemplateElement(props) {
return (0, _detachedNode.detachedProps)(props.parent, {
type: 'TemplateElement',
tail: props.tail,
value: {
cooked: props.cooked,
raw: props.raw
}
});
} // Identifier has a bunch of stuff that usually you don't want to provide - so we have
// this manual def to allow us to default some values
var _ObjectTypeProperty = require("./special-case-node-types/ObjectTypeProperty");
Object.keys(_ObjectTypeProperty).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _ObjectTypeProperty[key]) return;
exports[key] = _ObjectTypeProperty[key];
});
function Identifier(props) {
var _props$optional;
var _misc = require("./special-case-node-types/misc");
const node = (0, _detachedNode.detachedProps)(props.parent, {
type: 'Identifier',
name: props.name,
optional: (_props$optional = props.optional) != null ? _props$optional : false,
typeAnnotation: (0, _detachedNode.asDetachedNode)(props.typeAnnotation)
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
} //
// Literals require a "raw" which is added by the estree transform, not hermes.
//
Object.keys(_misc).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _misc[key]) return;
exports[key] = _misc[key];
});
var _Property = require("./special-case-node-types/Property");
function BigIntLiteral(props) {
var _props$raw;
const node = (0, _detachedNode.detachedProps)(props.parent, {
type: 'Literal',
value: props.value,
raw: (_props$raw = props.raw) != null ? _props$raw : `${props.value}n`,
bigint: `${props.value}`
});
(0, _detachedNode.setParentPointersInDirectChildren)(node);
return node;
}
function BooleanLiteral(props) {
return (0, _detachedNode.detachedProps)(props.parent, {
type: 'Literal',
raw: props.value ? 'true' : 'false',
value: props.value
});
}
function NumericLiteral(props) {
var _props$raw2;
return (0, _detachedNode.detachedProps)(props.parent, {
type: 'Literal',
value: props.value,
raw: (_props$raw2 = props.raw) != null ? _props$raw2 : `${props.value}`
});
}
function NullLiteral(props = { ...null
}) {
return (0, _detachedNode.detachedProps)(props.parent, {
type: 'Literal',
value: null,
raw: 'null'
});
}
function StringLiteral(props) {
const hasSingleQuote = props.value.includes('"');
const hasDoubleQuote = props.value.includes("'");
let raw = props.raw;
if (raw == null) {
if (hasSingleQuote && hasDoubleQuote) {
raw = `'${props.value.replace(/'/g, "\\'")}'`;
} else if (hasSingleQuote) {
raw = `"${props.value}"`;
} else {
raw = `'${props.value}'`;
}
}
return (0, _detachedNode.detachedProps)(props.parent, {
type: 'Literal',
raw,
value: props.value
});
}
function LineComment(props) {
// $FlowExpectedError[prop-missing]
// $FlowExpectedError[incompatible-return]
return (0, _detachedNode.detachedProps)(undefined, {
type: 'Line',
value: props.value
});
}
function BlockComment(props) {
// $FlowExpectedError[prop-missing]
// $FlowExpectedError[incompatible-return]
return (0, _detachedNode.detachedProps)(undefined, {
type: 'Block',
value: props.value
});
}
Object.keys(_Property).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _Property[key]) return;
exports[key] = _Property[key];
});

@@ -15,7 +15,7 @@ /**

});
exports.traverseWithContext = exports.traverse = exports.transform = exports.t = exports.SimpleTraverser = void 0;
exports.traverseWithContext = exports.traverse = exports.transform = exports.t = exports.print = exports.parse = exports.cloneJSDocCommentsToNewNode = exports.asDetachedNode = exports.SimpleTraverser = void 0;
var _SimpleTraverser = require("./traverse/SimpleTraverser");
var _hermesParser = require("hermes-parser");
exports.SimpleTraverser = _SimpleTraverser.SimpleTraverser;
exports.SimpleTraverser = _hermesParser.SimpleTraverser;

@@ -31,2 +31,10 @@ var _traverse = require("./traverse/traverse");

var _parse = require("./transform/parse");
exports.parse = _parse.parse;
var _print = require("./transform/print");
exports.print = _print.print;
var _t = _interopRequireWildcard(require("./generated/node-types"));

@@ -36,4 +44,12 @@

var _detachedNode = require("./detachedNode");
exports.asDetachedNode = _detachedNode.asDetachedNode;
var _comments = require("./transform/comments/comments");
exports.cloneJSDocCommentsToNewNode = _comments.cloneJSDocCommentsToNewNode;
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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

exports.cloneCommentWithMarkers = cloneCommentWithMarkers;
exports.cloneJSDocCommentsToNewNode = cloneJSDocCommentsToNewNode;
exports.getCommentsForNode = getCommentsForNode;

@@ -30,2 +31,4 @@ exports.getLeadingCommentsForNode = getLeadingCommentsForNode;

var _hermesEstree = require("hermes-estree");
var _os = require("os");

@@ -64,2 +67,10 @@

function cloneJSDocCommentsToNewNode(oldNode, newNode) {
const comments = getCommentsForNode(oldNode).filter(comment => {
return (0, _hermesEstree.isBlockComment)(comment) && // JSDoc comments always start with an extra asterisk
comment.value.startsWith('*');
});
setCommentsOnNode(newNode, comments.map(cloneCommentWithMarkers));
}
function setCommentsOnNode(node, comments) {

@@ -66,0 +77,0 @@ // $FlowExpectedError - this property is secretly added by prettier.

@@ -53,3 +53,3 @@ /**

const childNodes = printer.getCommentChildNodes && printer.getCommentChildNodes(node, options) || typeof node === 'object' && Object.entries(node).filter(([key]) => key !== 'enclosingNode' && key !== 'precedingNode' && key !== 'followingNode' && key !== 'tokens' && key !== 'comments').map(([, value]) => value);
const childNodes = printer.getCommentChildNodes && printer.getCommentChildNodes(node, options) || typeof node === 'object' && Object.entries(node).filter(([key]) => key !== 'enclosingNode' && key !== 'precedingNode' && key !== 'followingNode' && key !== 'tokens' && key !== 'comments' && key !== 'parent').map(([, value]) => value);

@@ -56,0 +56,0 @@ if (!childNodes) {

@@ -9,3 +9,3 @@ "use strict";

var _arrayUtils = require("./utils/arrayUtils");
var _hermesParser = require("hermes-parser");

@@ -62,3 +62,3 @@ var _getStatementParent = require("./utils/getStatementParent");

{
parent[insertionParent.key] = (0, _arrayUtils.insertInArray)(parent[insertionParent.key], insertionParent.targetIndex, mutation.nodesToInsert);
parent[insertionParent.key] = _hermesParser.astArrayMutationHelpers.insertInArray(parent[insertionParent.key], insertionParent.targetIndex, mutation.nodesToInsert);
break;

@@ -69,3 +69,3 @@ }

{
parent[insertionParent.key] = (0, _arrayUtils.insertInArray)(parent[insertionParent.key], insertionParent.targetIndex + 1, mutation.nodesToInsert);
parent[insertionParent.key] = _hermesParser.astArrayMutationHelpers.insertInArray(parent[insertionParent.key], insertionParent.targetIndex + 1, mutation.nodesToInsert);
break;

@@ -72,0 +72,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

var _SimpleTraverser = require("../../traverse/SimpleTraverser");
var _hermesParser = require("hermes-parser");

@@ -37,3 +37,3 @@ var _comments = require("../comments/comments");

_SimpleTraverser.SimpleTraverser.traverse(ast, {
_hermesParser.SimpleTraverser.traverse(ast, {
enter(node) {

@@ -61,3 +61,3 @@ if (node === ast) {

// no more comments to process - so we can exit traversal
throw _SimpleTraverser.SimpleTraverserBreak;
throw _hermesParser.SimpleTraverserBreak;
}

@@ -64,0 +64,0 @@ },

@@ -9,3 +9,3 @@ "use strict";

var _arrayUtils = require("./utils/arrayUtils");
var _hermesParser = require("hermes-parser");

@@ -191,4 +191,4 @@ var _Errors = require("../Errors");

const parent = removalParent.parent;
parent[removalParent.key] = (0, _arrayUtils.removeFromArray)(parent[removalParent.key], removalParent.targetIndex);
parent[removalParent.key] = _hermesParser.astArrayMutationHelpers.removeFromArray(parent[removalParent.key], removalParent.targetIndex);
return removalParent.parent;
}

@@ -9,3 +9,3 @@ "use strict";

var _arrayUtils = require("./utils/arrayUtils");
var _hermesParser = require("hermes-parser");

@@ -43,3 +43,3 @@ var _getStatementParent = require("./utils/getStatementParent");

const parent = removalParent.parent;
parent[removalParent.key] = (0, _arrayUtils.removeFromArray)(parent[removalParent.key], removalParent.targetIndex);
parent[removalParent.key] = _hermesParser.astArrayMutationHelpers.removeFromArray(parent[removalParent.key], removalParent.targetIndex);
} else {

@@ -46,0 +46,0 @@ // The parent has a 1:1 relationship on this key, so we can't just

@@ -9,3 +9,3 @@ "use strict";

var _arrayUtils = require("./utils/arrayUtils");
var _hermesParser = require("hermes-parser");

@@ -18,4 +18,2 @@ var _comments = require("../comments/comments");

var _getVisitorKeys = require("../../getVisitorKeys");
/**

@@ -51,3 +49,3 @@ * Copyright (c) Meta Platforms, Inc. and affiliates.

const parent = replacementParent.parent;
parent[replacementParent.key] = (0, _arrayUtils.replaceInArray)(parent[replacementParent.key], replacementParent.targetIndex, [mutation.nodeToReplaceWith]);
parent[replacementParent.key] = _hermesParser.astArrayMutationHelpers.replaceInArray(parent[replacementParent.key], replacementParent.targetIndex, [mutation.nodeToReplaceWith]);
} else {

@@ -67,4 +65,4 @@ replacementParent.parent[replacementParent.key] = mutation.nodeToReplaceWith;

for (const key of (0, _getVisitorKeys.getVisitorKeys)(parent)) {
if ((0, _getVisitorKeys.isNode)( // $FlowExpectedError[prop-missing]
for (const key of (0, _hermesParser.getVisitorKeys)(parent)) {
if ((0, _hermesParser.isNode)( // $FlowExpectedError[prop-missing]
parent[key])) {

@@ -71,0 +69,0 @@ if (parent[key] === target) {

@@ -9,3 +9,3 @@ "use strict";

var _arrayUtils = require("./utils/arrayUtils");
var _hermesParser = require("hermes-parser");

@@ -67,3 +67,3 @@ var _getStatementParent = require("./utils/getStatementParent");

const parent = replacementParent.parent;
parent[replacementParent.key] = (0, _arrayUtils.replaceInArray)(parent[replacementParent.key], replacementParent.targetIndex, mutation.nodesToReplaceWith);
parent[replacementParent.key] = _hermesParser.astArrayMutationHelpers.replaceInArray(parent[replacementParent.key], replacementParent.targetIndex, mutation.nodesToReplaceWith);
return replacementParent.parent;

@@ -70,0 +70,0 @@ }

@@ -100,4 +100,5 @@ "use strict";

{
assertValidStatementLocation( // $FlowExpectedError[prop-missing] - flow does not track properties from parent interface
parent, 'left', 'right');
assertValidStatementLocation(parent, // $FlowExpectedError[prop-missing] - flow does not track properties from parent interface
'left', // $FlowExpectedError[prop-missing] - flow does not track properties from parent interface
'right');
return {

@@ -104,0 +105,0 @@ type: 'single',

@@ -17,13 +17,10 @@ /**

var prettier = _interopRequireWildcard(require("prettier"));
var _transformAST = require("./transformAST");
var _getTransformedAST = require("./getTransformedAST");
var _parse = require("./parse");
var _SimpleTraverser = require("../traverse/SimpleTraverser");
var _print = require("./print");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function transform(originalCode, visitors, prettierOptions = {}) {
const parseResult = (0, _parse.parse)(originalCode);
const {

@@ -33,3 +30,3 @@ ast,

mutatedCode
} = (0, _getTransformedAST.getTransformedAST)(originalCode, visitors);
} = (0, _transformAST.transformAST)(parseResult, visitors);

@@ -40,61 +37,3 @@ if (!astWasMutated) {

_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; // 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);
}
},
leave() {}
}); // we need to delete the comments prop or else prettier will do
// its own attachment pass after the mutation and duplicate the
// comments on each node, borking the output
// $FlowExpectedError[cannot-write]
delete ast.comments;
return prettier.format(mutatedCode, // $FlowExpectedError[incompatible-exact] - we don't want to create a dependency on the prettier types
{ ...prettierOptions,
parser() {
return ast;
}
});
} // 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;
return (0, _print.print)(ast, mutatedCode, prettierOptions);
}

@@ -71,3 +71,3 @@ "use strict";

if (node == null) {
// $FlowExpectedError[incompatible-call]
// $FlowExpectedError[incompatible-return]
return node;

@@ -74,0 +74,0 @@ }

@@ -15,3 +15,3 @@ "use strict";

var _SimpleTraverser = require("./SimpleTraverser");
var _hermesParser = require("hermes-parser");

@@ -36,24 +36,6 @@ /**

const emitter = new _SafeEmitter.SafeEmitter();
const nodeQueue = [];
let currentNode = ast; // set parent pointers and build up the traversal queue
let currentNode = ast;
let shouldSkipTraversal = false;
let shouldStopTraversal = false;
_SimpleTraverser.SimpleTraverser.traverse(ast, {
enter(node, parent) {
// $FlowExpectedError[cannot-write] - hermes doesn't set this
node.parent = parent;
nodeQueue.push({
isEntering: true,
node
});
},
leave(node) {
nodeQueue.push({
isEntering: false,
node
});
}
});
const getScope = (givenNode = currentNode) => {

@@ -117,3 +99,9 @@ // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope.

},
getScope
getScope,
stopTraversal: () => {
shouldStopTraversal = true;
},
skipTraversal: () => {
shouldSkipTraversal = true;
}
});

@@ -136,15 +124,28 @@ const traversalContext = Object.freeze({ ...traversalContextBase,

const eventGenerator = new _NodeEventGenerator.NodeEventGenerator(emitter);
nodeQueue.forEach(traversalInfo => {
currentNode = traversalInfo.node;
try {
if (traversalInfo.isEntering) {
eventGenerator.enterNode(currentNode);
} else {
eventGenerator.leaveNode(currentNode);
}
} catch (err) {
err.currentNode = currentNode;
throw err;
function checkTraversalFlags() {
if (shouldStopTraversal) {
// No need to reset the flag since we won't enter any more nodes.
throw _hermesParser.SimpleTraverser.Break;
}
if (shouldSkipTraversal) {
shouldSkipTraversal = false;
throw _hermesParser.SimpleTraverser.Skip;
}
}
_hermesParser.SimpleTraverser.traverse(ast, {
enter(node) {
currentNode = node;
eventGenerator.enterNode(node);
checkTraversalFlags();
},
leave(node) {
currentNode = node;
eventGenerator.leaveNode(node);
checkTraversalFlags();
}
});

@@ -151,0 +152,0 @@ }

{
"name": "hermes-transform",
"version": "0.9.0",
"version": "0.10.0",
"description": "Tools built on top of Hermes-ESTree to enable codebase transformation",

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

"flow-enums-runtime": "^0.0.6",
"hermes-eslint": "0.9.0",
"hermes-estree": "0.9.0"
"hermes-eslint": "0.10.0",
"hermes-estree": "0.10.0",
"hermes-parser": "0.10.0"
},
"peerDependencies": {
"prettier": "^2.4.1"
"prettier": "^2.7.1"
},

@@ -22,0 +23,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc