Skip to content

Commit

Permalink
Add prettierignore comments to codegen (#29372)
Browse files Browse the repository at this point in the history
Add prettierignore comments to generated code to avoid needing to add these files to your own .prettierignore if you use different settings.

GitOrigin-RevId: cdafb53c104eb3119bea706a963e0b9361474e2d
  • Loading branch information
thomasballinger authored and Convex, Inc. committed Aug 30, 2024
1 parent 6290711 commit f9a7f12
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli/lib/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,16 @@ async function writeFormattedFile(
//
// This is a little sketchy because we are using the default prettier config
// (not our user's one) but it's better than nothing.
const formattedContents = await prettier.format(contents, {
let formattedContents = await prettier.format(contents, {
parser: filetype,
pluginSearchDirs: false,
});
// Then add prettierignore comments so we don't fight with users' prettier configs
formattedContents = `/* prettier-ignore-start */
${formattedContents}
/* prettier-ignore-end */
`;
if (options?.debug) {
// NB: The `test_codegen_projects_are_up_to_date` smoke test depends
// on this output format.
Expand Down

0 comments on commit f9a7f12

Please sign in to comment.