Skip to content

Commit 3bb1a66

Browse files
chore: fix more linter issues (#47)
* chore: add 'chrome' to globals in biome configuration * refactor: streamline compression stream initialization and enhance type safety in Stripe webhook handling * chore: fix moar lint issues * chore: address coderabbit suggestions * refactor: optimize isMaskedSecret function using useCallback * chore: apply code formatting and clean up imports across multiple components --------- Co-authored-by: Hyteq <[email protected]>
1 parent a610868 commit 3bb1a66

File tree

133 files changed

+1082
-774
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1082
-774
lines changed

apps/api/src/agent/handlers/metric-handler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ function extractMetricValue(
5353
queryData: unknown[],
5454
defaultValue: unknown
5555
): unknown {
56-
if (!(queryData.length && queryData[0])) return defaultValue;
56+
if (!(queryData.length && queryData[0])) {
57+
return defaultValue;
58+
}
5759

5860
const firstRow = queryData[0] as Record<string, unknown>;
5961
const valueKey =

apps/api/src/agent/prompts/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const comprehensiveUnifiedPrompt = (
4040
mode: 'analysis_only' | 'execute_chat' | 'execute_agent_step',
4141
previousMessages?: any[],
4242
agentToolResult?: any,
43-
model?: 'chat' | 'agent' | 'agent-max'
43+
_model?: 'chat' | 'agent' | 'agent-max'
4444
) => `
4545
<persona>
4646
You are Nova, a world-class, specialized AI analytics assistant for the website ${websiteHostname}. You are precise, analytical, and secure. Your sole purpose is to help users understand their website's analytics data by providing insights, generating SQL queries, and creating visualizations.

apps/api/src/agent/utils/sql-validator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export function validateSQL(sql: string): boolean {
2222

2323
// Check for dangerous keyword patterns
2424
for (const keyword of FORBIDDEN_SQL_KEYWORDS) {
25-
if (upperSQL.includes(keyword)) return false;
25+
if (upperSQL.includes(keyword)) {
26+
return false;
27+
}
2628
}
2729

2830
// Must start with SELECT or WITH (for CTEs)

apps/api/src/lib/website-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function deriveWebsiteContext({ request }: { request: Request }) {
143143
getCachedWebsite(website_id),
144144
website_id && session?.user
145145
? getTimezone(request, session)
146-
: getTimezone(request, null)
146+
: getTimezone(request, null),
147147
]);
148148

149149
if (!website) {

apps/api/src/middleware/logging.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

apps/api/src/middleware/rate-limit.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { auth } from '@databuddy/auth';
2-
import { getRateLimitIdentifier, rateLimiters } from '@databuddy/rpc';
32
import { cacheable } from '@databuddy/redis';
3+
import { getRateLimitIdentifier, rateLimiters } from '@databuddy/rpc';
44
import { Elysia } from 'elysia';
55

66
export interface RateLimitOptions {
@@ -39,7 +39,6 @@ export function createRateLimitMiddleware(options: RateLimitOptions) {
3939
if (!options.skipAuth) {
4040
const session = await getCachedAuthSession(request.headers);
4141
userId = session?.user?.id;
42-
4342
}
4443

4544
const identifier = getRateLimitIdentifier(userId, request.headers);

apps/api/src/query/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ function applyGeoNormalization(
192192
): Record<string, any>[] {
193193
return data.map((row) => {
194194
// Only normalize if row has a 'name' field (country/region/etc)
195-
if (!row.name) return row;
195+
if (!row.name) {
196+
return row;
197+
}
196198
const code = getCountryCode(row.name);
197199
const name = getCountryName(code);
198200
return {

apps/basket/src/hooks/auth.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ type WebsiteWithOwner = Website & {
1515
ownerId: string | null;
1616
};
1717

18+
const REGEX_WWW_PREFIX = /^www\./;
19+
const REGEX_DOMAIN_LABEL = /^[a-zA-Z0-9-]+$/;
20+
1821
/**
1922
* Resolves the owner's user ID for a given website.
2023
* The owner is the user if it's a personal project, or the organization's owner
@@ -161,7 +164,7 @@ export function normalizeDomain(domain: string): string {
161164

162165
try {
163166
const hostname = new URL(urlString).hostname;
164-
const finalDomain = hostname.replace(/^www\./, '');
167+
const finalDomain = hostname.replace(REGEX_WWW_PREFIX, '');
165168

166169
if (!isValidDomainFormat(finalDomain)) {
167170
throw new Error(
@@ -213,7 +216,7 @@ export function isValidDomainFormat(domain: string): boolean {
213216
return false;
214217
}
215218
if (
216-
!/^[a-zA-Z0-9-]+$/.test(label) ||
219+
!REGEX_DOMAIN_LABEL.test(label) ||
217220
label.startsWith('-') ||
218221
label.endsWith('-')
219222
) {

apps/basket/src/polyfills/compression.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ globalThis.CompressionStream ??= class CompressionStream {
1212
writable;
1313

1414
constructor(format) {
15-
make(
16-
this,
17-
format === 'deflate'
18-
? zlib.createDeflate()
19-
: format === 'gzip'
20-
? zlib.createGzip()
21-
: zlib.createDeflateRaw()
22-
);
15+
let handle;
16+
if (format === 'deflate') {
17+
handle = zlib.createDeflate();
18+
} else if (format === 'gzip') {
19+
handle = zlib.createGzip();
20+
} else {
21+
handle = zlib.createDeflateRaw();
22+
}
23+
make(this, handle);
2324
}
2425
};
2526

@@ -28,13 +29,14 @@ globalThis.DecompressionStream ??= class DecompressionStream {
2829
writable;
2930

3031
constructor(format) {
31-
make(
32-
this,
33-
format === 'deflate'
34-
? zlib.createInflate()
35-
: format === 'gzip'
36-
? zlib.createGunzip()
37-
: zlib.createInflateRaw()
38-
);
32+
let handle;
33+
if (format === 'deflate') {
34+
handle = zlib.createInflate();
35+
} else if (format === 'gzip') {
36+
handle = zlib.createGunzip();
37+
} else {
38+
handle = zlib.createInflateRaw();
39+
}
40+
make(this, handle);
3941
}
4042
};

apps/basket/src/routes/basket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ async function checkDuplicate(
447447
async function logBlockedTraffic(
448448
request: Request,
449449
body: any,
450-
query: any,
450+
_query: any,
451451
blockReason: string,
452452
blockCategory: string,
453453
botName?: string,

0 commit comments

Comments
 (0)