chore(ui): move existing inline null/empty and typeof checks to the guards
Maintainers usually reply within 1 day
@bitcoinbrisbane is already working on this.
Since Nov 1, 2026.
Assessment
This issue has not been assessed yet.
Description
Why
UI Architecture Commandment 8 (CLAUDE.md) says null, empty and length checks go through src/utils/guards.ts. Since #933, the Guards CI job (yarn check:guards) enforces this, but only on lines a PR adds. Older code was never moved over, so it doesn't match the rule. Any PR that touches those files either inherits the old checks or ends up mixing unrelated guard fixes into its diff (as #936 did; now closed).
The last adoption pass was #449 (#451, #453, #459, #473).
What's left on main (9420ff5)
Counted with the same rules check:guards uses (scripts/guards/rules.ts), over whole files. Comments and // guards-ok lines are skipped.
136 hand-written null/empty/length checks in 63 files
| Use instead | Count |
|---|---|
hasValue(x) |
64 |
isNullish(x) |
48 |
isEmpty(x) / isBlank(x) |
12 |
hasElements(x) / hasContent(x) |
12 |
Densest files: pages/TableAdminPage.tsx (15), bus/GameMessageBus.ts (8), components/bridge/StuckPaymentsPanel.tsx (8), pages/Dashboard.tsx (6), submit/ActionSubmitController.ts (5), utils/turnClock.ts (5).
30 typeof checks in 19 files, mostly narrowing an unknown reply field, e.g.
const msg = typeof raw?.message === "string" ? raw.message : response.statusText; // hooks/game/useFetchSngClaimSignature.ts
rawLog: typeof rawLog === "string" ? rawLog : "", // submit/txVerdict.ts
if (typeof err === "object" && err !== null) { // apis/HTTPClient.ts
There are no guards for these yet. Most are in constants/currency.ts, submit/txVerdict.ts, components/explorer/ClickableAddress.tsx, audio/actionSoundPlayer.ts and apis/HTTPClient.ts.
Scope
- Replace the 136 checks with the existing guards. Where
nullandundefinedmean different things, keep the strict check and end the line with// guards-ok. Example: #919's ante rule, wherenullmeans "antes off" andundefinedmeans "not set".isNullishwould merge them. - Add type guards for the
typeofcases, with tests inguards.test.ts:isString,isNumber,isBoolean, andisRecordfor "non-null object whose fields can be read". Then switch the 30 sites to them and list the new guards in Commandment 8. - Teach
check:guardsthetypeofpattern so new ones are flagged once the guards exist.
How
- Its own PRs, split by directory (
bus/+submit/,hooks/,components/,pages/,utils/+apis/), not folded into feature PRs. - No behaviour change. Each PR passes
tsc -b, the full jest suite andcheck:guards. - No visible change, so no screenshots.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 5
- Avg merge
- 23h 23m
- Merged PRs (30d)
- 97
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from block52/ui
-
enhancement tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
feat(ui): player notes and tags — click a seat to note a player; tag icons (fish, shark, tight, loose…) show by their pillPossibly taken @Dzeezbtc claimed this 3 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
architecture refactor tech debt
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
feat(ui): antes on the create form — on/off, start level and size, with the schedule in the previewPossibly taken @bitcoinbrisbane claimed this 7 days ago. Openfeature lobby sit-and-go
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Open-Earth-Foundation/CityCatalyst#3399 ·
Maintainers usually reply within 2 days
-
userReport
Difficulty 1/5 Under an hour Newbie friendliness 72/100
nkprasad12/morcus-net#631 ·
Maintainers usually reply within 1 day
-
fix(app): fail closed if GetGeneralSetting fails during initializationPossibly taken @kalavt claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
nekko-labs/nekko-agent#1756 ·
Maintainers usually reply within 1 day
-
needs-area-label
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days