First off, this library is awesome, thanks for creating it! It's been really useful for customizing our Prisma schema formatting beyond what prisma format can do. I did run into this edge case with trailing comments though, I wonder how hard it would be to fix.
Summary
Trailing comments at the end of a line get forced onto the next line when parsing and then printing a schema.
Current behavior
The following code:
import { getSchema, printSchema } from '@mrleebo/prisma-ast';
const source = `
enum Role {
ADMIN
OWNER // similar to ADMIN, but can delete the project
MEMBER
USER // deprecated
}
`;
const schema = getSchema(source);
const output = printSchema(schema);
console.log(output);
outputs:
enum Role {
ADMIN
OWNER
// similar to ADMIN, but can delete the project
MEMBER
USER
// deprecated
}
Expected behavior
I would have expected that code to output one of these:
// Option 1: preserve trailing comments at end of line
enum Role {
ADMIN
OWNER // similar to ADMIN, but can delete the project
MEMBER
USER // deprecated
}
// Option 2: move trailing comments to the preceding line
enum Role {
ADMIN
// similar to ADMIN, but can delete the project
OWNER
MEMBER
// deprecated
USER
}
First off, this library is awesome, thanks for creating it! It's been really useful for customizing our Prisma schema formatting beyond what
prisma format
can do. I did run into this edge case with trailing comments though, I wonder how hard it would be to fix.Summary
Trailing comments at the end of a line get forced onto the next line when parsing and then printing a schema.
Current behavior
The following code:
outputs:
Expected behavior
I would have expected that code to output one of these: