fix(lint): backend test files are never linted #298

Closed
opened 2026-09-04 12:22:46 -05:00 by bermudalamb · 0 comments
Owner

The two lint scripts do not cover the same ground:

Script
backend/package.json eslint src scripts
frontend/package.json eslint src tests

So every file under backend/tests/ — the entire unit and integration suite, around sixty files — has never been linted. The frontend's tests have been all along.

Why this is worth more than tidiness

Two of the defects found during #260 and #293 lived in backend test files, and both are the kind of thing a linter is good at noticing:

  • A unit test that opened a real TLS connection to smtp.gmail.com on every run, hidden behind a .catch(() => 'threw') that made any outcome pass.
  • Integration tests that did jest.spyOn(pool, 'connect') on the shared pg pool, which made a suite report "Test suite failed to run" against its own teardown and made filtered runs hang forever.

Neither was caught by lint, because lint never looked. Both were caught by review, which is slower and depends on somebody being suspicious in the right place.

The repo already has rules that would apply here — sonarjs/no-skipped-tests fired on the frontend's e2e specs during #269 and had to be explained rather than suppressed, which is exactly the conversation worth having about backend tests too.

The work

Change the backend script to eslint src scripts tests, then fix whatever it finds. That second half is the unknown: sixty unlinted files may produce a long list, and some of it may be rules that make sense for src and not for tests. Expect to need a tests-specific override block, the way many projects relax no-explicit-any or no-non-null-assertion for test code — backend/tests uses rows[0]! heavily and that is idiomatic there.

Worth doing as its own change rather than folded into a feature branch, because the fix list is unbounded until the command is actually run.

Found while reviewing #293.

The two lint scripts do not cover the same ground: | | Script | |---|---| | `backend/package.json` | `eslint src scripts` | | `frontend/package.json` | `eslint src tests` | So every file under `backend/tests/` — the entire unit and integration suite, around sixty files — has never been linted. The frontend's tests have been all along. ## Why this is worth more than tidiness Two of the defects found during #260 and #293 lived in backend test files, and both are the kind of thing a linter is good at noticing: - A unit test that opened a real TLS connection to `smtp.gmail.com` on every run, hidden behind a `.catch(() => 'threw')` that made any outcome pass. - Integration tests that did `jest.spyOn(pool, 'connect')` on the shared `pg` pool, which made a suite report "Test suite failed to run" against its own teardown and made filtered runs hang forever. Neither was caught by lint, because lint never looked. Both were caught by review, which is slower and depends on somebody being suspicious in the right place. The repo already has rules that would apply here — `sonarjs/no-skipped-tests` fired on the frontend's e2e specs during #269 and had to be explained rather than suppressed, which is exactly the conversation worth having about backend tests too. ## The work Change the backend script to `eslint src scripts tests`, then fix whatever it finds. That second half is the unknown: sixty unlinted files may produce a long list, and some of it may be rules that make sense for `src` and not for tests. Expect to need a `tests`-specific override block, the way many projects relax `no-explicit-any` or `no-non-null-assertion` for test code — `backend/tests` uses `rows[0]!` heavily and that is idiomatic there. Worth doing as its own change rather than folded into a feature branch, because the fix list is unbounded until the command is actually run. Found while reviewing #293.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bermudalamb/redefined-designs#298