Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@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 34,105,935 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.