chore(utils): add src/utils barrel file — 418 deep imports across 188 files; 3 export-name collisions block export *
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- eslint, typescript, vite
- Ambito
- developer-experience, frontend, tooling
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 2
- Fork
- 5
- Merge medio
- 22h 35m
- PR unite (30g)
- 91
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di block52/ui
-
enhancement tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
feat(ui): player notes and tags — click a seat to note a player; tag icons (fish, shark, tight, loose…) show by their pillForse già presa @Dzeezbtc l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
chore(ui): move existing inline null/empty and typeof checks to the guardsForse già presa @bitcoinbrisbane l’ha presa 1 giorno fa. Apertarefactor tech debt UI
block52/ui#937 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
feat(ui): display side pots separately when a player is all-inForse già presa @TexasHODL l’ha presa oggi. ApertaWeek 2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
block52/ui#918 · 2 commenti · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
oxidecomputer/skepsis#102 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
voidzero-dev/void#677 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
kunchenguid/gh-axi#247 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
lidge-jun/opencodex#8101 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno