Fix code example for prettier.resolveConfig (#16525)

This commit is contained in:
Yuhei Yasuda authored and GitHub committed 2024-08-10 09:52:30 +08:00
1 parent a19277059e
commit 5c60b9ef4a
1 file changed
+4 -1
+4 -1
View File
@@ -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: