feat(prettier): update to version 1.6

This commit is contained in:
ikatyang
2017-08-29 13:24:51 +08:00
parent 96cffadf50
commit 22671e3941
2 changed files with 34 additions and 1 deletions

View File

@@ -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`
*/

View File

@@ -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();