Security News
RubyGems.org Adds New Maintainer Role
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.
@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 31,456,170 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.
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.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.