Socket
Socket
Sign inDemoInstall

@typescript-eslint/visitor-keys

Package Overview
Dependencies
2
Maintainers
2
Versions
2703
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @typescript-eslint/visitor-keys

Visitor keys used to help traverse the TypeScript-ESTree AST


Version published
Weekly downloads
47M
decreased by-0.63%
Maintainers
2
Install size
203 kB
Created
Weekly downloads
 

Package description

What is @typescript-eslint/visitor-keys?

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.

What are @typescript-eslint/visitor-keys's main functionalities?

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);
    }
  });
}

Other packages similar to @typescript-eslint/visitor-keys

Changelog

Source

7.4.0 (2024-03-25)

🚀 Features

  • eslint-plugin: [consistent-type-imports] ignore files with decorators, experimentalDecorators, and emitDecoratorMetadata (#8335)
  • eslint-plugin: [no-unnecessary-type-arguments] handle tagged templates (#8708)
  • eslint-plugin: deprecate no-throw-literal and add a renamed only-throw-error (#8701)

🩹 Fixes

  • eslint-plugin: [prefer-optional-chain] address multipart nullish checks false positive (#8678)
  • eslint-plugin: [prefer-optional-chain] properly disambiguate between boolean and false (#8685)
  • eslint-plugin: [no-unnecessary-type-assertion] avoid remove const casting on template literals with expressions inside (#8740)
  • typescript-eslint: declare peer dependency on utils to ensure npm correctly installs dependencies (#8738)
  • website: visual Editor is not scrolled (#8709)
  • website: make 404 page good again (#8750)

❤️ Thank You

  • Abraham Guo
  • Brad Zacher @bradzacher
  • Josh Goldberg ✨
  • Kim Sang Du @developer-bandi
  • Kirk Waiblinger @kirkwaiblinger
  • Marco Pasqualetti @marcalexiei
  • YeonJuan @yeonjuan

You can read about our versioning strategy and releases on our website.

Readme

Source

@typescript-eslint/visitor-keys

Visitor keys used to help traverse the TypeScript-ESTree AST.

✋ Internal Package

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.

Keywords

FAQs

Last updated on 25 Mar 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc