fix: resolve lint and typecheck errors in API routes and tests
- Remove unused imports (users, and) from api-tokens model - Fix password_hash destructure lint error in user routes - Fix apiErrorResponse mock pattern in all 12 test files (use instanceof) - Remove stale eslint-disable directives from test files - Add eslint override for tests (no-explicit-any, no-require-imports) - Fix unused vars in settings and tokens tests - Fix unused tokenB in integration test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,11 +15,11 @@ vi.mock('@/src/lib/api-auth', () => {
|
||||
requireApiAdmin: vi.fn().mockResolvedValue({ userId: 1, role: 'admin', authMethod: 'bearer' }),
|
||||
requireApiUser: vi.fn().mockResolvedValue({ userId: 1, role: 'admin', authMethod: 'bearer' }),
|
||||
apiErrorResponse: vi.fn((error: unknown) => {
|
||||
const { NextResponse } = require('next/server');
|
||||
if (error && typeof error === 'object' && 'status' in error) {
|
||||
return NextResponse.json({ error: (error as Error).message }, { status: (error as any).status });
|
||||
const { NextResponse: NR } = require('next/server');
|
||||
if (error instanceof ApiAuthError) {
|
||||
return NR.json({ error: error.message }, { status: error.status });
|
||||
}
|
||||
return NextResponse.json({ error: error instanceof Error ? error.message : 'Internal server error' }, { status: 500 });
|
||||
return NR.json({ error: error instanceof Error ? error.message : 'Internal server error' }, { status: 500 });
|
||||
}),
|
||||
ApiAuthError,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user