Skip to content

[CLASS-13991] Add no-rtl-icon-swap ESLint rule - #3175

Draft
maddy531 wants to merge 4 commits into
CLASS-13991.rtl-directional-iconsfrom
CLASS-13991.no-rtl-icon-swap
Draft

[CLASS-13991] Add no-rtl-icon-swap ESLint rule#3175
maddy531 wants to merge 4 commits into
CLASS-13991.rtl-directional-iconsfrom
CLASS-13991.no-rtl-icon-swap

Conversation

@maddy531

Copy link
Copy Markdown
Contributor

Summary

  • Adds @khanacademy/wonder-blocks/no-rtl-icon-swap to catch RTL ternaries that swap any Phosphor icon on the mirroring whitelist (carets, arrows, sign-in/sign-out, indent/outdent, etc.).
  • Embeds a copy of MIRRORED_ICON_NAMES in the eslint plugin (no React dependency) with a sync test against wonder-blocks-icon.
  • Enables the rule as error in recommended.

Stacked on #3174 (CLASS-13991.rtl-directional-icons). Merge the base RTL mirroring PR first; this PR only touches the eslint plugin / its docs.

Test plan

  • pnpm exec jest packages/eslint-plugin-wonder-blocks/src/rules/__tests__/no-rtl-icon-swap.test.ts packages/eslint-plugin-wonder-blocks/src/data/__tests__/mirrored-icon-names.test.ts
  • Confirm sync test fails if the eslint copy drifts from mirrored-icon-names.ts in wonder-blocks-icon
  • Spot-check demo: packages/eslint-plugin-wonder-blocks/demo/src/no-rtl-icon-swap-example.tsx
  • After base PR merges, retarget this PR to main (or merge stack as-is)

Made with Cursor

Maddy Andrade and others added 2 commits August 11, 2026 13:18
Whitelists reading-direction glyphs and flips them under :dir(rtl). Which
icons mirror is owned by Wonder Blocks — update directional-icons.ts rather
than handling RTL at the call site.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the RTL whitelist as an explicit source of truth so PhosphorIcon and
follow-on tooling (e.g. lint) can share the same list without editing the
matching helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a8976a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/eslint-plugin-wonder-blocks Minor

Not sure what this means? Click here to learn what changesets are.

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

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Size Change: +1.15 kB (+0.86%)

Total Size: 134 kB

📦 View Changed
Filename Size Change
packages/eslint-plugin-wonder-blocks/dist/es/index.js 8.25 kB +1.15 kB (+16.16%) ⚠️
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.02 kB
packages/wonder-blocks-announcer/dist/es/index.js 2.43 kB
packages/wonder-blocks-badge/dist/es/index.js 2.03 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.93 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 798 B
packages/wonder-blocks-button/dist/es/index.js 4.28 kB
packages/wonder-blocks-card/dist/es/index.js 1.09 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.61 kB
packages/wonder-blocks-core/dist/es/index.js 2.6 kB
packages/wonder-blocks-data/dist/es/index.js 5.51 kB
packages/wonder-blocks-date-picker/dist/es/index.js 8.06 kB
packages/wonder-blocks-dropdown/dist/es/index.js 20.4 kB
packages/wonder-blocks-form/dist/es/index.js 6.39 kB
packages/wonder-blocks-grid/dist/es/index.js 1.25 kB
packages/wonder-blocks-icon-button/dist/es/index.js 4.06 kB
packages/wonder-blocks-icon/dist/es/index.js 2.66 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 4.2 kB
packages/wonder-blocks-layout/dist/es/index.js 1.69 kB
packages/wonder-blocks-link/dist/es/index.js 1.54 kB
packages/wonder-blocks-modal/dist/es/index.js 7.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.32 kB
packages/wonder-blocks-popover/dist/es/index.js 4.41 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.49 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.12 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.6 kB
packages/wonder-blocks-tabs/dist/es/index.js 5.62 kB
packages/wonder-blocks-testing-core/dist/es/index.js 4.09 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.53 kB
packages/wonder-blocks-tokens/dist/es/index.js 6.48 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.19 kB
packages/wonder-blocks-typography/dist/es/index.js 1.04 kB

compressed-size-action

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-nxfxvmsmqc.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 544
Tests with visual changes 0
Total stories 869
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 544

Maddy Andrade and others added 2 commits August 11, 2026 14:18
Chromatic/Storybook production builds emit `arrow-right-[hash].svg`.
Suffix-only matching missed those, so glyphs never got the mirror class
even though flex layout reversed under dir=rtl.

Co-authored-by: Cursor <cursoragent@cursor.com>
Flag RTL ternaries that swap Phosphor icons on the mirroring whitelist so
call sites cannot double-flip once PhosphorIcon auto-mirrors.

Co-authored-by: Cursor <cursoragent@cursor.com>
@maddy531
maddy531 force-pushed the CLASS-13991.no-rtl-icon-swap branch from f0da0c7 to a8976a5 Compare August 11, 2026 18:18
@maddy531
maddy531 force-pushed the CLASS-13991.rtl-directional-icons branch from d16c894 to f124ade Compare August 11, 2026 18:51
@maddy531
maddy531 force-pushed the CLASS-13991.rtl-directional-icons branch from 72980b9 to 28788bc Compare August 20, 2026 13:50
@maddy531
maddy531 force-pushed the CLASS-13991.rtl-directional-icons branch from 7e36805 to 976777e Compare August 31, 2026 14:31
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.

1 participant