Skip to content

chore(checks): wire custom checks into pre-push + CI, add no-duplicate-guards#2311

Merged
andrew-bierman merged 2 commits into
developmentfrom
feat/improve-custom-checks
Apr 26, 2026
Merged

chore(checks): wire custom checks into pre-push + CI, add no-duplicate-guards#2311
andrew-bierman merged 2 commits into
developmentfrom
feat/improve-custom-checks

Conversation

@andrew-bierman
Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: lefthook only ran Biome on pre-commit — all 9 custom scripts were invisible to developers, and several were absent from CI too
  • Fix: pre-push hook now runs bun check:all (full suite) so violations are caught locally before hitting CI; CI gains lint:custom and check:casts:strict steps
  • New check: no-duplicate-guards.ts flags re-implementations of guards already exported from @packrat/guards — found 4 assertDefined duplicates on first run

Changes

File Change
lefthook.yml Add pre-push hook → bun check:all
.github/workflows/checks.yml Add lint:custom + check:casts:strict steps (continue-on-error while backlog is cleared)
biome.json Escalate useTopLevelRegex warnerror
package.json Expose check:all as a root script
scripts/check-all.ts Add no-raw-process-env, no-duplicate-guards, check-type-casts --strict to the suite
scripts/lint/no-duplicate-guards.ts New check — detects guard re-implementations outside @packrat/guards

Why continue-on-error on the new CI steps

There are ~78 existing typeof guard violations and ~175 unsafe cast violations. Adding them as hard blocks would fail every open PR today. The pre-push hook already stops new violations from being pushed — CI reports on the existing backlog. Remove continue-on-error once those are cleaned up.

Test Plan

  • Push a commit that uses typeof x === 'string' outside packages/guards/ — pre-push hook should block it
  • Push a commit that adds export function assertDefined outside packages/guards/no-duplicate-guards should flag it
  • Confirm bun check:all runs all 10 checks and shows the full table
  • Confirm bun lint still auto-fixes inline regex literals (now errors, not warnings)

…e-guards

Pre-push was a dead zone — lefthook only ran Biome on pre-commit, so
all 9 custom scripts were invisible to developers. This PR closes that
gap and adds a missing check.

- lefthook: add pre-push hook running `bun check:all` (full custom suite)
- checks.yml: add lint:custom and check:casts:strict steps (continue-on-error
  while existing backlog is cleared; pre-push already blocks new violations)
- biome.json: escalate useTopLevelRegex warn → error
- package.json: expose `check:all` as a root script
- scripts/check-all.ts: add no-raw-process-env, no-duplicate-guards,
  check-type-casts --strict to the orchestrated suite
- scripts/lint/no-duplicate-guards.ts (new): flags re-implementations of
  guards already exported from @packrat/guards; found 4 assertDefined
  duplicates on first run
Copilot AI review requested due to automatic review settings April 26, 2026 20:00
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ab6fea8f-eb28-42f9-9ec5-853307bb9833

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/improve-custom-checks

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.

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file ci/cd labels Apr 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 26, 2026

Coverage Report for Expo Unit Tests Coverage (./apps/expo)

Status Category Percentage Covered / Total
🔵 Lines 81.38% 516 / 634
🔵 Statements 81.38% (🎯 75%) 516 / 634
🔵 Functions 92.85% 52 / 56
🔵 Branches 92.55% 199 / 215
File CoverageNo changed files found.
Generated in workflow #807 for commit fe5308c by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 26, 2026

Coverage Report for API Unit Tests Coverage (./packages/api)

Status Category Percentage Covered / Total
🔵 Lines 74.9% 582 / 777
🔵 Statements 74.9% (🎯 65%) 582 / 777
🔵 Functions 95.91% 47 / 49
🔵 Branches 88.23% 270 / 306
File CoverageNo changed files found.
Generated in workflow #807 for commit fe5308c by the Vitest Coverage Report Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens developer/CI feedback loops by wiring the repo’s custom lint/check scripts into local git hooks and the Checks workflow, and introduces a new guard-duplication detector to enforce using @packrat/guards as the single source of truth.

Changes:

  • Add check:all script and wire it into a new pre-push hook to run the full custom check suite locally.
  • Extend CI (checks.yml) with lint:custom and strict cast checks (temporarily continue-on-error).
  • Add scripts/lint/no-duplicate-guards.ts to detect re-implementations of known guards outside @packrat/guards.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/lint/no-duplicate-guards.ts New custom lint script to detect duplicated guard implementations across apps/packages.
scripts/check-all.ts Adds the new guard-duplication check + strict type-cast check to the orchestrated suite.
package.json Exposes check:all as a root script entry point.
lefthook.yml Adds a pre-push hook to run the full check suite locally.
biome.json Escalates useTopLevelRegex from warning to error.
.github/workflows/checks.yml Adds CI steps for lint:custom and strict cast checks with continue-on-error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/check-all.ts Outdated
// Runs the following checks in parallel and prints a unified summary table:
// - scripts/lint/no-raw-regex.ts
// - scripts/lint/no-raw-typeof.ts
// - scripts/lint/no-raw-process-env.ts
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

The check list in the file header references scripts/lint/no-raw-process-env.ts, but the actual check runs packages/env/scripts/no-raw-process-env.ts (see ALL_CHECKS). Updating the comment will avoid confusion when someone tries to locate the script.

Suggested change
// - scripts/lint/no-raw-process-env.ts
// - packages/env/scripts/no-raw-process-env.ts

Copilot uses AI. Check for mistakes.
# Pre-push hook already blocks new violations — these report on the backlog.
- name: Custom lint rules (typeof guards, raw regex, process.env)
run: bun lint:custom
continue-on-error: true
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

CI adds a lint:custom step, but it currently runs only no-raw-typeof, no-raw-regex, and no-raw-process-env (per package.json). The newly added no-duplicate-guards check is not executed anywhere in CI, so duplicates can still land by bypassing local hooks. Consider running bun check:all (optionally with continue-on-error while backlog is cleared) or adding no-duplicate-guards to lint:custom / as its own step.

Suggested change
continue-on-error: true
continue-on-error: true
# TODO: remove continue-on-error once the duplicate-guards backlog is cleared.
- name: Check duplicate guards
run: bun no-duplicate-guards
continue-on-error: true

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +69
// Excluded source roots (the canonical definitions live here).
const EXCLUDED_PREFIXES = ['packages/guards/', 'packages/checks/'];

Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

EXCLUDED_PREFIXES values include a trailing /, but walkDir builds relPath values like packages/guards (no trailing slash) for the directory itself. As a result, isExcluded('packages/guards') returns false and this script will scan the canonical implementations in packages/guards/ (and packages/checks/), causing self-violations and making the check fail on every run. Consider normalizing relPath (e.g., ensure it always ends with / when comparing) or updating isExcluded to treat both exact directory matches and prefix matches as excluded.

Copilot uses AI. Check for mistakes.
Comment thread scripts/lint/no-duplicate-guards.ts Outdated
// 0 — no violations
// 1 — violations found
//
// Wired into check-all.ts and CI via checks.yml.
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

This header comment says the script is wired into CI via checks.yml, but the workflow changes shown only add lint:custom and check:casts:strict steps and do not run no-duplicate-guards. Either update the comment to match reality or add a CI step (or include this script in lint:custom / check:all) so CI reports these violations even if the pre-push hook is bypassed.

Suggested change
// Wired into check-all.ts and CI via checks.yml.
// Wired into check-all.ts.

Copilot uses AI. Check for mistakes.
- Fix EXCLUDED_ROOTS trailing-slash mismatch (dirs were not excluded early)
- Add no-duplicate-guards to lint:custom so CI covers it
- Fix check-all.ts comment: correct path for no-raw-process-env
- Fix header comment: wired into lint:custom, not checks.yml directly
@andrew-bierman andrew-bierman merged commit 0de8f55 into development Apr 26, 2026
9 checks passed
@andrew-bierman andrew-bierman deleted the feat/improve-custom-checks branch April 26, 2026 21:16
andrew-bierman added a commit that referenced this pull request May 14, 2026
chore(checks): wire custom checks into pre-push + CI, add no-duplicate-guards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants