Skip to content

Commit f913454

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Use local prettier settings for generated code (#30888)
Use local prettier settings to format generated files. GitOrigin-RevId: 35261af24f1bd489f2f1f78f902375b4d8410a07
1 parent 58ad76f commit f913454

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/cli/lib/codegen.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async function doReadmeCodegen(
309309
readmeCodegen(),
310310
"markdown",
311311
readmePath,
312-
opts,
312+
{ ignoreLocalConfig: true, ...opts },
313313
);
314314
}
315315

@@ -331,7 +331,7 @@ async function doTsconfigCodegen(
331331
tsconfigCodegen(),
332332
"json",
333333
tsconfigPath,
334-
opts,
334+
{ ignoreLocalConfig: true, ...opts },
335335
);
336336
}
337337

@@ -547,15 +547,17 @@ async function writeFormattedFile(
547547
options?: {
548548
dryRun?: boolean;
549549
debug?: boolean;
550+
ignoreLocalConfig?: boolean;
550551
},
551552
) {
552553
// Run prettier so we don't have to think about formatting!
553-
//
554-
// This is a little sketchy because we are using the default prettier config
555-
// (not our user's one) but it's better than nothing.
554+
// If we can find them, use the developer's Prettier configuration.
555+
const config = options?.ignoreLocalConfig
556+
? null
557+
: await prettier.resolveConfig(destination);
556558
const formattedContents = await prettier.format(contents, {
557559
parser: filetype,
558-
pluginSearchDirs: false,
560+
...config,
559561
});
560562
if (options?.debug) {
561563
// NB: The `test_codegen_projects_are_up_to_date` smoke test depends

0 commit comments

Comments
 (0)