From 923eec3afecee981600e5e2a5303ad3abf7cdc00 Mon Sep 17 00:00:00 2001 From: TOMIKAWA Sotaro <15074382+ssssota@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:07:40 +0900 Subject: [PATCH] docs: `getValue()` replaced with `node` (#16224) --- docs/plugins.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index c106a6792a6d..bfa039eabe43 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -202,7 +202,7 @@ function print( The `print` function is passed the following parameters: -- **`path`**: An object, which can be used to access nodes in the AST. It’s a stack-like data structure that maintains the current state of the recursion. It is called “path” because it represents the path to the current node from the root of the AST. The current node is returned by `path.getValue()`. +- **`path`**: An object, which can be used to access nodes in the AST. It’s a stack-like data structure that maintains the current state of the recursion. It is called “path” because it represents the path to the current node from the root of the AST. The current node is returned by `path.node`. - **`options`**: A persistent object, which contains global options and which a plugin may mutate to store contextual data. - **`print`**: A callback for printing sub-nodes. This function contains the core printing logic that consists of steps whose implementation is provided by plugins. In particular, it calls the printer’s `print` function and passes itself to it. Thus, the two `print` functions – the one from the core and the one from the plugin – call each other while descending down the AST recursively. @@ -214,7 +214,7 @@ import { doc } from "prettier"; const { group, indent, join, line, softline } = doc.builders; function print(path, options, print) { - const node = path.getValue(); + const node = path.node; switch (node.type) { case "list": @@ -281,7 +281,7 @@ For example, a plugin that has nodes with embedded JavaScript might have the fol ```js function embed(path, options) { - const node = path.getValue(); + const node = path.node; if (node.type === "javascript") { return async (textToDoc) => { return [