Website: Update documentation of `resolveConfigFile` (#6568)
parent
fced57c1d6
commit
1aef2b13f4
16
docs/api.md
16
docs/api.md
|
@ -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()`
|
||||
|
||||
|
|
|
@ -59,16 +59,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()`
|
||||
|
||||
|
|
Loading…
Reference in New Issue