Skip to content

feat(lint): enforce BaseProps styling passthrough (xstyle/className/style) - #4528

Merged
cixzhang merged 1 commit into
mainfrom
feat/lint-baseprops-passthrough
Aug 27, 2026
Merged

cixzhang merged 1 commit into
mainfrom
feat/lint-baseprops-passthrough

Conversation

@cixzhang

@cixzhang cixzhang commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Components declare their styling contract by extending BaseProps, which includes
xstyle, className, and style. Nothing currently enforces that the implementation
actually forwards those props, so a component can promise all three escape hatches in
its types while silently dropping them at runtime.

This adds @astryx/require-baseprops-passthrough as a warning in both ESLint configs.
It stays warning-only while violations remain; promotion to an error should be a
separate, deliberate step after the repository is clean.

Rule behavior

The rule checks public components with a local props interface carrying the BaseProps
styling contract. It reports two failure modes:

  • Unused — a styling prop is destructured but never referenced.
  • Not forwarded — a styling prop promised by the type never reaches the root.

className and style may ride a rest spread onto a native or composed root. xstyle
cannot be a native DOM attribute, so an un-destructured xstyle only counts when the
rest object is passed to a composed component.

A component can opt out by omitting a styling prop from its type, or explicitly bind an
intentionally unused prop with a leading underscore.

Current main inventory

Rebased onto current main, the rule reports 7 violations across 3 core files and
none in lab, charts, or richtext:

File Props dropped
packages/core/src/TopNav/TopNavMegaMenuItem.tsx:189 xstyle, className, style
packages/core/src/Typeahead/BaseTypeahead.tsx:375 xstyle, className, style
packages/core/src/VisuallyHidden/VisuallyHidden.tsx:89 xstyle

All seven are real contract mismatches; none are false positives:

  • TopNavMegaMenuItemProps carries all three props, while neither its drawer nor desktop
    root receives them.
  • BaseTypeaheadProps carries all three props, while the input and popover paths receive
    none of them. inputXStyle does not remove the inherited BaseProps promise.
  • VisuallyHidden documents that all styling props are intentionally unsupported, but
    its Omit currently excludes only className and style, leaving xstyle public.

#5563 fixed the other eight warnings
previously listed here (TopNavMenu, TopNavMegaMenu, and TypeaheadItem), so they are
not retained as stale inventory.

Known reach limit: styling contracts are resolved from interfaces declared in the same
file. Imported props types are skipped; widening that analysis is a separate change.

Testing

  • RuleTester suite: 13 tests pass.
  • ESLint inventory: core 7 warnings in 3 files; lab 0; charts 0; richtext 0.
  • Pre-push repository checks pass.
  • No packages/** changes in this PR.

@vercel

vercel Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 27, 2026 4:59am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 29, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Jul 29, 2026
github-actions Bot added a commit that referenced this pull request Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang changed the title feat(lint): enforce xstyle passthrough via BaseProps feat(lint): enforce BaseProps styling passthrough (xstyle/className/style) Jul 30, 2026
@cixzhang
cixzhang force-pushed the feat/lint-baseprops-passthrough branch from f86ade3 to c59049e Compare July 30, 2026 06:13
@cixzhang
cixzhang force-pushed the feat/lint-baseprops-passthrough branch from c59049e to ea317c7 Compare July 30, 2026 06:19
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
@cixzhang
cixzhang force-pushed the feat/lint-baseprops-passthrough branch from ea317c7 to 92591ea Compare July 30, 2026 19:35
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
Comment thread packages/core/src/TopNav/TopNavMenu.tsx Resolved
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
@cixzhang
cixzhang force-pushed the feat/lint-baseprops-passthrough branch from c63a8b8 to b1fc36b Compare July 30, 2026 22:30
github-actions Bot added a commit that referenced this pull request Jul 30, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

Direction: keep the invariant, but refresh this branch against current main before it advances. Re-measure the now-stale finding inventory and leave the rule warning-only until the repo is clean enough to promote it deliberately.

@cixzhang
cixzhang force-pushed the feat/lint-baseprops-passthrough branch from ea22c0e to 47d75b7 Compare August 27, 2026 04:19
github-actions Bot added a commit that referenced this pull request Aug 27, 2026
Add @astryx/require-baseprops-passthrough to catch public components that declare xstyle, className, and style through BaseProps but silently drop those props at runtime. Keep the rule warning-only while existing violations remain.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — both nits fixed. I reverted the element change locally and the new test does catch it. Approve once you undraft.

[Reviewed by Robohands]

@cixzhang
cixzhang marked this pull request as ready for review August 27, 2026 05:13
@cixzhang
cixzhang merged commit d1cab79 into main Aug 27, 2026
31 of 33 checks passed
@cixzhang
cixzhang deleted the feat/lint-baseprops-passthrough branch August 27, 2026 05:15
github-actions Bot added a commit that referenced this pull request Aug 27, 2026

This branch was successfully deployed

1 active deployment
Preview — 594c6fa8 Deployed Aug 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant