Replace String() calls with .toString()/.toLocaleString() per ast-grep rule
- Add formatError() helper in CLI to safely handle unknown error types - Add uniqueTestId() helper for generating unique test identifiers - Replace String(id) with id.toString() for database ID conversions - Replace String(n) with n.toLocaleString() for user-facing number formatting - Fix TypeScript errors in test files (undefined checks, unused variables) - Update lint commands to include ast-grep scanning Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
initTestDb,
|
||||
KNOWN_AAGUIDS,
|
||||
TEST_RP,
|
||||
uniqueTestId,
|
||||
withTestTransaction,
|
||||
} from "@reviq/test-helpers";
|
||||
import { VirtualAuthenticator } from "@reviq/virtual-authenticator";
|
||||
@@ -60,7 +61,7 @@ async function createSession(
|
||||
db: Kysely<Database>,
|
||||
userId: number,
|
||||
): Promise<string> {
|
||||
const token = `test-session-${String(Date.now())}${String(Math.random())}`;
|
||||
const token = `test-session-${uniqueTestId()}`;
|
||||
const tokenHashValue = await hashToken(token);
|
||||
const expiresAt = new Date(Date.now() + SESSION_EXPIRY_MS);
|
||||
|
||||
@@ -87,7 +88,7 @@ async function createLoginRequest(
|
||||
userId: number,
|
||||
email: string,
|
||||
): Promise<{ id: number; token: string }> {
|
||||
const token = `test-login-${String(Date.now())}${String(Math.random())}`;
|
||||
const token = `test-login-${uniqueTestId()}`;
|
||||
const expiresAt = new Date(Date.now() + 10 * 60 * 1000); // 10 minutes
|
||||
|
||||
const result = await db
|
||||
@@ -236,7 +237,7 @@ describeE2E("webauthn", () => {
|
||||
const challengeRow = await db
|
||||
.selectFrom("webauthn_challenges")
|
||||
.select("id")
|
||||
.where("id", "=", String(challengeId))
|
||||
.where("id", "=", challengeId.toString())
|
||||
.executeTakeFirst();
|
||||
|
||||
expect(challengeRow).toBeDefined();
|
||||
@@ -382,7 +383,7 @@ describeE2E("webauthn", () => {
|
||||
const challengeRow = await db
|
||||
.selectFrom("webauthn_challenges")
|
||||
.select("id")
|
||||
.where("id", "=", String(challengeId))
|
||||
.where("id", "=", challengeId.toString())
|
||||
.executeTakeFirst();
|
||||
|
||||
expect(challengeRow).toBeUndefined();
|
||||
@@ -585,7 +586,7 @@ describeE2E("webauthn", () => {
|
||||
const challengeRow = await db
|
||||
.selectFrom("webauthn_challenges")
|
||||
.select("id")
|
||||
.where("id", "=", String(authChallengeId))
|
||||
.where("id", "=", authChallengeId.toString())
|
||||
.executeTakeFirst();
|
||||
|
||||
expect(challengeRow).toBeUndefined();
|
||||
|
||||
Reference in New Issue
Block a user