Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@babel/traverse
Advanced tools
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
The @babel/traverse package is part of the Babel toolchain and is used for traversing and manipulating the abstract syntax tree (AST) generated by Babel. It provides methods to visit nodes in the tree, update them, add or remove nodes, and perform various transformations on the code represented by the AST.
Visiting Nodes
This feature allows you to visit specific nodes in the AST. You can specify the types of nodes you're interested in and provide functions that will be called when those nodes are encountered during traversal.
{"type": "Identifier", "name": "a"}
Modifying Nodes
With @babel/traverse, you can modify nodes in the AST. This can include changing node types, adding or removing properties, or even replacing a node with a different one.
{"type": "Identifier", "name": "b"}
Adding and Removing Nodes
This feature allows you to add new nodes to the AST or remove existing ones. This is useful for code transformations where you need to introduce new variables, functions, or other constructs, or clean up unused code.
{"type": "VariableDeclaration", "declarations": [{"type": "VariableDeclarator", "id": {"type": "Identifier", "name": "c"}, "init": {"type": "Literal", "value": 3, "raw": "3"}}], "kind": "const"}
Scope Management
The package provides utilities for managing scope within the AST. This includes tracking variable declarations, bindings, and references, which is crucial for correctly transforming code without introducing errors.
{"type": "BlockStatement", "body": [], "directives": []}
Estraverse is a simple and flexible library for traversing and manipulating JavaScript ASTs. It is similar to @babel/traverse but is not tied to the Babel ecosystem and can be used with other ASTs conforming to the ESTree spec.
Acorn-walk is a small module for walking the AST generated by the Acorn parser. It provides a simple interface for visiting nodes but does not offer the same level of manipulation capabilities as @babel/traverse.
Recast provides AST traversal and manipulation capabilities, with a focus on preserving the original formatting of the code as much as possible. It uses esprima or babel as the parser and is more focused on code printing than @babel/traverse.
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
See our website @babel/traverse for more information or the issues associated with this package.
Using npm:
npm install --save-dev @babel/traverse
or using yarn:
yarn add @babel/traverse --dev
v7.21.0 (2023-02-20)
babel-core
, babel-helper-create-class-features-plugin
, babel-plugin-proposal-class-properties
, babel-plugin-proposal-private-methods
, babel-plugin-proposal-private-property-in-object
babel-helper-create-regexp-features-plugin
, babel-plugin-proposal-regexp-modifiers
, babel-standalone
babel-cli
, babel-core
, babel-generator
, babel-plugin-transform-destructuring
, babel-plugin-transform-modules-commonjs
, babel-plugin-transform-react-jsx
, babel-traverse
babel-parser
, babel-types
const
modifier in type parameters (@nicolo-ribaudo)babel-generator
, babel-helpers
, babel-parser
, babel-plugin-proposal-decorators
, babel-plugin-syntax-decorators
, babel-runtime-corejs2
, babel-runtime-corejs3
, babel-runtime
2023-01
TC39 meeting (@nicolo-ribaudo)babel-parser
new.target
outside functions (@overlookmotel)annexb: false
parser option to disable Annex B (@nicolo-ribaudo)babel-core
.cts
as configuration file (@liuxingbaoyu)babel-generator
, babel-parser
, babel-plugin-transform-typescript
export type * from
(@nicolo-ribaudo)babel-plugin-transform-typescript
babel-core
babel-helper-create-class-features-plugin
, babel-plugin-proposal-class-properties
, babel-plugin-proposal-class-static-block
, babel-plugin-proposal-private-methods
, babel-plugin-transform-classes
, babel-plugin-transform-new-target
babel-parser
, babel-plugin-transform-flow-comments
, babel-plugin-transform-flow-strip-types
, babel-types
babel-core
@babel/core
(@nicolo-ribaudo)babel-plugin-transform-typescript
FAQs
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
The npm package @babel/traverse receives a total of 23,560,543 weekly downloads. As such, @babel/traverse popularity was classified as popular.
We found that @babel/traverse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.