Fix lint errors and add ast-grep rule for countAll
- Fix template literal expressions: wrap Date.now() in String() - Add missing afterAll import in admin.test.ts - Fix countOwners to use countAll() without misleading <number> type - Add ast-grep rule to prevent countAll<number>() usage - Fix formatting issues from merge conflict resolution Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
8
.ast-grep/rules/no-countall-number.yml
Normal file
8
.ast-grep/rules/no-countall-number.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
id: no-countall-number
|
||||||
|
language: typescript
|
||||||
|
severity: error
|
||||||
|
message: "Don't use countAll<number>() - use countAll() instead. PostgreSQL COUNT returns bigint (string), so the type annotation is misleading."
|
||||||
|
note: "Use Number() to convert the result if you need a number type."
|
||||||
|
rule:
|
||||||
|
pattern: countAll<number>()
|
||||||
|
fix: countAll()
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -68,7 +68,9 @@ export async function signupWithPassword(
|
|||||||
// Handle duplicate email (unique constraint violation)
|
// Handle duplicate email (unique constraint violation)
|
||||||
// Use generic error to prevent email enumeration
|
// Use generic error to prevent email enumeration
|
||||||
if (error instanceof Error && error.message.includes("users_email_key")) {
|
if (error instanceof Error && error.message.includes("users_email_key")) {
|
||||||
throw new ORPCError("BAD_REQUEST", { message: "Unable to create account" });
|
throw new ORPCError("BAD_REQUEST", {
|
||||||
|
message: "Unable to create account",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -209,7 +211,9 @@ export async function signupWithPasskey(
|
|||||||
// Handle duplicate email (unique constraint violation)
|
// Handle duplicate email (unique constraint violation)
|
||||||
// Use generic error to prevent email enumeration
|
// Use generic error to prevent email enumeration
|
||||||
if (error instanceof Error && error.message.includes("users_email_key")) {
|
if (error instanceof Error && error.message.includes("users_email_key")) {
|
||||||
throw new ORPCError("BAD_REQUEST", { message: "Unable to create account" });
|
throw new ORPCError("BAD_REQUEST", {
|
||||||
|
message: "Unable to create account",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,11 +115,11 @@ export async function countOwners(
|
|||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const result = await db
|
const result = await db
|
||||||
.selectFrom("org_members")
|
.selectFrom("org_members")
|
||||||
.select((eb) => eb.fn.countAll<number>().as("count"))
|
.select((eb) => eb.fn.countAll().as("count"))
|
||||||
.where("org_id", "=", orgId)
|
.where("org_id", "=", orgId)
|
||||||
.where("role", "=", "owner")
|
.where("role", "=", "owner")
|
||||||
.executeTakeFirstOrThrow();
|
.executeTakeFirstOrThrow();
|
||||||
|
|
||||||
// PostgreSQL COUNT returns bigint which may be a string; ensure numeric comparison works
|
// PostgreSQL COUNT returns bigint (string), convert to number
|
||||||
return Number(result.count);
|
return Number(result.count);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
\restrict 7omiXDURqmmr2m2jWDDMoltRzeUAT80fRWiPifpD7IpQGCLgxQNBFsA5uBgakPg
|
\restrict NNYnwssF6iMx0TXsk1nTprUEDwxna9uejAmsIiUlMLcPLlQlnnRVCusYtzweHXM
|
||||||
|
|
||||||
-- Dumped from database version 17.7
|
-- Dumped from database version 17.7
|
||||||
-- Dumped by pg_dump version 17.7
|
-- Dumped by pg_dump version 17.7
|
||||||
@@ -1084,7 +1084,7 @@ ALTER TABLE ONLY public.user_devices
|
|||||||
-- PostgreSQL database dump complete
|
-- PostgreSQL database dump complete
|
||||||
--
|
--
|
||||||
|
|
||||||
\unrestrict 7omiXDURqmmr2m2jWDDMoltRzeUAT80fRWiPifpD7IpQGCLgxQNBFsA5uBgakPg
|
\unrestrict NNYnwssF6iMx0TXsk1nTprUEDwxna9uejAmsIiUlMLcPLlQlnnRVCusYtzweHXM
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
ruleDirs:
|
ruleDirs:
|
||||||
- /Users/igm/proj/reviq/publisher-dashboard/.ast-grep/rules/
|
- .ast-grep/rules/
|
||||||
testConfigs:
|
testConfigs:
|
||||||
- testDir: /Users/igm/proj/reviq/publisher-dashboard/.ast-grep/rule-tests/
|
- testDir: .ast-grep/rule-tests/
|
||||||
utilDirs:
|
utilDirs:
|
||||||
- /Users/igm/proj/reviq/publisher-dashboard/.ast-grep/utils/
|
- .ast-grep/utils/
|
||||||
|
|||||||
Reference in New Issue
Block a user