From 83b6ca855dbdd88b2b5a11d4c773046b860162cd Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Sun, 14 Apr 2019 13:03:12 +0100 Subject: [PATCH] feat: update prettier with standalone files --- types/prettier/index.d.ts | 1 + types/prettier/parser-angular.d.ts | 5 ++++ types/prettier/parser-babylon.d.ts | 5 ++++ types/prettier/parser-flow.d.ts | 5 ++++ types/prettier/parser-glimmer.d.ts | 5 ++++ types/prettier/parser-graphql.d.ts | 5 ++++ types/prettier/parser-html.d.ts | 5 ++++ types/prettier/parser-markdown.d.ts | 5 ++++ types/prettier/parser-postcss.d.ts | 5 ++++ types/prettier/parser-typescript.d.ts | 5 ++++ types/prettier/parser-yaml.d.ts | 5 ++++ types/prettier/standalone.d.ts | 43 +++++++++++++++++++++++++++ 12 files changed, 94 insertions(+) create mode 100644 types/prettier/parser-angular.d.ts create mode 100644 types/prettier/parser-babylon.d.ts create mode 100644 types/prettier/parser-flow.d.ts create mode 100644 types/prettier/parser-glimmer.d.ts create mode 100644 types/prettier/parser-graphql.d.ts create mode 100644 types/prettier/parser-html.d.ts create mode 100644 types/prettier/parser-markdown.d.ts create mode 100644 types/prettier/parser-postcss.d.ts create mode 100644 types/prettier/parser-typescript.d.ts create mode 100644 types/prettier/parser-yaml.d.ts create mode 100644 types/prettier/standalone.d.ts diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index 97e60d4837..7ab257bb00 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for prettier 1.16 // Project: https://github.com/prettier/prettier, https://prettier.io // Definitions by: Ika +// Ifiok Jr. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/prettier/parser-angular.d.ts b/types/prettier/parser-angular.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-angular.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-babylon.d.ts b/types/prettier/parser-babylon.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-babylon.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-flow.d.ts b/types/prettier/parser-flow.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-flow.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-glimmer.d.ts b/types/prettier/parser-glimmer.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-glimmer.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-graphql.d.ts b/types/prettier/parser-graphql.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-graphql.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-html.d.ts b/types/prettier/parser-html.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-html.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-markdown.d.ts b/types/prettier/parser-markdown.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-markdown.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-postcss.d.ts b/types/prettier/parser-postcss.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-postcss.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-typescript.d.ts b/types/prettier/parser-typescript.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-typescript.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/parser-yaml.d.ts b/types/prettier/parser-yaml.d.ts new file mode 100644 index 0000000000..72f81da10e --- /dev/null +++ b/types/prettier/parser-yaml.d.ts @@ -0,0 +1,5 @@ +import { Plugin } from './'; + +declare const plugin: Plugin; +export as namespace plugin; +export = plugin; diff --git a/types/prettier/standalone.d.ts b/types/prettier/standalone.d.ts new file mode 100644 index 0000000000..f985babdd5 --- /dev/null +++ b/types/prettier/standalone.d.ts @@ -0,0 +1,43 @@ +import { CursorOptions, CursorResult, Options, Plugin } from './'; + +type Omit = Pick< + GType, + Exclude +>; + +type MakeRequired = Omit< + GType, + GKeys +> & + { [P in GKeys]-?: GType[P] }; + +type MR = MakeRequired; + +/** + * formatWithCursor both formats the code, and translates a cursor position from unformatted code to formatted code. + * This is useful for editor integrations, to prevent the cursor from moving when code is formatted + * + * The cursorOffset option should be provided, to specify where the cursor is. This option cannot be used with rangeStart and rangeEnd. + * + * ```js + * prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babel" }); + * ``` + * `-> { formatted: '1;\n', cursorOffset: 1 }` + */ +export function formatWithCursor( + source: string, + options: MR, +): CursorResult; + +/** + * `format` is used to format text using Prettier. [Options](https://github.com/prettier/prettier#options) may be provided to override the defaults. + */ +export function format(source: string, options?: MR): string; + +/** + * `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`. + * This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios. + */ +export function check(source: string, options?: MR): boolean; + +export { Plugin };