fix: throw a clear error for unsupported transform functions (closes #644)#757
Open
Vitalini wants to merge 1 commit into
Open
fix: throw a clear error for unsupported transform functions (closes #644)#757Vitalini wants to merge 1 commit into
Vitalini wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| 'translateX', | ||
| 'translateY', | ||
| 'scale', | ||
| 'scaleX', |
Contributor
Fixes vercel#644. Previously, using an unsupported transform function like `translateZ(1px)`, `translate3d(...)`, `rotateX(...)`, `perspective(...)` or `matrix(...)` produced a cryptic downstream error such as `Y[r] is not a function` from the `css-to-react-native` parser, paired with the misleading hint that only absolute lengths were supported. This change validates the transform function names against the list of functions actually implemented by `builder/transform.ts` (plus the shorthand forms unfolded by `css-to-react-native`) and throws an explicit error that names the offending function and lists the supported set. Before: Y[r] is not a function in CSS rule `transform: translateZ(1px)`. Only absolute lengths such as `10px` are supported. After: `transform: translateZ()` is not supported. Supported transform functions: translate, translateX, translateY, scale, scaleX, scaleY, rotate, skewX, skewY. Test plan: two new cases in `test/error.test.tsx` cover a single unsupported function and a list with one unsupported function mixed in with a supported one. All existing error and transform tests continue to pass.
05dcd39 to
451b11e
Compare
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.
Summary
Fixes #644.
Previously, using an unsupported transform function like
translateZ(1px),translate3d(...),rotateX(...),perspective(...)ormatrix(...)produced a cryptic downstream error such asY[r] is not a functionfrom thecss-to-react-nativeparser, paired with the misleading hint that only absolute lengths were supported.This change validates transform function names up-front against the list of functions actually implemented by
builder/transform.ts(plus the shorthand forms thatcss-to-react-nativeunfolds) and throws an explicit error that names the offending function and lists the supported set.Before
After
Test plan
test/error.test.tsx:translateZ)rotate(45deg) rotateX(30deg))test/error.test.tsx,test/transform.test.tsx— 19 passing)