A plugin for pretty-format2 that prints Abstract Syntax Trees (ASTs) in a human-readable, indented format. Version 1.0.1 is the current stable release. It provides a structured view of AST nodes with their properties, types, and positions. Compared to alternatives like util.inspect, it produces a much more concise and visually organized output, specifically designed for AST inspection. The package works with any AST that follows a similar node structure and requires pretty-format2 as a peer dependency.
npm install pretty-format-astVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: import pretty-format2 and pretty-format-ast, then format a simple AST object with the plugin.
Use { plugins: [prettyFormatAST] } instead of { plugins: prettyFormatAST }.Check compatibility with pretty-format2 v2.0.0 before upgrading.
Wait for an updated version of pretty-format-ast or pin pretty-format2 to v1.x.
Ensure your AST objects have a 'type' string field for proper formatting.
Use import: import prettyFormat2 from 'pretty-format2'; or ensure you have v1.x installed.
Run: npm install pretty-format2
Use require syntax, or set "type": "module" in package.json.
Wrap the plugin in an array: plugins: [prettyFormatAST]