Skip to content

Fix ESLint parsing errors in TypeScript files (Job 83813344643) #541

Description

@Listoncrypt

Problem

The CI linting job (83813344643) is failing with 4 critical ESLint parsing errors that prevent code from being properly analyzed:

src/config/env.schema.ts:171:0  error  Parsing error: ',' expected
src/controllers/contracts.controller.ts:46:20  error  Parsing error: ',' expected
src/controllers/contracts.controller.test.ts:337:0  error  Parsing error: '}' expected
src/db/migrations.ts:90:2  error  Expression or comma expected

These syntax errors are blocking the entire linting step and preventing the PR from merging.

Root Cause

The code contains syntax errors that break TypeScript/ESLint parsing:

  1. env.schema.ts line 171: Missing comma after superRefine callback closing brace
  2. contracts.controller.ts line 45-69: Orphaned method body code floating outside the class definition
  3. contracts.controller.test.ts line 337: Missing closing brace for the test suite
  4. migrations.ts line 90: Duplicate/extra closing brace in the MIGRATIONS array

Current Code Issues

Issue 1: env.schema.ts (line 170-171)

// ❌ Current (broken)
  }
});

Issue 2: contracts.controller.ts (line 43-69)

Code outside class:

// ❌ Current (broken) - floating orphaned code
export class ContractsController {
  // ... constructor missing here
  
  const rawCursor = req.query['cursor'];  // <-- This is outside the class!
  // ... more orphaned code
}

Issue 3: contracts.controller.test.ts (line 336)

Missing closing brace for describe blocks.

Issue 4: migrations.ts (line 89-91)

// ❌ Current (broken)
    },
  },  // <-- Duplicate closing brace
  {

Solution

Fix 1: env.schema.ts (line 170)

// ✅ Fixed
  },  // Add comma here
});

Fix 2: contracts.controller.ts (line 44-69)

Move the orphaned code into a proper method inside the class:

export class ContractsController {
  constructor(private readonly service: ContractsService) {}

  /**
   * GET /api/v1/contracts (cursor pagination path)
   * Paginate contracts using cursor-based navigation.
   */
  public async getContractsCursor(req: Request, res: Response, next: NextFunction) {
    try {
      const limit = parseLimit(req.query['limit']);
      const rawCursor = req.query['cursor'];
      
      if (rawCursor !== undefined && typeof rawCursor === 'string') {
        try {
          decodeCursor(rawCursor);
        } catch (err) {
          res.status(400).json({
            status: 'error',
            message: (err as Error).message,
          });
          return;
        }
      }

      const cursor =
        typeof rawCursor === 'string' && rawCursor.length > 0
          ? rawCursor
          : undefined;

      const page = await this.service.getContractsPage({ limit, cursor });
      res.status(200).json({ status: 'success', data: page });
    } catch (error) {
      next(error);
    }
  }

  // ... rest of class methods
}

Fix 3: contracts.controller.test.ts (line 336)

// ✅ Fixed - add closing braces
    it('returns 200 with CONTRACT_BOUNDS', () => {
      controller.getBounds(mockRequest as Request, mockResponse as Response);
      expect(mockResponse.status).toHaveBeenCalledWith(200);
      expect(mockResponse.json).toHaveBeenCalledWith({
        status: 'success',
        data: CONTRACT_BOUNDS,
        requestId: 'unknown',
      });
    });
  });
});  // ✅ Add these closing braces

Fix 4: migrations.ts (line 89-91)

// ✅ Fixed - remove duplicate closing brace
    },
  },  // ✅ This is correct
  {
    version: 4,
    // ... rest of migration

Expected Outcome

  • ✅ All 4 ESLint parsing errors resolved
  • ✅ ESLint successfully lints all TypeScript files without parsing errors
  • ✅ CI job 83813344643 passes
  • ✅ PR can be merged
  • ✅ 55 remaining warnings still need attention but won't block merge

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions