Skip to content

Commit 9ddb3a8

Browse files
thomasballingerConvex, Inc.
authored and
Convex, Inc.
committed
Don't prettierignore generated README and tsconfig.json (#29446)
Stop prettierignore-ing generated README and tsconfig.json GitOrigin-RevId: c7b3b807d2ac94a9e234b94814c152c19ef589d2
1 parent 6fbaf17 commit 9ddb3a8

File tree

7 files changed

+23
-48
lines changed

7 files changed

+23
-48
lines changed

demo/convex/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
# Welcome to your Convex functions directory!
42

53
Write your Convex functions here.
@@ -90,5 +88,3 @@ function handleButtonPress() {
9088
Use the Convex CLI to push your functions to a deployment. See everything
9189
the Convex CLI can do by running `npx convex -h` in your project root
9290
directory. To learn more, launch the docs with `npx convex docs`.
93-
94-
/* prettier-ignore-end */

demo/convex/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
{
42
/* This TypeScript project config describes the environment that
53
* Convex functions run in and is used to typecheck them.
@@ -25,5 +23,3 @@
2523
"include": ["./**/*"],
2624
"exclude": ["./_generated"]
2725
}
28-
29-
/* prettier-ignore-end */

npm-packages/convex/src/cli/lib/codegen.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export async function doFinalComponentCodegen(
259259
serverContents,
260260
"typescript",
261261
serverDTSPath,
262-
opts,
262+
{ prettierIgnore: true, ...opts },
263263
);
264264

265265
const apiDTSPath = path.join(codegenDir, "api.d.ts");
@@ -269,14 +269,10 @@ export async function doFinalComponentCodegen(
269269
rootComponent,
270270
componentDirectory,
271271
);
272-
await writeFormattedFile(
273-
ctx,
274-
tmpDir,
275-
apiContents,
276-
"typescript",
277-
apiDTSPath,
278-
opts,
279-
);
272+
await writeFormattedFile(ctx, tmpDir, apiContents, "typescript", apiDTSPath, {
273+
prettierIgnore: true,
274+
...opts,
275+
});
280276

281277
if (opts?.generateCommonJSApi || projectConfig.generateCommonJSApi) {
282278
const apiCjsDTSPath = path.join(codegenDir, "api_cjs.d.ts");
@@ -286,7 +282,7 @@ export async function doFinalComponentCodegen(
286282
apiContents,
287283
"typescript",
288284
apiCjsDTSPath,
289-
opts,
285+
{ prettierIgnore: true, ...opts },
290286
);
291287
}
292288
}
@@ -356,7 +352,7 @@ async function doDataModelCodegen(
356352
schemaContent.DTS,
357353
"typescript",
358354
path.join(codegenDir, "dataModel.d.ts"),
359-
opts,
355+
{ prettierIgnore: true, ...opts },
360356
);
361357
return ["dataModel.d.ts"];
362358
}
@@ -374,7 +370,7 @@ async function doServerCodegen(
374370
serverContent.JS,
375371
"typescript",
376372
path.join(codegenDir, "server.js"),
377-
opts,
373+
{ prettierIgnore: true, ...opts },
378374
);
379375

380376
await writeFormattedFile(
@@ -383,7 +379,7 @@ async function doServerCodegen(
383379
serverContent.DTS,
384380
"typescript",
385381
path.join(codegenDir, "server.d.ts"),
386-
opts,
382+
{ prettierIgnore: true, ...opts },
387383
);
388384

389385
return ["server.js", "server.d.ts"];
@@ -402,7 +398,7 @@ async function doInitialComponentServerCodegen(
402398
componentServerJS(),
403399
"typescript",
404400
path.join(codegenDir, "server.js"),
405-
opts,
401+
{ prettierIgnore: true, ...opts },
406402
);
407403

408404
// Don't write our stub if the file already exists: It probably
@@ -415,7 +411,7 @@ async function doInitialComponentServerCodegen(
415411
componentServerStubDTS(isRoot),
416412
"typescript",
417413
path.join(codegenDir, "server.d.ts"),
418-
opts,
414+
{ prettierIgnore: true, ...opts },
419415
);
420416
}
421417

@@ -437,7 +433,7 @@ async function doInitialComponentApiCodegen(
437433
apiJS,
438434
"typescript",
439435
path.join(codegenDir, "api.js"),
440-
opts,
436+
{ prettierIgnore: true, ...opts },
441437
);
442438

443439
// Don't write the `.d.ts` stub if it already exists.
@@ -450,7 +446,7 @@ async function doInitialComponentApiCodegen(
450446
apiStubDTS,
451447
"typescript",
452448
apiDTSPath,
453-
opts,
449+
{ prettierIgnore: true, ...opts },
454450
);
455451
}
456452

@@ -464,7 +460,7 @@ async function doInitialComponentApiCodegen(
464460
apiCjsJS,
465461
"typescript",
466462
path.join(codegenDir, "api_cjs.cjs"),
467-
opts,
463+
{ prettierIgnore: true, ...opts },
468464
);
469465

470466
const cjsStubPath = path.join(codegenDir, "api_cjs.d.cts");
@@ -475,7 +471,7 @@ async function doInitialComponentApiCodegen(
475471
apiStubDTS,
476472
"typescript",
477473
cjsStubPath,
478-
opts,
474+
{ prettierIgnore: true, ...opts },
479475
);
480476
}
481477
writtenFiles.push("api_cjs.cjs", "api_cjs.d.cts");
@@ -502,15 +498,15 @@ async function doApiCodegen(
502498
apiContent.JS,
503499
"typescript",
504500
path.join(codegenDir, "api.js"),
505-
opts,
501+
{ prettierIgnore: true, ...opts },
506502
);
507503
await writeFormattedFile(
508504
ctx,
509505
tmpDir,
510506
apiContent.DTS,
511507
"typescript",
512508
path.join(codegenDir, "api.d.ts"),
513-
opts,
509+
{ prettierIgnore: true, ...opts },
514510
);
515511
const writtenFiles = ["api.js", "api.d.ts"];
516512

@@ -522,15 +518,15 @@ async function doApiCodegen(
522518
apiCjsContent.JS,
523519
"typescript",
524520
path.join(codegenDir, "api_cjs.cjs"),
525-
opts,
521+
{ prettierIgnore: true, ...opts },
526522
);
527523
await writeFormattedFile(
528524
ctx,
529525
tmpDir,
530526
apiCjsContent.DTS,
531527
"typescript",
532528
path.join(codegenDir, "api_cjs.d.cts"),
533-
opts,
529+
{ prettierIgnore: true, ...opts },
534530
);
535531
writtenFiles.push("api_cjs.cjs", "api_cjs.d.cts");
536532
}
@@ -547,6 +543,7 @@ async function writeFormattedFile(
547543
options?: {
548544
dryRun?: boolean;
549545
debug?: boolean;
546+
prettierIgnore?: boolean;
550547
},
551548
) {
552549
// Run prettier so we don't have to think about formatting!
@@ -558,11 +555,13 @@ async function writeFormattedFile(
558555
pluginSearchDirs: false,
559556
});
560557
// Then add prettierignore comments so we don't fight with users' prettier configs
561-
formattedContents = `/* prettier-ignore-start */
558+
if (options?.prettierIgnore) {
559+
formattedContents = `/* prettier-ignore-start */
562560
563561
${formattedContents}
564562
/* prettier-ignore-end */
565563
`;
564+
}
566565
if (options?.debug) {
567566
// NB: The `test_codegen_projects_are_up_to_date` smoke test depends
568567
// on this output format.

npm-packages/system-udfs/convex/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
# Welcome to your Convex functions directory!
42

53
Write your Convex functions here.
@@ -90,5 +88,3 @@ function handleButtonPress() {
9088
Use the Convex CLI to push your functions to a deployment. See everything
9189
the Convex CLI can do by running `npx convex -h` in your project root
9290
directory. To learn more, launch the docs with `npx convex docs`.
93-
94-
/* prettier-ignore-end */

npm-packages/system-udfs/convex/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
{
42
/* This TypeScript project config describes the environment that
53
* Convex functions run in and is used to typecheck them.
@@ -25,5 +23,3 @@
2523
"include": ["./**/*"],
2624
"exclude": ["./_generated"]
2725
}
28-
29-
/* prettier-ignore-end */

npm-packages/udf-tests/convex/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
# Welcome to your Convex functions directory!
42

53
Write your Convex functions here.
@@ -90,5 +88,3 @@ function handleButtonPress() {
9088
Use the Convex CLI to push your functions to a deployment. See everything
9189
the Convex CLI can do by running `npx convex -h` in your project root
9290
directory. To learn more, launch the docs with `npx convex docs`.
93-
94-
/* prettier-ignore-end */

npm-packages/udf-tests/convex/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* prettier-ignore-start */
2-
31
{
42
/* This TypeScript project config describes the environment that
53
* Convex functions run in and is used to typecheck them.
@@ -25,5 +23,3 @@
2523
"include": ["./**/*"],
2624
"exclude": ["./_generated"]
2725
}
28-
29-
/* prettier-ignore-end */

0 commit comments

Comments
 (0)