From 884b826d5f27286167e2b39ee2a9e01ef260ec74 Mon Sep 17 00:00:00 2001 From: Xhristin3 Date: Fri, 20 Feb 2026 19:54:09 -0800 Subject: [PATCH] fixed eslint --- apps/backend/eslint.config.mjs | 6 +++- apps/backend/test/admin.e2e-spec.ts | 4 +-- apps/backend/test/app.e2e-spec.ts | 3 +- apps/backend/test/auth.e2e-spec.ts | 21 +++++------ apps/backend/test/escrow.e2e-spec.ts | 54 ++++++++++++++-------------- 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/apps/backend/eslint.config.mjs b/apps/backend/eslint.config.mjs index df28404..6a9dc6e 100644 --- a/apps/backend/eslint.config.mjs +++ b/apps/backend/eslint.config.mjs @@ -25,10 +25,14 @@ export default tseslint.config( }, }, { + files: ['**/*.spec.ts', '**/*.e2e-spec.ts'], rules: { '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-floating-promises': 'warn', - '@typescript-eslint/no-unsafe-argument': 'warn' + '@typescript-eslint/no-unsafe-argument': 'warn', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-return': 'off', }, }, ); diff --git a/apps/backend/test/admin.e2e-spec.ts b/apps/backend/test/admin.e2e-spec.ts index 126bef9..6d35562 100644 --- a/apps/backend/test/admin.e2e-spec.ts +++ b/apps/backend/test/admin.e2e-spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; +import request from 'supertest'; import { AppModule } from '../src/app.module'; import { getRepository } from 'typeorm'; import { User, UserRole } from '../src/modules/user/entities/user.entity'; @@ -20,7 +20,7 @@ describe('Admin API (e2e)', () => { // Create test users const userRepository = getRepository(User); - + const admin = userRepository.create({ walletAddress: 'ADMIN_TEST_WALLET', role: UserRole.ADMIN, diff --git a/apps/backend/test/app.e2e-spec.ts b/apps/backend/test/app.e2e-spec.ts index 36852c5..9ceebc4 100644 --- a/apps/backend/test/app.e2e-spec.ts +++ b/apps/backend/test/app.e2e-spec.ts @@ -1,11 +1,10 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import request from 'supertest'; -import { App } from 'supertest/types'; import { AppModule } from './../src/app.module'; describe('AppController (e2e)', () => { - let app: INestApplication; + let app: INestApplication; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ diff --git a/apps/backend/test/auth.e2e-spec.ts b/apps/backend/test/auth.e2e-spec.ts index bb8fc56..c47a59c 100644 --- a/apps/backend/test/auth.e2e-spec.ts +++ b/apps/backend/test/auth.e2e-spec.ts @@ -1,8 +1,9 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication, ValidationPipe } from '@nestjs/common'; -import supertest from 'supertest'; +import request from 'supertest'; import type { Server } from 'http'; import { AppModule } from './../src/app.module'; +import supertest from 'supertest'; // Mock Stellar keypair for testing interface MockKeypair { @@ -73,7 +74,7 @@ describe('AuthController (e2e)', () => { describe('/auth/challenge (POST)', () => { it('should return a unique nonce for a wallet address', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/auth/challenge') .send({ walletAddress: testWalletAddress }) .expect(200); @@ -86,7 +87,7 @@ describe('AuthController (e2e)', () => { }); it('should return 400 for invalid wallet address', async () => { - await supertest(httpServer) + await request(httpServer) .post('/auth/challenge') .send({ walletAddress: 'invalid-address' }) .expect(400); @@ -96,7 +97,7 @@ describe('AuthController (e2e)', () => { describe('/auth/verify (POST)', () => { it('should verify a valid signature and return tokens', async () => { // First get a challenge - const challengeResponse = await supertest(httpServer) + const challengeResponse = await request(httpServer) .post('/auth/challenge') .send({ walletAddress: testWalletAddress }) .expect(200); @@ -104,7 +105,7 @@ describe('AuthController (e2e)', () => { const message = (challengeResponse.body as ChallengeResponse).message; const signature = testKeypair.sign(Buffer.from(message)).toString('hex'); - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/auth/verify') .send({ walletAddress: testWalletAddress, @@ -121,7 +122,7 @@ describe('AuthController (e2e)', () => { }); it('should return 401 for invalid signature', async () => { - await supertest(httpServer) + await request(httpServer) .post('/auth/verify') .send({ walletAddress: testWalletAddress, @@ -135,7 +136,7 @@ describe('AuthController (e2e)', () => { describe('/auth/me (GET)', () => { beforeEach(async () => { // Get a valid access token - const challengeResponse = await supertest(httpServer) + const challengeResponse = await request(httpServer) .post('/auth/challenge') .send({ walletAddress: testWalletAddress }) .expect(200); @@ -143,7 +144,7 @@ describe('AuthController (e2e)', () => { const message = (challengeResponse.body as ChallengeResponse).message; const signature = testKeypair.sign(Buffer.from(message)).toString('hex'); - const verifyResponse = await supertest(httpServer) + const verifyResponse = await request(httpServer) .post('/auth/verify') .send({ walletAddress: testWalletAddress, @@ -156,7 +157,7 @@ describe('AuthController (e2e)', () => { }); it('should return current user with valid token', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .get('/auth/me') .set('Authorization', `Bearer ${accessToken}`) .expect(200); @@ -175,7 +176,7 @@ describe('AuthController (e2e)', () => { }); it('should return 401 with invalid token', async () => { - await supertest(httpServer) + await request(httpServer) .get('/auth/me') .set('Authorization', 'Bearer invalid-token') .expect(401); diff --git a/apps/backend/test/escrow.e2e-spec.ts b/apps/backend/test/escrow.e2e-spec.ts index d9037db..f52a482 100644 --- a/apps/backend/test/escrow.e2e-spec.ts +++ b/apps/backend/test/escrow.e2e-spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication, ValidationPipe } from '@nestjs/common'; -import supertest from 'supertest'; +import request from 'supertest'; import type { Server } from 'http'; import { AppModule } from '../src/app.module'; import { TypeOrmModule } from '@nestjs/typeorm'; @@ -67,14 +67,14 @@ describe('Escrow (e2e)', () => { httpServer = app.getHttpServer() as Server; // Authenticate first user - const challengeResponse = await supertest(httpServer) + const challengeResponse = await request(httpServer) .post('/auth/challenge') .send({ walletAddress: testWalletAddress }); const message = (challengeResponse.body as { message: string }).message; const signature = testKeypair.sign(message).toString('hex'); - const verifyResponse = await supertest(httpServer) + const verifyResponse = await request(httpServer) .post('/auth/verify') .send({ walletAddress: testWalletAddress, @@ -84,20 +84,20 @@ describe('Escrow (e2e)', () => { accessToken = (verifyResponse.body as { accessToken: string }).accessToken; - const meResponse = await supertest(httpServer) + const meResponse = await request(httpServer) .get('/auth/me') .set('Authorization', `Bearer ${accessToken}`); userId = (meResponse.body as { id: string }).id; // Authenticate second user - const challenge2 = await supertest(httpServer) + const challenge2 = await request(httpServer) .post('/auth/challenge') .send({ walletAddress: secondWalletAddress }); const message2 = (challenge2.body as { message: string }).message; const signature2 = secondKeypair.sign(message2).toString('hex'); - const verify2 = await supertest(httpServer).post('/auth/verify').send({ + const verify2 = await request(httpServer).post('/auth/verify').send({ walletAddress: secondWalletAddress, signature: signature2, publicKey: secondWalletAddress, @@ -105,7 +105,7 @@ describe('Escrow (e2e)', () => { secondAccessToken = (verify2.body as { accessToken: string }).accessToken; - const me2 = await supertest(httpServer) + const me2 = await request(httpServer) .get('/auth/me') .set('Authorization', `Bearer ${secondAccessToken}`); secondUserId = (me2.body as { id: string }).id; @@ -133,7 +133,7 @@ describe('Escrow (e2e)', () => { describe('POST /escrows', () => { it('should create an escrow', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/escrows') .set('Authorization', `Bearer ${accessToken}`) .send({ @@ -154,7 +154,7 @@ describe('Escrow (e2e)', () => { }); it('should create an escrow with conditions', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/escrows') .set('Authorization', `Bearer ${accessToken}`) .send({ @@ -173,7 +173,7 @@ describe('Escrow (e2e)', () => { }); it('should return 400 for invalid data', async () => { - await supertest(httpServer) + await request(httpServer) .post('/escrows') .set('Authorization', `Bearer ${accessToken}`) .send({ @@ -184,7 +184,7 @@ describe('Escrow (e2e)', () => { }); it('should return 401 without auth token', async () => { - await supertest(httpServer) + await request(httpServer) .post('/escrows') .send({ title: 'Test Escrow', @@ -197,7 +197,7 @@ describe('Escrow (e2e)', () => { describe('GET /escrows', () => { it('should return user escrows', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .get('/escrows') .set('Authorization', `Bearer ${accessToken}`) .expect(200); @@ -211,7 +211,7 @@ describe('Escrow (e2e)', () => { }); it('should support pagination', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .get('/escrows?page=1&limit=5') .set('Authorization', `Bearer ${accessToken}`) .expect(200); @@ -222,7 +222,7 @@ describe('Escrow (e2e)', () => { }); it('should filter by status', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .get('/escrows?status=pending') .set('Authorization', `Bearer ${accessToken}`) .expect(200); @@ -234,7 +234,7 @@ describe('Escrow (e2e)', () => { }); it('should return 401 without auth token', async () => { - await supertest(httpServer).get('/escrows').expect(401); + await request(httpServer).get('/escrows').expect(401); }); }); @@ -242,7 +242,7 @@ describe('Escrow (e2e)', () => { let escrowId: string; beforeAll(async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/escrows') .set('Authorization', `Bearer ${accessToken}`) .send({ @@ -254,7 +254,7 @@ describe('Escrow (e2e)', () => { }); it('should return escrow details for creator', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .get(`/escrows/${escrowId}`) .set('Authorization', `Bearer ${accessToken}`) .expect(200); @@ -265,7 +265,7 @@ describe('Escrow (e2e)', () => { }); it('should return escrow details for party', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .get(`/escrows/${escrowId}`) .set('Authorization', `Bearer ${secondAccessToken}`) .expect(200); @@ -275,7 +275,7 @@ describe('Escrow (e2e)', () => { }); it('should return 404 for non-existent escrow', async () => { - await supertest(httpServer) + await request(httpServer) .get('/escrows/non-existent-id') .set('Authorization', `Bearer ${accessToken}`) .expect(404); @@ -286,7 +286,7 @@ describe('Escrow (e2e)', () => { let escrowId: string; beforeEach(async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/escrows') .set('Authorization', `Bearer ${accessToken}`) .send({ @@ -298,7 +298,7 @@ describe('Escrow (e2e)', () => { }); it('should update escrow by creator', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .patch(`/escrows/${escrowId}`) .set('Authorization', `Bearer ${accessToken}`) .send({ title: 'Updated Title' }) @@ -309,7 +309,7 @@ describe('Escrow (e2e)', () => { }); it('should return 403 when non-creator tries to update', async () => { - await supertest(httpServer) + await request(httpServer) .patch(`/escrows/${escrowId}`) .set('Authorization', `Bearer ${secondAccessToken}`) .send({ title: 'Unauthorized Update' }) @@ -321,7 +321,7 @@ describe('Escrow (e2e)', () => { let escrowId: string; beforeEach(async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post('/escrows') .set('Authorization', `Bearer ${accessToken}`) .send({ @@ -333,7 +333,7 @@ describe('Escrow (e2e)', () => { }); it('should cancel escrow by creator', async () => { - const response = await supertest(httpServer) + const response = await request(httpServer) .post(`/escrows/${escrowId}/cancel`) .set('Authorization', `Bearer ${accessToken}`) .send({ reason: 'Changed my mind' }) @@ -344,7 +344,7 @@ describe('Escrow (e2e)', () => { }); it('should return 403 when non-creator tries to cancel pending escrow', async () => { - await supertest(httpServer) + await request(httpServer) .post(`/escrows/${escrowId}/cancel`) .set('Authorization', `Bearer ${secondAccessToken}`) .send({ reason: 'Unauthorized cancel' }) @@ -353,13 +353,13 @@ describe('Escrow (e2e)', () => { it('should return 400 when trying to cancel already cancelled escrow', async () => { // First cancel - await supertest(httpServer) + await request(httpServer) .post(`/escrows/${escrowId}/cancel`) .set('Authorization', `Bearer ${accessToken}`) .send({}); // Try to cancel again - await supertest(httpServer) + await request(httpServer) .post(`/escrows/${escrowId}/cancel`) .set('Authorization', `Bearer ${accessToken}`) .send({})