From 5c60b9ef4ab2ab5f02ab53461201fec72089cb09 Mon Sep 17 00:00:00 2001 From: Yuhei Yasuda Date: Sat, 10 Aug 2024 10:52:30 +0900 Subject: [PATCH] Fix code example for `prettier.resolveConfig` (#16525) --- docs/api.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 50dab9a63..8d4fdc6aa 100644 --- a/docs/api.md +++ b/docs/api.md @@ -49,7 +49,10 @@ If `options.useCache` is `false`, all caching will be bypassed. ```js const text = await fs.readFile(filePath, "utf8"); const options = await prettier.resolveConfig(filePath); -const formatted = await prettier.format(text, options); +const formatted = await prettier.format(text, { + ...options, + filepath: filePath, +}); ``` If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editorconfig.org/) is in your project, Prettier will parse it and convert its properties to the corresponding Prettier configuration. This configuration will be overridden by `.prettierrc`, etc. Currently, the following EditorConfig properties are supported: