chore(core): standardize dev-time console warnings#4307
Open
cixzhang wants to merge 1 commit into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Add useDevWarning hook plus devWarn/devError/warnOnce utilities so components surface builder guidance consistently: once per mount via a ref + effect (never on every render, never via extra state), in a uniform `Component: message` format. Route all existing console.warn/error call sites through the new helpers (Field, Timestamp, useOverflow, Popover, Table, Toast, Theme, i18n, defineSyntaxTheme, Drawer) and drop the ad-hoc dedup flags.
cixzhang
force-pushed
the
feat/standardize-dev-warnings
branch
from
July 25, 2026 02:27
b4c088f to
9ebe350
Compare
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsField · View in Storybook
Popover · View in Storybook
Table · View in Storybook
Timestamp · View in Storybook
Toast · View in Storybook
i18n
Bundle Size Summary
Accessibility AuditStatus: 2 accessibility violation(s) found — 2 serious. Table - 1 issue(s)
Timestamp - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
enabled auto-merge (squash)
July 25, 2026 02:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
We warn and error to the builder in a bunch of places, but there was no shared pattern. Two problems kept recurring:
if (cond) console.warn(...)in a component body repeats each render, and the "fix" people reached for was extrauseState— needless state and re-renders just to gate a log.[Table],[Astryx],useToast:, bare strings), so it wasn't always obvious which component a message came from.What
A small dev-logging utility family in
@astryxdesign/core, and every existing call site migrated to it:useDevWarning(component, message, condition?)— the primary pattern. Aref+useEffectfires the warning once per mount when the condition holds: never during render, never triggering a re-render, no extra state. This is the correct replacement for the render-body/useStateanti-pattern.devWarn/devError— imperative helpers for the contexts a hook can't reach (plain functions, module init, inside effects).devWarnis dev-only;devErrorruns in prod too, since it reports real runtime failures that should reach telemetry.warnOnce(key, ...)— global once-per-key dedup for singleton warnings (per-theme perf hint, missing i18n key, one-time fallback), replacing three separate ad-hocSet/boolean flags.All output is normalized to
Component: message.Risk
Low. Warning text is unchanged in substance — only the prefix is normalized (
[Table]→Table:,[Astryx] Theme "x"→Theme: "x", etc.). Warnings are dev-only guardrails;devErrorpreserves the existing always-on behavior for plugin failures. Assertions in the affected tests were updated to match the new prefix.Testing
pnpm -F @astryxdesign/core test— 1171 passing (incl. new colocated tests for the util + hook)pnpm -F @astryxdesign/lab test src/Drawer— 41 passingpnpm -F @astryxdesign/core typecheck,lint,build, andsync-exports --checkall clean