eslint-visitor-keys
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The eslint-visitor-keys
is a handy npm package that provides constants and utilities for working with visitor keys in order to traverse Abstract Syntax Trees (AST). It brings you an efficient way to handle and traverse any ESTree nodes in your JavaScript codebase, making code analysis and syntax parsing tasks a breeze.
Using eslint-visitor-keys
is relatively straightforward. After installing it with npm using npm install eslint-visitor-keys
, you can import it in your project as follows:
If you're using ESM (ECMAScript modules), the import code looks like this:
import * as evk from "eslint-visitor-keys"
For a CommonJS-based project, use the require
statement to import eslint-visitor-keys:
:
const evk = require("eslint-visitor-keys")
Once imported, you have access to features such as evk.KEYS
, which allows you to print property names of child nodes:
console.log(evk.KEYS.AssignmentExpression) // β ["left", "right"]
In addition, you can also make use of the evk.getKeys(node)
function to fetch the visitor keys of an AST node. Moreover, you can use evk.unionWith(additionalKeys)
to make a union set with evk.KEYS
and your defined keys.
The documentation for eslint-visitor-keys
is available directly in the readme on its GitHub repo (https://github.com/eslint/eslint-visitor-keys), which details key features and usage instructions. The accompanying examples illustrate how to utilize its APIs effectively. Considering the package serves as a utility for AST node traversal, familiarity with AST and ESTree might be helpful for better comprehension of the docs.