Repository navigation
feat(enforce-logical): the block axis, and sizes on request (#215) - #223
Merged
Merged
Conversation
Tailwind 4.2 shipped logical utilities for the block axis and for sizing, and
enforce-logical only mapped the inline axis, so a converted project could
reintroduce `mt-4`, `top-0` or `border-b` unreported.
- Block axis: mt/mb → mbs/mbe, pt/pb → pbs/pbe, scroll-mt… → scroll-mbs…,
top/bottom → inset-bs/inset-be, border-t/border-b → border-bs/border-be.
They follow `direction`, whose default 'both' always meant both axes.
- `sizing: true` (off by default): w/min-w/max-w → inline/min-inline/
max-inline, h/… → block/…, size → inline + block (variant and `!` on both).
- With a design system on 4.2+, left/right become inset-s/inset-e, the
spelling enforce-canonical would rewrite start/end into.
- Never a dead class. A 4.2 target is probed as `<to>-0` (isValid accepts an
arbitrary value on any prefix, so `mt-[3px]` became `mbs-[3px]` on 4.1;
`inline-flex` made `inline` a known prefix). Without a design system the
block axis and sizes are only suggested, through reportClassSuggestion, and
left/right fall back to start/end. A named size converts only when both
classes declare the same value (`w-xs` reads --width-xs, `inline-xs` only
--container-xs); `w-dvh`, `h-dvw`, `max-w-prose`, `max-w-screen-*` have no
counterpart and are skipped.
- New messageId `useLogicalWritingMode` ("so it follows the writing mode") for
the block axis and sizes; ReplacementEntry takes a per-entry messageId so one
string can mix them under one autofix.
- enforce-physical inverts all of it, both inset spellings included
(LOGICAL_INSET_ALIASES folded into invertAxisMappings), and never touches a
display utility.
- enforce-shorthand folds the logical pairs (mbs+mbe → my, inset-s+inset-e →
inset-x, border-bs+border-be → border-y, the four logical sides), so logical
+ shorthand converge whichever fix lands first; never inline+block → size.
declaredValues/sameValues move to utils/declared-values.ts, shared.
Tests: generated table cases with and without a design system, sizing across
theme namespaces (axis-namespaces.css gains --width-xs), a hand-built 4.1
design system for convertDirectional, display exclusion, a real-binary e2e for
convergence in every fix order, and engine-smoke on the real 4.1.15 / 4.2.
Mutations of the value comparison, the 4.1 probe, skipValues and the display
exclusion each fail a test.
Bench: enforce-logical on shadcn/ui apps/v4 goes 600 → 1160 (block axis);
138 messages now name inset-s/inset-e; nothing removed. The CSS oracle finds
all 1028 fixed strings equivalent. Baselines, latest.json, /benchmark and
/comparison regenerated.
Claude-Session: https://claude.ai/code/session_019vTh6S5A41M1HLkmk3FaM1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #215.
Summary
Tailwind 4.2 shipped logical utilities for the block axis and for sizing.
enforce-logicalonly mapped the inline axis, so a converted project could reintroducemt-4,top-0orborder-bwithout a report.mt/mb→mbs/mbe,pt/pb→pbs/pbe,scroll-m*/scroll-p*,top/bottom→inset-bs/inset-be, andborder-t/border-b→border-bs/border-be. These followdirection, whose default'both'has always meant both axes.sizing: true(off by default):w/hand theirmin-/max-forms →inline/block, andsize-*→inline-* block-*.left/right→inset-s/inset-ewith a design system on 4.2+. This is the canonical spelling, soenforce-canonicalno longer needs a second pass.<to>-0. Two shortcuts failed:isValidaccepts an arbitrary value on any prefix, somt-[3px]becamembs-[3px]on 4.1, andinline-flexmadeinlinelook like a known prefix.w-xsreads--width-xs, whileinline-xsreads--container-xs).w-dvh,h-dvw,max-w-proseandmax-w-screen-*have no counterpart and are skipped.useLogicalWritingModefor the block axis and sizes. These differ from their logical forms only in vertical text, not in RTL.enforce-physicalinverts all of the above and never touches a display utility (inline-flex).enforce-shorthandfolds the logical pairs, so logical + shorthand converge whichever fix lands first.Bench
apps/v4,enforce-logicalgoes from 600 → 1160 reports, all on the block axis. 138 messages now nameinset-s/inset-e, and nothing is removed.latest.json,/benchmarkand/comparisonare regenerated.Test plan
convertDirectional; display exclusion.skipValuesand the display exclusion each fail a test.logical-shorthand-convergence: real binary, every fix order converges. Removing thembs+mbefamily fails it.engine-smoke.mjson real Tailwind 4.1.15 (left-[3px]→start-[3px], nombs-) and 4.3.3. CI runs 4.1.15 and 4.2.direction,sizing, the behavior without a DS and on 4.1, interactions;doc-examplesruns every new ✗/✓ example.lint:types,format:check, typecheck, build andpnpm test(3704 + 312); benchnpm test;interop.mjs.🤖 Generated with Claude Code
https://claude.ai/code/session_019vTh6S5A41M1HLkmk3FaM1