Skip to content

fix: add ESLint config, lint script, and lint-staged gate to backend (#1278) - #1373

Open
Blessed-Femi wants to merge 10 commits into
LabsCrypt:mainfrom
Blessed-Femi:fix/1278-backend-eslint
Open

fix: add ESLint config, lint script, and lint-staged gate to backend (#1278)#1373
Blessed-Femi wants to merge 10 commits into
LabsCrypt:mainfrom
Blessed-Femi:fix/1278-backend-eslint

Conversation

@Blessed-Femi

Copy link
Copy Markdown
Contributor

Summary

Closes #1278

The backend has no lint gate at all: no ESLint config, no lint script, no eslint devDependency, and the root lint-staged config only globs frontend/**. Backend TypeScript — the half of the codebase that handles fund movement — was never statically linted locally, in pre-commit hooks, or in CI. This PR closes that gap.

Changes

New backend lint setup

  • backend/eslint.config.mjs (new) — flat config adapted from the frontend (frontend/eslint.config.mjs) for a Node/Express codebase:
    • typescript-eslint recommended ruleset
    • no-console: error (use the winston logger), matching the frontend's rule
    • no-unused-vars with _-prefix ignore patterns for args/vars/caught errors
    • no-explicit-any: warn for tests/** only (mocks/test doubles); still an error in src/** like the frontend
    • Ignores: dist, coverage, src/generated/** (Prisma client), examples/**, src/**/*.example.ts, and allows console in prisma/seed.ts (CLI script)
  • backend/package.json — added "lint": "eslint ." script and eslint, @eslint/js, typescript-eslint devDependencies (lockfile updated)
  • package.json (root) — extended lint-staged to run the backend lint on backend/**/*.{ts,tsx,js}, so pre-commit hooks now gate backend changes
  • .github/workflows/ci.yml — added a Lint step to the backend CI job (npm run lint), mirroring the frontend job

Cleanup so the gate passes on the current codebase

The new rules surfaced real (mostly mechanical) violations in src, all fixed:

  • Explicit any (src): catch (error: any)unknown with instanceof Error narrowing; typed Prisma.StreamWhereInput in export.service.ts; structural types for export records; typed CacheItem<unknown>, Record<string, unknown> webhook payloads, rate-limiter Options, handler signatures (AuthenticatedRequestRequest + internal cast, matching createStream/pauseStream convention) which also removed the as any casts at route registration
  • Unused vars: renamed unused params/catch vars to the _ convention
  • prefer-const: one letconst
  • no-console: only occurred in prisma/seed.ts, exempted via config

Acceptance criteria

  • npm run lint --workspace=backend exists and passes (0 errors; 282 pre-existing any usages in test files surface as warnings)
  • A backend file with a lint violation is caught by pre-commit hooks — verified: staging a file with console.log makes lint-staged fail with exit 1
  • Backend is now linted in CI (ci.yml backend job)

Verification

  • npm run lint --workspace=backend — 0 errors (exit 0)
  • npm run build (tsc) in backend — passes
  • vitest run --exclude='tests/integration/**' — 315 passed / 3 skipped (identical to main; the lone module-load ERR_ERL_KEY_GEN_IPV6 validation error and the coverage-threshold failure both pre-exist on main and are unrelated to this PR)
  • npx lint-staged with a violating backend file — fails as intended (exit 1)

Fixes #1278

Blessed-Femi and others added 6 commits August 30, 2026 13:17
…absCrypt#1278)

The backend had no ESLint config, no lint script, and was excluded from
the root lint-staged glob, so backend TypeScript was never statically
linted locally or in CI. Add a flat ESLint config for backend
(typescript-eslint recommended, adapted from the frontend's ruleset), a
`lint` script, eslint/typescript-eslint devDependencies, a lint step in
the backend CI job, and extend lint-staged to backend/** so pre-commit
hooks catch backend violations.

Also fix the lint violations the new rules surface in src (explicit any,
unused vars, console, prefer-const) so the gate passes on the current
codebase; tests keep no-explicit-any as a warning.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The backend ESLint gate added in this branch flags `catch (error: any)` as
an error. The handler already narrows via `error instanceof Error`, so drop
the `any` annotation and rely on the default `unknown` catch type.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Remove duplicate MemoryCache class fragment in redis.ts and use
  unknown instead of any
- Drop unused rateLimit import in stream-rate-limiter middleware
- Remove dup cancel route registration left by merge and drop as any
- Fix broken ternary leftover in soroban-event-worker
- Pin prisma's mysql2 dep via override and sync package-lock

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
@K1NGD4VID

Copy link
Copy Markdown
Collaborator

resolve conflict on this issue @Blessed-Femi

Blessed-Femi and others added 4 commits September 3, 2026 08:32
Commit 48f46eb (mysql2 pin) dropped a comma after the prisma
override block, which broke npm ci on every CI job. Restore it.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The merge of main into fix/1278-backend-eslint jammed both mysql2
override specs (^3.22.0 and >=3.22.0) together without a comma,
making package.json invalid JSON and breaking npm ci on every CI job.
Keep the prisma-scoped override from the branch and main's >=3.22.0
top-level pin.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Audit] Backend has no lint script or ESLint configuration at all

2 participants