Repository navigation
feat(lint): enforce BaseProps styling passthrough (xstyle/className/style) - #4528
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
f86ade3 to
c59049e
Compare
c59049e to
ea317c7
Compare
ea317c7 to
92591ea
Compare
c63a8b8 to
b1fc36b
Compare
b1fc36b to
f8d2a76
Compare
f8d2a76 to
ac595ba
Compare
|
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. |
ea22c0e to
47d75b7
Compare
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.
47d75b7 to
594c6fa
Compare
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — both nits fixed. I reverted the element change locally and the new test does catch it. Approve once you undraft.
[Reviewed by Robohands]
Summary
Components declare their styling contract by extending
BaseProps, which includesxstyle,className, andstyle. Nothing currently enforces that the implementationactually 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-passthroughas 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
BasePropsstyling contract. It reports two failure modes:
classNameandstylemay ride a rest spread onto a native or composed root.xstylecannot be a native DOM attribute, so an un-destructured
xstyleonly counts when therest 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 andnone in lab, charts, or richtext:
packages/core/src/TopNav/TopNavMegaMenuItem.tsx:189xstyle,className,stylepackages/core/src/Typeahead/BaseTypeahead.tsx:375xstyle,className,stylepackages/core/src/VisuallyHidden/VisuallyHidden.tsx:89xstyleAll seven are real contract mismatches; none are false positives:
TopNavMegaMenuItemPropscarries all three props, while neither its drawer nor desktoproot receives them.
BaseTypeaheadPropscarries all three props, while the input and popover paths receivenone of them.
inputXStyledoes not remove the inheritedBasePropspromise.VisuallyHiddendocuments that all styling props are intentionally unsupported, butits
Omitcurrently excludes onlyclassNameandstyle, leavingxstylepublic.#5563 fixed the other eight warnings
previously listed here (
TopNavMenu,TopNavMegaMenu, andTypeaheadItem), so they arenot 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
packages/**changes in this PR.