Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@typescript-eslint/visitor-keys
Advanced tools
Visitor keys used to help traverse the TypeScript-ESTree AST
The @typescript-eslint/visitor-keys package provides an enumeration of TypeScript ESTree AST node types and their respective visitor keys. It is primarily used in the context of ESLint plugins and custom rules development to traverse the AST (Abstract Syntax Tree) of TypeScript code and analyze or manipulate the code structure.
AST Node Traversal
This code demonstrates how to use the visitor keys from the package to traverse an AST node and its children recursively. The `traverseAST` function takes a node and a visitor object that contains methods corresponding to node types. It uses the visitor keys to determine which properties of a node to traverse.
const visitorKeys = require('@typescript-eslint/visitor-keys');
function traverseAST(node, visitor) {
if (visitor[node.type]) {
visitor[node.type](node);
}
const keys = visitorKeys[node.type] || [];
keys.forEach((key) => {
const value = node[key];
if (Array.isArray(value)) {
value.forEach(child => traverseAST(child, visitor));
} else if (value && typeof value === 'object') {
traverseAST(value, visitor);
}
});
}
This package provides a list of visitor keys for traversing the AST of JavaScript code. It is similar to @typescript-eslint/visitor-keys but is tailored for JavaScript rather than TypeScript. It is used by ESLint to work with its own rules and plugins.
While not a direct equivalent, babel-types is part of the Babel ecosystem and provides definitions for various AST node types, builders, and assertion methods. It can be used to traverse and manipulate ASTs for both JavaScript and TypeScript, offering a broader scope compared to @typescript-eslint/visitor-keys.
Estraverse is a simple and flexible library for traversing and replacing nodes in an ECMAScript AST. It is not TypeScript-specific but can be used with JavaScript ASTs. It provides a similar traversal functionality but does not rely on a predefined set of visitor keys.
@typescript-eslint/visitor-keys
Visitor keys used to help traverse the TypeScript-ESTree AST.
This is an internal package to the typescript-eslint monorepo. You likely don't want to use it directly.
š See https://typescript-eslint.io for docs on typescript-eslint.
FAQs
Visitor keys used to help traverse the TypeScript-ESTree AST
The npm package @typescript-eslint/visitor-keys receives a total of 28,389,853 weekly downloads. As such, @typescript-eslint/visitor-keys popularity was classified as popular.
We found that @typescript-eslint/visitor-keys demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 2 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.