Skip to content

feat: add pre-push hook for lint and typecheck validation (#290) - #468

Closed
NatashaAlker wants to merge 6 commits into
masterfrom
vibe-270
Closed

feat: add pre-push hook for lint and typecheck validation (#290)#468
NatashaAlker wants to merge 6 commits into
masterfrom
vibe-270

Conversation

@NatashaAlker

@NatashaAlker NatashaAlker commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Husky pre-push git hook that runs yarn lint && yarn typecheck before allowing pushes, catching lint and TypeScript errors locally before CI
  • Adds typecheck script (tsc --noEmit) to all 30+ workspace packages and a typecheck turbo task
  • Promotes Biome noUnusedVariables and noUnusedFunctionParameters rules from warning to error level so they block pushes
  • Adds a type-check CI job to test.yml between lint and test jobs (existing lint job unchanged)

Test plan

  • Introduced unused variable → push blocked with Biome error
  • Introduced debugger statement → push blocked with Biome error
  • Introduced type mismatch (number = "string") → push blocked with TypeScript error
  • Clean code push succeeds (turbo caching ~454ms on cache hit)
  • Verified existing CI lint job unchanged as safety net

Closes #290

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Pre-push Git hook now enforces linting and TypeScript type-checking on push.
  • Improvements

    • Notification processing now records failure status to audit logs when delivery fails.
    • Linter configured to treat unused variables and unused function parameters as errors.
    • Added workspace-wide non-emitting TypeScript type-check command and CI type-check job.
  • Tests

    • Added test covering notification processing error handling.

NatashaAlker and others added 2 commits March 24, 2026 14:22
Add Husky pre-push git hook that runs lint and TypeScript checks before
allowing a push, catching errors locally instead of waiting for CI.

- Install husky@9.1.7 with prepare script for auto-setup
- Add typecheck script (tsc --noEmit) to all 30 workspace packages
- Rename turbo task from type-check to typecheck for consistency
- Add typecheck CI job to test.yml mirroring the lint job
- Create ticket documentation in docs/tickets/290/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r level

These rules were at warning level (Biome default), meaning they didn't
cause a non-zero exit code and wouldn't block the pre-push hook. Promote
to error so unused variables and parameters are caught before pushing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8feb4df7-114e-4500-bb5c-b62251d3d63c

📥 Commits

Reviewing files that changed from the base of the PR and between 78d0169 and 1dbca55.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (16)
  • apps/web/package.json
  • libs/account/package.json
  • libs/admin-pages/package.json
  • libs/auth/src/pages/crime-callback/index.test.ts
  • libs/list-types/administrative-court-daily-cause-list/package.json
  • libs/list-types/care-standards-tribunal-weekly-hearing-list/package.json
  • libs/list-types/civil-and-family-daily-cause-list/package.json
  • libs/list-types/common/package.json
  • libs/list-types/court-of-appeal-civil-daily-cause-list/package.json
  • libs/list-types/london-administrative-court-daily-cause-list/package.json
  • libs/list-types/rcj-standard-daily-cause-list/package.json
  • libs/notifications/src/notification/notification-service.test.ts
  • libs/notifications/src/notification/notification-service.ts
  • libs/publication/package.json
  • libs/web-core/package.json
  • package.json
✅ Files skipped from review due to trivial changes (11)
  • libs/account/package.json
  • libs/auth/src/pages/crime-callback/index.test.ts
  • libs/admin-pages/package.json
  • libs/list-types/care-standards-tribunal-weekly-hearing-list/package.json
  • libs/publication/package.json
  • libs/list-types/rcj-standard-daily-cause-list/package.json
  • libs/list-types/court-of-appeal-civil-daily-cause-list/package.json
  • libs/list-types/common/package.json
  • libs/list-types/civil-and-family-daily-cause-list/package.json
  • apps/web/package.json
  • libs/list-types/administrative-court-daily-cause-list/package.json
🚧 Files skipped from review as they are similar to previous changes (5)
  • libs/list-types/london-administrative-court-daily-cause-list/package.json
  • package.json
  • libs/notifications/src/notification/notification-service.ts
  • libs/web-core/package.json
  • libs/notifications/src/notification/notification-service.test.ts

📝 Walkthrough

Walkthrough

Adds a pre-push Husky hook and workspace typecheck scripts, renames a Turbo task, tightens Biome lint rules, adds a CI type-check job, updates notification processing to persist failure status to the audit log (with tests), and adds ticket/implementation docs.

Changes

Pre-push Hook, Workspace Typecheck & CI

Layer / File(s) Summary
Hook
.husky/pre-push
New Husky pre-push hook runs yarn lint then yarn typecheck on push.
Root config
package.json
Adds prepare: "husky", typecheck: "turbo typecheck" and devDependency husky@9.1.7.
Workspace scripts
apps/*/package.json, libs/*/package.json (many files)
Adds typecheck script (tsc --noEmit) to workspace packages and adjusts trailing commas in lint:fix entries for JSON validity.
Turbo task
turbo.json
Renames Turbo task key from type-checktypecheck.
CI
.github/workflows/job.test.yml
Adds type-check job that runs Prisma generation then npx turbo typecheck, with PR partial-filtering and caching changes.
Docs
docs/tickets/290/*
Adds ticket, plan, and tasks docs describing Husky/typecheck implementation steps.
Lint config
biome.json
Adds noUnusedVariables and noUnusedFunctionParameters rules set to error.

Notification service — audit log persistence

Layer / File(s) Summary
Core change
libs/notifications/src/notification/notification-service.ts
processUserNotification now declares notification outside try, and on exception attempts a best-effort updateNotificationStatus(notification.id, "Failed", error.message) if audit log creation succeeded; update errors are swallowed.
Tests
libs/notifications/src/notification/notification-service.test.ts
Adds test that mocks createNotificationAuditLog success and sendEmail rejection, asserting sent = 0, totalSubscriptions = 1 and that updateNotificationStatus is called with "Failed" and the error message.

Sequence Diagram(s)

sequenceDiagram
  participant Processor as NotificationProcessor
  participant AuditDB as AuditLogDB
  participant Email as EmailService

  Processor->>AuditDB: createNotificationAuditLog(subscription, payload)
  Activate AuditDB
  AuditDB-->>Processor: auditLog(created) {id, metadata}
  Deactivate AuditDB

  Processor->>Email: sendEmail(auditLog, payload)
  alt sendEmail succeeds
    Email-->>Processor: success
    Processor->>AuditDB: updateNotificationStatus(id, "Succeeded")
    AuditDB-->>Processor: ok
  else sendEmail fails
    Email-->>Processor: error
    Processor->>AuditDB: updateNotificationStatus(id, "Failed", error.message)  rgba(220,20,60,0.5)
    AuditDB-->>Processor: ok / error (ignored)  rgba(220,20,60,0.5)
    Processor-->>Processor: return failed result
  end
Loading

Possibly related issues

Possibly related PRs

  • hmcts/cath-service#155 — Touches notifications area including tests and notification-related modules; strongly related to the notification-service changes in this PR.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarises the main change: adding a pre-push Git hook for automated lint and typecheck validation before pushing to GitHub.
Linked Issues check ✅ Passed The PR fully implements the acceptance criteria from #290: adds lint and TypeScript validation checks via a pre-push hook, preventing pushes with errors and meeting the requirement that developers ensure no lint or TypeScript errors before pushing.
Out of Scope Changes check ✅ Passed All changes are properly scoped to #290 objectives: Husky setup, typecheck scripts, Biome rule updates for pre-push enforcement, CI job addition, and necessary test updates supporting the validation flow.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vibe-270

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bee8b8d9-f4a8-4a90-a527-bc79be23c551

📥 Commits

Reviewing files that changed from the base of the PR and between b88bf95 and 9734d80.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (38)
  • .github/workflows/test.yml
  • .husky/pre-push
  • apps/api/package.json
  • apps/crons/package.json
  • apps/postgres/package.json
  • apps/web/package.json
  • biome.json
  • docs/tickets/290/plan.md
  • docs/tickets/290/tasks.md
  • docs/tickets/290/ticket.md
  • libs/account/package.json
  • libs/admin-pages/package.json
  • libs/api/package.json
  • libs/audit-log/package.json
  • libs/auth/package.json
  • libs/cloud-native-platform/package.json
  • libs/list-search-config/package.json
  • libs/list-types/administrative-court-daily-cause-list/package.json
  • libs/list-types/care-standards-tribunal-weekly-hearing-list/package.json
  • libs/list-types/civil-and-family-daily-cause-list/package.json
  • libs/list-types/common/package.json
  • libs/list-types/court-of-appeal-civil-daily-cause-list/package.json
  • libs/list-types/london-administrative-court-daily-cause-list/package.json
  • libs/list-types/rcj-standard-daily-cause-list/package.json
  • libs/location/package.json
  • libs/notification/package.json
  • libs/notifications/package.json
  • libs/pdf-generation/package.json
  • libs/public-pages/package.json
  • libs/publication/package.json
  • libs/redis/package.json
  • libs/simple-router/package.json
  • libs/subscriptions/package.json
  • libs/system-admin-pages/package.json
  • libs/verified-pages/package.json
  • libs/web-core/package.json
  • package.json
  • turbo.json

Comment thread docs/tickets/290/tasks.md
Comment on lines +3 to +7
- [x] Add husky devDependency and prepare/type-check scripts to root package.json
- [x] Run yarn install to install husky
- [x] Initialize husky and create .husky/pre-push hook
- [x] Add type-check script to all 30 workspace package.json files
- [x] Verify yarn type-check passes across all packages

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use typecheck consistently in the checklist.

Lines 3, 6, and 7 still reference type-check, but the implemented script name is typecheck. This makes the task log inaccurate.

✏️ Suggested doc fix
-- [x] Add husky devDependency and prepare/type-check scripts to root package.json
+- [x] Add husky devDependency and prepare/typecheck scripts to root package.json
...
-- [x] Add type-check script to all 30 workspace package.json files
-- [x] Verify yarn type-check passes across all packages
+- [x] Add typecheck script to all 30 workspace package.json files
+- [x] Verify yarn typecheck passes across all packages
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [x] Add husky devDependency and prepare/type-check scripts to root package.json
- [x] Run yarn install to install husky
- [x] Initialize husky and create .husky/pre-push hook
- [x] Add type-check script to all 30 workspace package.json files
- [x] Verify yarn type-check passes across all packages
- [x] Add husky devDependency and prepare/typecheck scripts to root package.json
- [x] Run yarn install to install husky
- [x] Initialize husky and create .husky/pre-push hook
- [x] Add typecheck script to all 30 workspace package.json files
- [x] Verify yarn typecheck passes across all packages


### Acceptance criteria

Make sure there is no lint and typescript error in code before pushing to Github.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tidy acceptance criterion capitalisation.

Line 16 should use TypeScript and GitHub for consistency and correctness.

✏️ Suggested wording
-Make sure there is no lint and typescript error in code before pushing to Github.
+Make sure there are no lint or TypeScript errors in code before pushing to GitHub.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Make sure there is no lint and typescript error in code before pushing to Github.
Make sure there are no lint or TypeScript errors in code before pushing to GitHub.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~16-~16: The official name of this software platform is spelled with a capital “H”.
Context: ...escript error in code before pushing to Github. ## Comments ### Comment by OgechiOke...

(GITHUB)

Comment on lines 11 to 15
"scripts": {
"build": "tsc",
"dev": "tsc --watch"
"dev": "tsc --watch",
"typecheck": "tsc --noEmit"
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check if libs/audit-log has test files or formatting/linting needs

# Check for test files
fd -e test.ts -e spec.ts . libs/audit-log/

# Check for source files that would need linting
fd -e ts -e tsx . libs/audit-log/src/

# Check if other lib packages have these scripts
rg -A 15 '"scripts"' libs/*/package.json | grep -E '(test|format|lint)'

Repository: hmcts/cath-service

Length of output: 6297


🏁 Script executed:

cat -n libs/audit-log/package.json

Repository: hmcts/cath-service

Length of output: 540


Add missing scripts to package.json.

This library package is missing the required test, test:watch, format, lint, and lint:fix scripts. All peer library modules include these alongside the build and dev scripts. Add the following to the scripts section:

"test": "vitest run",
"test:watch": "vitest watch",
"format": "biome format --write .",
"lint": "biome check .",
"lint:fix": "biome check --write --unsafe ."

@github-actions

github-actions Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

🎭 Playwright E2E Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 1dbca55.

♻️ This comment has been updated with latest results.

The blob-ingestion-notifications E2E test was failing because the payload
had empty courtLists, causing notification processing to fail silently.
Updated the payload with realistic case data matching the reference data
for court_id 9001. Also fixed processUserNotification to update the
notification audit log to "Failed" when an error is thrown after log
creation, preventing notifications from being stuck in "Pending" state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
libs/notifications/src/notification/notification-service.ts (1)

155-157: Avoid completely silent fallback-update failures.

At Line 156, swallowing the nested failure with an empty catch hides operational signals. Consider logging the secondary error at least once.

Suggested tweak
-    if (notification) {
-      await updateNotificationStatus(notification.notificationId, "Failed", undefined, errorMessage).catch(() => {});
-    }
+    if (notification) {
+      await updateNotificationStatus(notification.notificationId, "Failed", undefined, errorMessage).catch((updateError) => {
+        console.warn(
+          `Failed to update notification status for ${notification.notificationId}`,
+          updateError
+        );
+      });
+    }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a23f872e-8aeb-4b10-9613-c4ab42e87f47

📥 Commits

Reviewing files that changed from the base of the PR and between 9734d80 and 422f8da.

📒 Files selected for processing (3)
  • e2e-tests/tests/api/blob-ingestion-notifications.spec.ts
  • libs/notifications/src/notification/notification-service.test.ts
  • libs/notifications/src/notification/notification-service.ts

@sonarqubecloud

Copy link
Copy Markdown

- Resolved conflict in blob-ingestion-notifications.spec.ts by accepting
  master's createValidPayload function (dynamic payload creation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c5f63534-e566-458c-ab0f-a0b8643cd643

📥 Commits

Reviewing files that changed from the base of the PR and between 5705b8b and 78d0169.

📒 Files selected for processing (26)
  • .github/workflows/job.test.yml
  • apps/api/package.json
  • apps/crons/package.json
  • apps/postgres/package.json
  • apps/web/package.json
  • libs/account/package.json
  • libs/admin-pages/package.json
  • libs/api/package.json
  • libs/auth/package.json
  • libs/cloud-native-platform/package.json
  • libs/list-search-config/package.json
  • libs/list-types/administrative-court-daily-cause-list/package.json
  • libs/list-types/care-standards-tribunal-weekly-hearing-list/package.json
  • libs/list-types/civil-and-family-daily-cause-list/package.json
  • libs/list-types/common/package.json
  • libs/list-types/court-of-appeal-civil-daily-cause-list/package.json
  • libs/list-types/london-administrative-court-daily-cause-list/package.json
  • libs/list-types/rcj-standard-daily-cause-list/package.json
  • libs/location/package.json
  • libs/notification/package.json
  • libs/notifications/package.json
  • libs/pdf-generation/package.json
  • libs/public-pages/package.json
  • libs/publication/package.json
  • libs/subscriptions/package.json
  • libs/system-admin-pages/package.json
✅ Files skipped from review due to trivial changes (21)
  • libs/account/package.json
  • libs/list-search-config/package.json
  • libs/list-types/civil-and-family-daily-cause-list/package.json
  • libs/public-pages/package.json
  • libs/list-types/london-administrative-court-daily-cause-list/package.json
  • apps/crons/package.json
  • libs/api/package.json
  • libs/system-admin-pages/package.json
  • libs/list-types/administrative-court-daily-cause-list/package.json
  • apps/postgres/package.json
  • libs/admin-pages/package.json
  • libs/publication/package.json
  • libs/list-types/court-of-appeal-civil-daily-cause-list/package.json
  • libs/notification/package.json
  • libs/list-types/care-standards-tribunal-weekly-hearing-list/package.json
  • libs/list-types/common/package.json
  • libs/subscriptions/package.json
  • libs/location/package.json
  • apps/api/package.json
  • libs/cloud-native-platform/package.json
  • libs/auth/package.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/web/package.json
  • libs/list-types/rcj-standard-daily-cause-list/package.json
  • libs/pdf-generation/package.json
  • libs/notifications/package.json

Comment on lines +68 to +72
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24.13.1'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Node versions declared in .github/workflows/job.test.yml:"
rg -n "node-version:" .github/workflows/job.test.yml

echo
echo "If you maintain a repo-wide Node pin, check it too:"
fd -HI '^\.(nvmrc|node-version)$' . | sed 's#^#- #'

Repository: hmcts/cath-service

Length of output: 296


🏁 Script executed:

cat .nvmrc

Repository: hmcts/cath-service

Length of output: 70


🏁 Script executed:

head -n 75 .github/workflows/job.test.yml | tail -n 60

Repository: hmcts/cath-service

Length of output: 1535


🏁 Script executed:

sed -n '110,130p' .github/workflows/job.test.yml

Repository: hmcts/cath-service

Length of output: 570


Unify Node.js version with the other CI jobs.

Line 71 pins 24.13.1, whilst lint and test use 24.15.0. This diverges from the repo-wide pin in .nvmrc (24.15.0) and can produce inconsistent CI results between jobs.

Suggested fix
       - name: Setup Node.js
         uses: actions/setup-node@v6
         with:
-          node-version: '24.13.1'
+          node-version: '24.15.0'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24.13.1'
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24.15.0'

@sonarqubecloud

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown

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.

[VIBE-270] Create hook for lint style check and any typescript errors

5 participants