diff --git a/flow-typed/npm/prettier_v1.x.x.js b/flow-typed/npm/prettier_v1.x.x.js index f7e7b6e..098b335 100644 --- a/flow-typed/npm/prettier_v1.x.x.js +++ b/flow-typed/npm/prettier_v1.x.x.js @@ -1,26 +1,48 @@ -// flow-typed signature: 066c92e9ccb5f0711df8d73cbca837d6 -// flow-typed version: 9e32affdbd/prettier_v1.x.x/flow_>=v0.56.x +// flow-typed signature: ec743a1b5c1197353e0849812930f32a +// flow-typed version: c6154227d1/prettier_v1.x.x/flow_>=v0.104.x declare module "prettier" { - declare export type AST = Object; - declare export type Doc = Object; - declare export type FastPath = Object; + declare export type AST = { [key: string]: any, ... }; + declare export type Doc = { + [key: string]: any, + ... + }; + declare export type FastPath = { + stack: any[], + getName(): null | string | number | Symbol, + getValue(): T, + getNode(count?: number): null | T, + getParentNode(count?: number): null | T, + call(callback: (path: FastPath) => U, ...names: Array): U, + each(callback: (path: FastPath) => void, ...names: Array): void, + map(callback: (path: FastPath, index: number) => U, ...names: Array): U[], + ... + }; declare export type PrettierParserName = - | "babylon" + | "babylon" // deprecated + | "babel" + | "babel-flow" | "flow" | "typescript" - | "postcss" + | "postcss" // deprecated | "css" | "less" | "scss" | "json" + | "json5" + | "json-stringify" | "graphql" | "markdown" - | "vue"; + | "vue" + | "html" + | "angular" + | "mdx" + | "yaml"; declare export type PrettierParser = { - [name: PrettierParserName]: (text: string, options?: Object) => AST + [name: PrettierParserName]: (text: string, options?: { [key: string]: any, ... }) => AST, + ... }; declare export type CustomParser = ( @@ -51,31 +73,51 @@ declare module "prettier" { declare export type Plugin = { languages: SupportLanguage, - parsers: { [parserName: string]: Parser }, - printers: { [astFormat: string]: Printer } + parsers: { [parserName: string]: Parser, ... }, + printers: { [astFormat: string]: Printer, ... }, + options?: SupportOption[], + ... }; declare export type Parser = { parse: ( text: string, - parsers: { [parserName: string]: Parser }, - options: Object + parsers: { [parserName: string]: Parser, ... }, + options: { [key: string]: any, ... } ) => AST, - astFormat: string + astFormat: string, + hasPragma?: (text: string) => boolean, + locStart: (node: any) => number, + locEnd: (node: any) => number, + preprocess?: (text: string, options: { [key: string]: any, ... }) => string, + ... }; declare export type Printer = { print: ( - path: FastPath, - options: Object, - print: (path: FastPath) => Doc + path: FastPath<>, + options: { [key: string]: any, ... }, + print: (path: FastPath<>) => Doc ) => Doc, embed: ( - path: FastPath, - print: (path: FastPath) => Doc, - textToDoc: (text: string, options: Object) => Doc, - options: Object - ) => ?Doc + path: FastPath<>, + print: (path: FastPath<>) => Doc, + textToDoc: (text: string, options: { [key: string]: any, ... }) => Doc, + options: { [key: string]: any, ... } + ) => ?Doc, + insertPragma?: (text: string) => string, + massageAstNode?: (node: any, newNode: any, parent: any) => any, + hasPrettierIgnore?: (path: FastPath<>) => boolean, + canAttachComment?: (node: any) => boolean, + willPrintOwnComments?: (path: FastPath<>) => boolean, + printComments?: (path: FastPath<>, print: (path: FastPath<>) => Doc, options: { [key: string]: any, ... }, needsSemi: boolean) => Doc, + handleComments?: { + ownLine?: (commentNode: any, text: string, options: { [key: string]: any, ... }, ast: any, isLastComment: boolean) => boolean, + endOfLine?: (commentNode: any, text: string, options: { [key: string]: any, ... }, ast: any, isLastComment: boolean) => boolean, + remaining?: (commentNode: any, text: string, options: { [key: string]: any, ... }, ast: any, isLastComment: boolean) => boolean, + ... + }, + ... }; declare export type CursorOptions = {| @@ -121,7 +163,8 @@ declare module "prettier" { extensions: Array, filenames?: Array, linguistLanguageId: number, - vscodeLanguageIds: Array + vscodeLanguageIds: Array, + ... }; declare export type SupportOption = {| @@ -168,7 +211,8 @@ declare module "prettier" { formatWithCursor: (source: string, options: CursorOptions) => CursorResult, resolveConfig: { (filePath: string, options?: ResolveConfigOptions): Promise, - sync(filePath: string, options?: ResolveConfigOptions): ?Options + sync(filePath: string, options?: ResolveConfigOptions): ?Options, + ... }, clearConfigCache: () => void, getSupportInfo: (version?: string) => SupportInfo diff --git a/src/graphql/generateFlowTypes.test.js b/src/graphql/generateFlowTypes.test.js index 079e562..2c589d5 100644 --- a/src/graphql/generateFlowTypes.test.js +++ b/src/graphql/generateFlowTypes.test.js @@ -5,7 +5,7 @@ import * as Schema from "./schema"; describe("graphql/generateFlowTypes", () => { function run(schema: Schema.Schema): string { - return generateFlowTypes(schema, {parser: "babylon", trailingComma: "es5"}); + return generateFlowTypes(schema, {parser: "babel", trailingComma: "es5"}); } describe("generateFlowTypes", () => { @@ -55,8 +55,8 @@ describe("graphql/generateFlowTypes", () => { const schema = s.schema({ E: s.enum(["ONE", "TWO"]), }); - const options1 = {parser: "babylon", singleQuote: false}; - const options2 = {parser: "babylon", singleQuote: true}; + const options1 = {parser: "babel", singleQuote: false}; + const options2 = {parser: "babel", singleQuote: true}; const output1 = generateFlowTypes(schema, options1); const output2 = generateFlowTypes(schema, options2); expect(output1).not.toEqual(output2); diff --git a/src/plugins/github/generateGraphqlFlowTypes.js b/src/plugins/github/generateGraphqlFlowTypes.js index e19427c..8c8d42b 100644 --- a/src/plugins/github/generateGraphqlFlowTypes.js +++ b/src/plugins/github/generateGraphqlFlowTypes.js @@ -7,7 +7,7 @@ import schema from "./schema"; export default function generateGraphqlFlowTypes() { const prettierOptions = { - ...{parser: "babylon"}, + ...{parser: "babel"}, ...(prettier.resolveConfig.sync(__filename) || {}), }; return generateFlowTypes(schema(), prettierOptions);