Website: Update documentation of resolveConfigFile (#6568)

This commit is contained in:
Sosuke Suzuki authored and Simon Lydell committed 2019-10-02 17:34:58 +02:00
1 parent fced57c1d6
commit 1aef2b13f4
2 files changed
+26 -6

No files matched your search

+13 -3
View File
@@ -58,16 +58,26 @@ If `options.editorconfig` is `true` and an [`.editorconfig` file](http://editorc
Use `prettier.resolveConfig.sync(filePath [, options])` if you'd like to use sync version.
## `prettier.resolveConfigFile(filePath [, options])`
## `prettier.resolveConfigFile([filePath])`
`resolveConfigFile` can be used to find the path of the Prettier's configuration file will be used when resolving the config (i.e. when calling `resolveConfig`). A promise is returned which will resolve to:
`resolveConfigFile` can be used to find the path of the Prettier configuration file that will be used when resolving the config (i.e. when calling `resolveConfig`). A promise is returned which will resolve to:
- The path of the configuration file.
- `null`, if no file was found.
The promise will be rejected if there was an error parsing the configuration file.
If `options.useCache` is `false`, all caching will be bypassed.
The search starts at `process.cwd()`, or at `filePath` if provided. Please see the [cosmiconfig docs](https://github.com/davidtheclark/cosmiconfig#explorersearch) for details on how the resolving works.
```js
prettier.resolveConfigFile().then(filePath => {
prettier.resolveConfig(filePath).then(options => {
const formatted = prettier.format(text, options);
});
});
```
Use `prettier.resolveConfigFile.sync([filePath])` if you'd like to use sync version.
## `prettier.clearConfigCache()`