Skip to content

Implement ADR 012: Replace unguarded console.warn calls with warning() helper#7592

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/review-unimplemented-adrs
Draft

Implement ADR 012: Replace unguarded console.warn calls with warning() helper#7592
Copilot wants to merge 2 commits intomainfrom
copilot/review-unimplemented-adrs

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Implements ADR 012 (Development Warnings): all console.warn() calls in production-reachable code paths must be wrapped in __DEV__ or use the existing warning() helper (which is already __DEV__-gated and a no-op in production).

Changes

Replaced bare console.warn() calls with warning(condition, message) in:

  • Radio.tsx — missing name attribute warning
  • TextInputInnerAction.tsx — missing aria-label warning
  • CheckboxOrRadioGroup.tsx — missing label/aria-labelledby warning
  • SegmentedControl.tsx — missing aria-label/aria-labelledby warning
  • utils/deprecate.tsxDeprecations.deprecate() static method now calls warn() instead of console.warn()

Simplified __DEV__-wrapped blocks that can be expressed more cleanly with warning():

  • Heading.tsx — removed redundant if (__DEV__) wrapper around useEffect; warning() handles dev-gating, eliminating the conditional hook pattern
  • FilteredActionList.tsx — collapsed __DEV__ + nested if into a single warning() call
  • DataTable/useTable.ts — replaced 4 if (__DEV__) { console.warn(...) } blocks with warning(true, msg)

Note: ButtonBase.tsx retains its if (__DEV__) { console.warn(...) } pattern intentionally — refactoring to warning() would surface SSR linting errors (ssr-friendly/no-dom-globals-in-react-fc) since HTMLButtonElement/HTMLAnchorElement are used in the render cycle. The existing pattern already satisfies ADR 012.

Before:

// Runs in production, no-op guards missing
if (!name && !ariaHidden) {
  // eslint-disable-next-line no-console
  console.warn('A radio input must have a `name` attribute...')
}

After:

// Stripped from production builds via __DEV__ gating inside warning()
warning(
  !name && !ariaHidden,
  'A radio input must have a `name` attribute...',
)

Changelog

New

  • None

Changed

  • console.warn() calls in Radio, TextInputInnerAction, CheckboxOrRadioGroup, SegmentedControl, Deprecations, Heading, FilteredActionList, and DataTable/useTable now use the warning() / warn() helpers and are stripped from production builds

Removed

  • None

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Internal refactor with no API or behavior change for consumers. Warnings only appear in development; production output is identical.

Testing & Reviewing

All affected component test suites pass (Radio, SegmentedControl, Heading, DataTable, RadioGroup, CheckboxGroup, TextInput, utils). Development warnings continue to emit as expected (visible in test stderr output).

Merge checklist

Original prompt

look at unimplemented ADRs in ./adrs, and tell me the easiest one to implement


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: e19562c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…) helper

Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Copilot AI changed the title [WIP] Review unimplemented ADRs for ease of implementation Implement ADR 012: Replace unguarded console.warn calls with warning() helper Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants