-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support shorthand for CallExpression as tag
close #137
- Loading branch information
Showing
5 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"prettier-plugin-embed": minor | ||
--- | ||
|
||
feat: support shorthand for CallExpression as tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`fixtures > should work 1`] = ` | ||
"sql.type(SESSION)\` | ||
INSERT INTO | ||
sessions (account_id, expires_at) | ||
VALUES | ||
( | ||
\${accountId}, | ||
\${expiresAt.toJSON()} | ||
) RETURNING id, | ||
created_at AS "createdAt", | ||
updated_at AS "updatedAt", | ||
expires_at AS "expiresAt", | ||
account_id AS "accountId" | ||
\`; | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
|
||
import prettier from "prettier"; | ||
import sql from "prettier-plugin-sql"; | ||
import * as embed from "../src"; | ||
|
||
import { describe, expect, it } from "vitest"; | ||
|
||
describe("fixtures", () => { | ||
it("should work", async () => { | ||
for (const file of await fs.readdir("test/fixtures")) { | ||
const filepath = path.resolve("test/fixtures", file); | ||
const code = await fs.readFile(filepath, "utf-8"); | ||
const formatted = await prettier.format(code, { | ||
filepath, | ||
plugins: [embed, sql], | ||
embeddedSqlTags: ["sql.type"], | ||
}); | ||
expect(formatted).toMatchSnapshot(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sql.type(SESSION)` | ||
INSERT INTO sessions (account_id, expires_at) | ||
VALUES (${accountId}, ${expiresAt.toJSON()}) | ||
RETURNING | ||
id, | ||
created_at AS "createdAt", | ||
updated_at AS "updatedAt", | ||
expires_at AS "expiresAt", | ||
account_id AS "accountId" | ||
`; |