mirror of https://github.com/buster-so/buster.git
lint errors
This commit is contained in:
parent
83aca9300e
commit
e68032ab8d
|
@ -2,7 +2,8 @@
|
||||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||||
"extends": ["../../biome.json"],
|
"extends": ["../../biome.json"],
|
||||||
"files": {
|
"files": {
|
||||||
"include": ["src/**/*", "scripts/**/*"]
|
"include": ["src/**/*"],
|
||||||
|
"ignore": ["scripts/**/*"]
|
||||||
},
|
},
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,12 +11,14 @@ if (!connectionString) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable SSL for local development
|
// Disable SSL for local development
|
||||||
const isDevelopment = process.env.ENVIRONMENT === 'development' || process.env.NODE_ENV === 'development';
|
const isDevelopment =
|
||||||
|
process.env.ENVIRONMENT === 'development' || process.env.NODE_ENV === 'development';
|
||||||
|
|
||||||
// Append sslmode=disable for local development if not already present
|
// Append sslmode=disable for local development if not already present
|
||||||
const dbUrl = isDevelopment && !connectionString.includes('sslmode=')
|
const dbUrl =
|
||||||
? `${connectionString}?sslmode=disable`
|
isDevelopment && !connectionString.includes('sslmode=')
|
||||||
: connectionString;
|
? `${connectionString}?sslmode=disable`
|
||||||
|
: connectionString;
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
schema: './src/schema.ts',
|
schema: './src/schema.ts',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import * as path from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
import * as path from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
// Get the directory name for ES modules
|
// Get the directory name for ES modules
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
@ -61,18 +61,28 @@ export function initializePool<T extends Record<string, postgres.PostgresType>>(
|
||||||
|
|
||||||
// Create postgres client with pool configuration
|
// Create postgres client with pool configuration
|
||||||
// Disable SSL for local development
|
// Disable SSL for local development
|
||||||
const isDevelopment = process.env.ENVIRONMENT === 'development' || process.env.NODE_ENV === 'development';
|
const isDevelopment =
|
||||||
|
process.env.ENVIRONMENT === 'development' || process.env.NODE_ENV === 'development';
|
||||||
console.log('Database connection - ENVIRONMENT:', process.env.ENVIRONMENT, 'NODE_ENV:', process.env.NODE_ENV, 'isDevelopment:', isDevelopment);
|
|
||||||
|
console.log(
|
||||||
|
'Database connection - ENVIRONMENT:',
|
||||||
|
process.env.ENVIRONMENT,
|
||||||
|
'NODE_ENV:',
|
||||||
|
process.env.NODE_ENV,
|
||||||
|
'isDevelopment:',
|
||||||
|
isDevelopment
|
||||||
|
);
|
||||||
|
|
||||||
globalPool = postgres(connectionString, {
|
globalPool = postgres(connectionString, {
|
||||||
max: poolSize,
|
max: poolSize,
|
||||||
idle_timeout: 30,
|
idle_timeout: 30,
|
||||||
connect_timeout: 30,
|
connect_timeout: 30,
|
||||||
prepare: true,
|
prepare: true,
|
||||||
ssl: isDevelopment ? false : {
|
ssl: isDevelopment
|
||||||
rejectUnauthorized: false, // Allow self-signed certificates
|
? false
|
||||||
},
|
: {
|
||||||
|
rejectUnauthorized: false, // Allow self-signed certificates
|
||||||
|
},
|
||||||
...config,
|
...config,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ vi.mock('../../connection', () => ({
|
||||||
|
|
||||||
// Mock drizzle-orm
|
// Mock drizzle-orm
|
||||||
vi.mock('drizzle-orm', async (importOriginal) => {
|
vi.mock('drizzle-orm', async (importOriginal) => {
|
||||||
const actual = (await importOriginal()) as any;
|
const actual = (await importOriginal()) as Record<string, unknown>;
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
sql: actual.sql,
|
sql: actual.sql,
|
||||||
|
|
|
@ -10,7 +10,7 @@ vi.mock('../../connection', () => ({
|
||||||
|
|
||||||
// Mock drizzle-orm
|
// Mock drizzle-orm
|
||||||
vi.mock('drizzle-orm', async (importOriginal) => {
|
vi.mock('drizzle-orm', async (importOriginal) => {
|
||||||
const actual = (await importOriginal()) as any;
|
const actual = (await importOriginal()) as Record<string, unknown>;
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
sql: actual.sql,
|
sql: actual.sql,
|
||||||
|
|
|
@ -82,10 +82,10 @@ describe('getOrganizationDocs', () => {
|
||||||
organizationId: '123e4567-e89b-12d3-a456-426614174000',
|
organizationId: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
};
|
};
|
||||||
|
|
||||||
let mockSelect: any;
|
let mockSelect: ReturnType<typeof vi.fn>;
|
||||||
let mockFrom: any;
|
let mockFrom: ReturnType<typeof vi.fn>;
|
||||||
let mockWhere: any;
|
let mockWhere: ReturnType<typeof vi.fn>;
|
||||||
let mockOrderBy: any;
|
let mockOrderBy: ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
|
@ -124,10 +124,10 @@ describe('upsertDoc', () => {
|
||||||
organizationId: '123e4567-e89b-12d3-a456-426614174000',
|
organizationId: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
};
|
};
|
||||||
|
|
||||||
let mockInsert: any;
|
let mockInsert: ReturnType<typeof vi.fn>;
|
||||||
let mockValues: any;
|
let mockValues: ReturnType<typeof vi.fn>;
|
||||||
let mockOnConflictDoUpdate: any;
|
let mockOnConflictDoUpdate: ReturnType<typeof vi.fn>;
|
||||||
let mockReturning: any;
|
let mockReturning: ReturnType<typeof vi.fn>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
|
|
|
@ -87,9 +87,10 @@ export async function createShortcut(input: CreateShortcutInput) {
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
return created;
|
return created;
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
// Handle unique constraint violation
|
// Handle unique constraint violation
|
||||||
if (error?.code === '23505' && error?.constraint?.includes('unique')) {
|
const dbError = error as { code?: string; constraint?: string };
|
||||||
|
if (dbError?.code === '23505' && dbError?.constraint?.includes('unique')) {
|
||||||
throw new Error(`Shortcut with name '${validated.name}' already exists`);
|
throw new Error(`Shortcut with name '${validated.name}' already exists`);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -16,7 +16,7 @@ export type UpdateShortcutInput = z.infer<typeof UpdateShortcutInputSchema>;
|
||||||
export async function updateShortcut(input: UpdateShortcutInput) {
|
export async function updateShortcut(input: UpdateShortcutInput) {
|
||||||
const validated = UpdateShortcutInputSchema.parse(input);
|
const validated = UpdateShortcutInputSchema.parse(input);
|
||||||
|
|
||||||
const updateData: Record<string, any> = {
|
const updateData: Record<string, unknown> = {
|
||||||
updatedBy: validated.updatedBy,
|
updatedBy: validated.updatedBy,
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue