Skip to content

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

Open
NatashaAlker wants to merge 3 commits intomasterfrom
vibe-270
Open

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

Conversation

@NatashaAlker
Copy link
Copy Markdown
Contributor

@NatashaAlker NatashaAlker commented Mar 24, 2026

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

    • Prevent pushes with TypeScript errors via a pre-push check and workspace type-check scripts.
  • Bug Fixes

    • Notification processing now records failures more reliably when sending fails.
  • Chores

    • CI now runs a dedicated type-check job; root tooling updated to support pre-push hooks and workspace type-checking.
    • Lint rules tightened to treat unused variables and parameters as errors.
  • Tests

    • Updated tests and end-to-end payloads to validate notification failure handling and ingestion flows.

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
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Adds a Husky pre-push hook and workspace typecheck scripts, updates CI with a type-check job and Turbo task rename, tightens Biome rules for unused symbols, and documents the change via ticket/plan/tasks files.

Changes

Cohort / File(s) Summary
Husky & root scripts
package.json, .husky/pre-push
Adds husky devDependency and prepare script; adds root typecheck (turbo typecheck); pre-push hook runs yarn lint then yarn typecheck.
CI workflow & Turbo
.github/workflows/test.yml, turbo.json
Adds type-check GitHub Actions job (sets up Node, caches Yarn/Turbo, runs yarn db:generate and npx turbo typecheck with PR filtering); renames Turbo task key type-checktypecheck.
Workspace package scripts
TypeCheck scripts
apps/{api,crons,postgres,web}/package.json, libs/.../package.json, apps/*, libs/*
Adds typecheck script (tsc --noEmit) across workspace packages (30+ packages) to enable local per-package TypeScript checks.
Linter config
biome.json
Enables noUnusedVariables and noUnusedFunctionParameters rules as error in Biome recommended correctness rules.
Documentation
docs/tickets/290/{ticket.md,plan.md,tasks.md}
Adds ticket, implementation plan, and completed tasks documenting Husky, per-package typecheck, and CI changes.
Tests & notification service
e2e-tests/tests/api/blob-ingestion-notifications.spec.ts, libs/notifications/src/notification/notification-service.*
Updates test payload in blob ingestion e2e test; changes notification processing to persist audit-log failure status when audit log creation succeeded and adds a corresponding unit test.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer (local)
  participant Git as Local Git
  participant Husky as Husky pre-push
  participant Yarn as Yarn/TSC
  participant Repo as Remote GitHub
  participant CI as GitHub Actions (type-check job)
  Dev->>Git: git push
  Git->>Husky: run pre-push hook
  Husky->>Yarn: yarn lint
  Yarn-->>Husky: lint pass/fail
  alt lint passes
    Husky->>Yarn: yarn typecheck (turbo typecheck -> invokes tsc in workspaces)
    Yarn-->>Husky: typecheck pass/fail
    alt typecheck passes
      Husky->>Git: allow push
      Git->>Repo: push commits
      Repo->>CI: trigger workflows (includes type-check job)
      CI->>CI: setup Node, db:generate, npx turbo typecheck
      CI-->>Repo: report status
    else typecheck fails
      Husky->>Git: block push
    end
  else lint fails
    Husky->>Git: block push
  end
Loading

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Two out-of-scope changes detected: updates to blob ingestion test data (venue and hearing list) and a new test case in notification-service.test.ts for error handling, neither related to the pre-push hook or typecheck implementation objectives. Remove test data changes in e2e-tests/tests/api/blob-ingestion-notifications.spec.ts and the new error handling test case from libs/notifications/src/notification/notification-service.test.ts, or move them to a separate PR.
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 (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the main change: adding a pre-push hook for lint and typecheck validation, which aligns with the primary objective of the changeset.
Linked Issues check ✅ Passed The pull request fully implements the objectives from issue #290: adds a Husky pre-push hook running lint and typecheck, adds typecheck scripts across workspaces, promotes lint rules to errors, and adds a CI job—all meeting the acceptance criterion of blocking pushes with lint/TypeScript errors.

✏️ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

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 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
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 24, 2026

🎭 Playwright E2E Test Results

257 tests   257 ✅  25m 26s ⏱️
 34 suites    0 💤
  1 files      0 ❌

Results for commit 422f8da.

♻️ 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>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

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

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

2 participants