-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I'm using prettier-plugin-embed with sql-formatter and sql-template-tag, which has worked well. I've run into one instance where
sql``template literals are not formatted properly. I use these in two different ways.
- To hold a SQL parameter
- To hold part of a sql query
In the first case, the template variable is on the same line, as expected. In the second case, the variable still appears on the same line, making the code harder to read.
function test() {
const myId = 123;
const otherClause = myId === 123 ? sql`AND id2 = 1234` : empty;
const query = sql`
SELECT *
FROM table_name
WHERE
id = ${myId}
${otherClause}
`;
}After formatting, this becomes
const query = sql`
SELECT
*
FROM
table_name
WHERE
id = ${myId} ${otherClause}
`;but I would like it to be
const query = sql`
SELECT
*
FROM
table_name
WHERE
id = ${myId}
${otherClause}
`;Is there a way to improve the formatting of the otherClause here? For example, if a template literal variable is on the same line, keep it that way. If it is on a new line, insert a new line to the formatted output.
Metadata
Metadata
Assignees
Labels
No labels