diff --git a/src/renderers/renderFieldsOnly.ts b/src/renderers/renderFieldsOnly.ts index 313a5473..82a0d04b 100644 --- a/src/renderers/renderFieldsOnly.ts +++ b/src/renderers/renderFieldsOnly.ts @@ -1,6 +1,6 @@ import { ContentType } from "contentful" -import { format } from "prettier" +import { format, resolveConfig } from "prettier" import renderContentType from "./contentful-fields-only/renderContentType" @@ -9,7 +9,9 @@ export default async function renderFieldsOnly(contentTypes: ContentType[]) { const source = renderAllContentTypes(sortedContentTypes) - return format(source, { parser: "typescript" }) + const prettierConfig = await resolveConfig(process.cwd()) + + return format(source, { ...prettierConfig, parser: "typescript" }) } function renderAllContentTypes(contentTypes: ContentType[]): string { diff --git a/test/renderers/renderFieldsOnly.test.ts b/test/renderers/renderFieldsOnly.test.ts index e0055e19..b40755d2 100644 --- a/test/renderers/renderFieldsOnly.test.ts +++ b/test/renderers/renderFieldsOnly.test.ts @@ -39,9 +39,9 @@ describe("renderFieldsOnly()", () => { "export interface IMyContentType { fields: { /** Array field */ - arrayField: (\\"one\\" | \\"of\\" | \\"the\\" | \\"above\\")[]; - }; - [otherKeys: string]: any; + arrayField: (\\"one\\" | \\"of\\" | \\"the\\" | \\"above\\")[] + } + [otherKeys: string]: any } " `)