docs: getValue() replaced with node (#16224)

This commit is contained in:
TOMIKAWA Sotaro authored and GitHub committed 2024-04-30 22:07:40 +09:00
1 parent 9026b1c89f
commit 923eec3afe
1 file changed
+3 -3
+3 -3
View File
@@ -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 [