mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-07 04:50:54 +08:00
feat(prettier): update to version 1.6
This commit is contained in:
27
types/prettier/index.d.ts
vendored
27
types/prettier/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for prettier 1.5
|
||||
// Type definitions for prettier 1.6
|
||||
// Project: https://github.com/prettier/prettier
|
||||
// Definitions by: Ika <https://github.com/ikatyang>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -97,6 +97,31 @@ export function check(source: string, options?: Options): boolean;
|
||||
*/
|
||||
export function formatWithCursor(source: string, options: CursorOptions): CursorResult;
|
||||
|
||||
export interface ResolveConfigOptions {
|
||||
/**
|
||||
* If set to `false`, all caching will be bypassed.
|
||||
*/
|
||||
useCache?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* `resolveConfig` can be used to resolve configuration for a given source file.
|
||||
* The function optionally accepts an input file path as an argument, which defaults to the current working directory.
|
||||
* A promise is returned which will resolve to:
|
||||
*
|
||||
* - An options object, providing a [config file](https://github.com/prettier/prettier#configuration-file) was found.
|
||||
* - `null`, if no file was found.
|
||||
*
|
||||
* The promise will be rejected if there was an error parsing the configuration file.
|
||||
*/
|
||||
export function resolveConfig(filePath?: string, options?: ResolveConfigOptions): Promise<null | Options>;
|
||||
|
||||
/**
|
||||
* As you repeatedly call `resolveConfig`, the file system structure will be cached for performance.
|
||||
* This function will clear the cache. Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.
|
||||
*/
|
||||
export function clearConfigCache(): void;
|
||||
|
||||
/**
|
||||
* `version` field in `package.json`
|
||||
*/
|
||||
|
||||
@@ -17,3 +17,11 @@ const customFormatted = prettier.format("lodash ( )", {
|
||||
return ast;
|
||||
}
|
||||
});
|
||||
|
||||
prettier.resolveConfig('path/to/somewhere').then(options => {
|
||||
if (options !== null) {
|
||||
const formatted = prettier.format('hello world', options);
|
||||
}
|
||||
});
|
||||
|
||||
prettier.clearConfigCache();
|
||||
|
||||
Reference in New Issue
Block a user