chore(utils): add src/utils barrel file — 418 deep imports across 188 files; 3 export-name collisions block export *
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- eslint, typescript, vite
- Domain
- developer-experience, frontend, tooling
Research direction
Start by reading the existing src/utils/cosmos/index.ts barrel and inspect the three collision pairs in encodingUtils.ts/nodePortal.ts, sngSchedule.ts/scheduledSng.ts, and accountUtils.ts/b52AccountUtils.ts, along with their callers. Then add the top-level and bridge barrels, migrate consumer imports, and configure ESLint to block deep imports. Run yarn build, yarn test, and yarn lint; done means all acceptance criteria pass, including unchanged chunk sizes.
Written by the indexing model from the issue text.
Description
Problem
src/utils/ has 78 source modules (plus bridge/ and cosmos/ subfolders) and no barrel file. Every consumer deep-imports individual modules, so imports pile up at the top of components:
- 418 separate
from "../utils/..."import statements across 188 files - Worst offenders:
components/playPage/Table.tsx(13 utils import lines),pages/TableAdminPage.tsx(12),pages/Dashboard.tsx(11),components/Footer/PokerActionPanel.tsx(11)
// today — Table.tsx has 13 of these lines
import { hasElements } from "../../utils/guards";
import { formatWinnings } from "../../utils/formatUtils";
import { colors } from "../../utils/colorConfig";
// ...10 more
// with a barrel
import { hasElements, formatWinnings, colors } from "../../utils";
Beyond the noise, deep imports mean every move/rename inside utils/ touches dozens of call sites, and there is no single place that defines the public surface of the utils layer.
What exists today (code pass)
src/utils/cosmos/index.tsalready exists — the pattern has precedent inside utils itself; the top level never got one.- All utils use named exports only (zero
export default), so the barrel is pureexport * from "./x"re-exports — Vite/Rollup tree-shakes these fine in an app build. - Three export-name collisions block a blind
export *and must be resolved first. They are not copy-paste duplicates — each pair is two different functions sharing a name:
| Name | File A | File B | Conflict |
|---|---|---|---|
base64ToHex |
encodingUtils.ts |
nodePortal.ts |
Different output: lowercase with 0x prefix vs UPPERCASE without prefix. Callers depend on the format, so they can't be merged blindly — rename the nodePortal one (e.g. base64ToHexUpper) or converge callers onto encodingUtils deliberately. |
formatCountdown |
sngSchedule.ts |
scheduledSng.ts |
Different signatures and semantics: (msRemaining) with days + "Starting now" vs (untilMs, nowMs) h:mm:ss. (That sngSchedule.ts and scheduledSng.ts both exist is its own smell.) |
getPublicKey |
accountUtils.ts |
b52AccountUtils.ts |
accountUtils derives an ETH public key from a private key; b52AccountUtils reads the stored cosmos address from localStorage — it doesn't return a public key at all. Rename it to what it does (e.g. getStoredCosmosAddress). |
Proposal (scoped to src/utils/ only, for now)
- Resolve the three collisions by renaming to intent (above) and updating their call sites. Each rename is mechanical and independently committable.
- Add
src/utils/index.tswithexport * from "./<module>"for every source module; re-export the subfolders via their own barrels (export * from "./cosmos", add a tinybridge/index.ts). Exclude test files. Keep the barrel re-export-only — no logic, no side-effectful module loads. - Migrate the 418 imports to
from "../utils"(mechanical codemod / find-replace; no behavior change). - Enforce it: ESLint
no-restricted-importson**/utils/*(allowingutilsitself and intra-utils relative imports), so deep imports don't creep back. - New-utils convention: adding a util = add the module + its
.test.ts+ one barrel line (document in CLAUDE.md's utils section).
Out of scope for this issue (follow-ups if this proves out): barrels for hooks/, components/ui/ (#42 already tracks the component library surface), apis/.
Note on bundle size
ui#779 (first-load JS) is the reason to keep the barrel pure: export * of side-effect-free modules tree-shakes cleanly under Rollup, but a barrel that executes anything at import time would pull the whole utils layer into every chunk. Acceptance includes verifying chunk sizes don't regress.
Prior art / related
src/utils/cosmos/index.ts— existing in-repo precedent- block52/poker-vm#1635 (closed) — same pattern applied to engine manager imports
- #42 (open) — component library
index.tsdoes this forcomponents/ui/ - #779 (open) — bundle-size context for keeping the barrel pure
Acceptance criteria
- Three name collisions renamed (
base64ToHex×2,formatCountdown×2,getPublicKey×2) with call sites updated -
src/utils/index.ts+src/utils/bridge/index.tsadded, re-export-only - All consumer imports migrated to the barrel (no remaining deep
utils/*imports outsidesrc/utils/) - ESLint rule preventing new deep imports
-
yarn buildchunk sizes unchanged (± noise) — no tree-shaking regression -
yarn testandyarn lintgreen
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 5
- Avg merge
- 22h 35m
- Merged PRs (30d)
- 91
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 1 day ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
chore(ui): move existing inline null/empty and typeof checks to the guardsPossibly taken @bitcoinbrisbane claimed this 1 day ago. Openrefactor tech debt UI
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
feat(ui): display side pots separately when a player is all-inPossibly taken @TexasHODL claimed this today. OpenWeek 2
Difficulty 4/5 3-5 days Newbie friendliness 45/100
block52/ui#918 · 2 comments · 2 assignees ·
Maintainers usually reply within 1 day
Similar issues
-
Remove unused dependenciesPossibly taken @alastair-smith claimed this today. Openchore other
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
alastair-smith/card-games#384 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
code-yeongyu/senpi#5571 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nexu-io/open-design#9262 · 1 comment ·
Maintainers usually reply within 1 day
-
friction
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
kentcdodds/kody#4753 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 62/100
lingdojo/kana-dojo#33508 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day