Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 1.01 KB

README.md

File metadata and controls

68 lines (48 loc) · 1.01 KB

tsestree-walker

Simple utility for walking an AST in the TSESTree format.

This is a ported and feature-reduced version of estree-walker.

Installation

npm

npm i @mkx419/tsestree-walker

pnpm

pnpm add @mkx419/tsestree-walker

Usage

walk

import { walk } from "@mkx419/tsestree-walker";
import { parse } from "@typescript-eslint/typescript-estree";

const ast = parse(sourceCode);

walk(ast, {
  enter(node) {
    //
  },
  leave(node) {
    //
  },
});

WalkerBase

import { WalkerBase } from "@mkx419/tsestree-walker";
import { parse } from "@typescript-eslint/typescript-estree";

class CustomWalker extends WalkerBase {
  constructor() {
    super();
  }

  enter(node) {
    //
  }

  leave(node) {
    //
  }

  start(ast) {
    super.start(ast);
  }
}

const ast = parse(sourceCode);

new CustomWalker().start(ast);