Skip to content

[CLASS-14252] Scope RTL value-heuristics in recommended config to high-signal checks#3085

Draft
maddy531 wants to merge 4 commits into
mainfrom
class-14252-rtl-recommended-conservative-heuristics
Draft

[CLASS-14252] Scope RTL value-heuristics in recommended config to high-signal checks#3085
maddy531 wants to merge 4 commits into
mainfrom
class-14252-rtl-recommended-conservative-heuristics

Conversation

@maddy531

@maddy531 maddy531 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

I previously had the 6 rtl lint rules set up for alter testing to see if they were helpful in catching RTL errors. During the transition to WB, I enabled all 6 rules as an experiment. While I was trying to set the eslint rule from warning to error in the frontend repo, I found that most for these rules didn't help.

This PR keeps the one one of these rules and removed the other 5

Flag Before After Why
warnBackgroundPosition keep Off-center bg images genuinely don't auto-flip; real bug, fixable via calc()/percentages
warnDirectionalTransforms Can't distinguish translateX(-50%) centering (RTL-safe) from directional offsets
warnShadows Fires on any X-offset shadow; imperceptible RTL impact
warnGradients Most gradients are symmetric/decorative; mirroring invisible
warnCursorDirections e-resize/w-resize — trivial, rare
warnBackgroundPositionXY backgroundPositionY is the block axis, which RTL never mirrors

Still fully enforced: the property-name → logical-property checks (marginLeftmarginInlineStart, etc., with autofix), textAlign: left/rightstart/end, float/clear, padding/margin shorthands, and backgroundPosition directional detection. None of those are gated by these flags.

Evidence

Audited the four KA frontend PRs escalating this rule to error (CLASS-14252). They introduce 25 new eslint-disable comments:

Cause Disables Real RTL bug?
translateX(-50%) centering / counter-rotated orbit 18 ❌ No
Symmetric transparent→white→transparent gradient 2 ❌ No
X-offset boxShadow (already paired with :dir(rtl)) 2 ❌ No
backgroundPositionY: bottom (block axis) 1 ❌ No
backgroundPosition: bottom right/left 2 ✅ Yes — and fixable via calc() (kept enforced)

23 of 25 (92%) are false positives eliminated by this change. The remaining 2 are caught by the check we keep, and are themselves fixable without a disable.

Risk

Disabling these means a genuinely directional transform/shadow/gradient wouldn't be linted. Across 25 real cases audited, zero were genuinely directional — the risk is empirically negligible, and the real directional cases (backgroundPosition) stay covered.

Test plan

  • No test snapshots the recommended config flags (verified — only the rule's own test file and unrelated codegen-template tests reference these names).
  • CI / consumers see fewer require-logical-properties-for-rtl errors after upgrading.

🤖 Generated with Claude Code

…-heuristics in recommended to high-signal checks only

The `recommended` config enabled all six value-heuristics of
`require-logical-properties-for-rtl`, but five of them have no
logical-property fix and fire almost entirely on RTL-safe code,
forcing `eslint-disable` suppressions on correct lines.

Keep `warnBackgroundPosition` (real, fixable signal); disable
`warnDirectionalTransforms`, `warnShadows`, `warnGradients`,
`warnCursorDirections`, `warnBackgroundPositionXY`. This matches the
rule's own `defaultOptions`. Part of CLASS-14252.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented May 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4143ffa

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 Major

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

Maddy Andrade and others added 3 commits June 1, 2026 10:48
…emove low-signal RTL heuristics; expand padding/margin shorthand

Remove the directional transform/shadow/gradient/cursor and backgroundPositionX/Y
checks outright (including their options) rather than disabling them: they have no
logical-property fix and are structurally unable to distinguish RTL-safe code from
real bugs, so leaving them as off-by-default toggles would only keep dead, un-fixable
checks around. Schema uses additionalProperties:false, so this is a breaking change
for any config that set those options -> changeset bumped to major.

Extend the padding/margin shorthand check to 3- and 4-value forms with autofix. The
4-value form is the genuine RTL hazard (left/right differ, don't auto-mirror) and was
previously uncaught. Collapse the recommended config entry to bare "error" since the
lone surviving option just restated defaultOptions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rop last rule option; autofix float/clear logical values

Remove the final warnBackgroundPosition option so the rule takes no options at
all -- the backgroundPosition/background directional check is now unconditional,
matching float/clear/direction. In the audited cases it only ever caught real
bugs, so a config-level off-switch wasn't justified; per-line eslint-disable
remains the escape hatch.

Add autofix for float: left/right -> inline-start/inline-end and clear likewise.
The flow-relative float/clear values are now Baseline (Chrome/Edge 118, Safari 15,
Firefox 55), so the fix the rule already recommended can be applied automatically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Size Change: -606 B (-0.47%)

Total Size: 128 kB

📦 View Changed
Filename Size Change
packages/eslint-plugin-wonder-blocks/dist/es/index.js 6.58 kB -606 B (-8.44%)
ℹ️ 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 761 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.48 kB
packages/wonder-blocks-date-picker/dist/es/index.js 8.06 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.7 kB
packages/wonder-blocks-form/dist/es/index.js 6.32 kB
packages/wonder-blocks-grid/dist/es/index.js 1.25 kB
packages/wonder-blocks-icon-button/dist/es/index.js 4.02 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.47 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.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.41 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 5.66 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 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 5.4 kB
packages/wonder-blocks-toolbar/dist/es/index.js 921 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.06 kB
packages/wonder-blocks-typography/dist/es/index.js 1.58 kB

compressed-size-action

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (b0f8cde) and published all packages with changesets to npm.

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR3085"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR3085

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

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

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