What is @types/eslint-visitor-keys?
The @types/eslint-visitor-keys package provides TypeScript type definitions for eslint-visitor-keys, which is a utility used by ESLint to determine the keys to visit on an AST (Abstract Syntax Tree) node. This package is essential for TypeScript users who are working with ESLint custom rules or plugins and need to ensure type safety and autocompletion when dealing with visitor keys.
What are @types/eslint-visitor-keys's main functionalities?
Type Definitions for Visitor Keys
This feature provides TypeScript type definitions for defining visitor keys. It allows developers to specify which properties of AST nodes should be visited by ESLint rules. The code sample demonstrates how to define visitor keys for `Program` and `CallExpression` nodes.
import { VisitorKeys } from '@types/eslint-visitor-keys';
const visitorKeys: VisitorKeys = {
Program: ['body'],
CallExpression: ['callee', 'arguments']
};
Other packages similar to @types/eslint-visitor-keys
@typescript-eslint/typescript-estree
This package is part of the TypeScript ESLint project and provides a parser that converts TypeScript code into an ESTree-compatible form. It is similar to @types/eslint-visitor-keys in that it deals with AST nodes, but it focuses more on parsing rather than defining visitor keys.
eslint
The core ESLint package itself is related to @types/eslint-visitor-keys as it uses visitor keys to traverse the AST and check for linting errors. However, ESLint is a comprehensive linting tool, whereas @types/eslint-visitor-keys specifically provides TypeScript types for the visitor keys.
This is a stub types definition for @types/eslint-visitor-keys (https://github.com/eslint/js/blob/main/packages/eslint-visitor-keys/README.md).
eslint-visitor-keys provides its own type definitions, so you don't need @types/eslint-visitor-keys installed!