Repository navigation
[babel-plugin] treat fontSizeAdjust as a unitless number - #1903
Merged
Merged
Conversation
|
@Om-singhaI is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes Babel plugin normalization so numeric fontSizeAdjust values compile as unitless CSS.
Changes:
- Registers
fontSizeAdjustas unitless. - Adds regression coverage for generated CSS.
| File | Description |
|---|---|
packages/@stylexjs/babel-plugin/src/shared/utils/transform-value.js |
Treats fontSizeAdjust numbers as unitless. |
packages/@stylexjs/babel-plugin/__tests__/transform-value-normalization-test.js |
Verifies unitless CSS output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mellyeliu
approved these changes
Sep 23, 2026
2 tasks done
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.
What changed / motivation ?
transformValueturns a numeric style value into a string and asksgetNumberSuffixwhat unit to append.getNumberSuffixfalls back topxwhen the key is not inunitlessNumberPropertiesand has no entry innumberPropertySuffixes.fontSizeAdjustwas in neither, sofontSizeAdjust: 0.545compiled tofont-size-adjust:.545px.font-size-adjusttakes a plain number, so the browser drops the declaration and the property does nothing.The Flow type for this property is
'none' | number, so a number is what users are told to write. A string like'0.545'does compile to valid CSS, because strings never reachgetNumberSuffix, but Flow rejects it. Dynamic styles already emit the value unitless through a custom property, so static and dynamic styles produced different CSS for the same input.fontSizeAdjusttounitlessNumberPropertiesinshared/utils/transform-value.js, next tofontWeight.unitlesscase intransform-value-normalization-test.jswithfontSizeAdjust: 0.545, the same way [babel-plugin] fix unitless zoom bug #1346 extended it withzoom: 2.Same shape of fix as #1346 for
zoomand #705 for the grid properties.Linked PR/Issues
Fixes #1902
Additional Context
Only
fontSizeAdjustchanges. No other key moves in or out of the set, and no existing snapshot changed.Testing, all measured on this branch against main at 20f2a50 with Node 25.6.1 and jest 30.1.3, run from
packages/@stylexjs/babel-plugin:npx jest __tests__/transform-value-normalization-test.js: 1 suite, 18 tests passed, 19 snapshots passed.npx jest __tests__/transform-value-normalization-test.js __tests__/transform-stylex-create-test.js: 2 suites, 118 tests passed, 217 snapshots passed.npx jest src/shared/utils/__tests__: 3 suites, 28 tests passed.npx jest __tests__/transform-stylex-keyframes-test.js __tests__/transform-stylex-props-test.js __tests__/validation-stylex-create-test.js: 3 suites, 141 passed, 58 skipped, 113 snapshots passed.transform-value.jsrestored from main and the new test kept,npx jest __tests__/transform-value-normalization-test.jsgives 1 failed and 17 passed, and the snapshot diff reads.x1v6sj9q{font-size-adjust:.545}against.xq0srfb{font-size-adjust:.545px}.--checkand eslint 8.57.1 are clean on both changed files..x1v6sj9q{font-size-adjust:.545}where it printed.xq0srfb{font-size-adjust:.545px}before.fontSizeAdjust: 0.545andfontSizeAdjust: '0.545'now compile to the same rule,.x1v6sj9q{font-size-adjust:.545}.0still givesfont-size-adjust:0,'none'still givesfont-size-adjust:none, and the dynamic form still givesfont-size-adjust:var(--x-fontSizeAdjust).Pre-flight checklist
Contribution Guidelines