Skip to content

fix: parsing multiple transforms tokens in single class#451

Merged
Brentlok merged 3 commits intomainfrom
fix/transform-parsing
Mar 12, 2026
Merged

fix: parsing multiple transforms tokens in single class#451
Brentlok merged 3 commits intomainfrom
fix/transform-parsing

Conversation

@Brentlok
Copy link
Contributor

@Brentlok Brentlok commented Mar 12, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Support for composite CSS transforms in a single token, allowing multiple transform operations (translate, rotate, scale, etc.) to be declared and handled together.
  • Tests

    • Added a test verifying multiple transforms are applied and normalized as a single transform sequence.
  • Chores

    • Updated a development dependency version.

@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 55283174-2661-4bb3-bf69-41a51066bd8f

📥 Commits

Reviewing files that changed from the base of the PR and between 10fe09f and e92d44e.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • package.json
  • packages/uniwind/src/metro/processor/css.ts

📝 Walkthrough

Walkthrough

Adds detection and flattening of CSS transform arrays in the Metro CSS processor: a TRANSFORM_TYPES set and isTransformArray() helper ensure arrays of transform objects are processed element-wise and normalized to a flat transform array. Includes a test and CSS utility for multiple transforms in one token.

Changes

Cohort / File(s) Summary
Transform Array Processing
packages/uniwind/src/metro/processor/css.ts
Adds TRANSFORM_TYPES set and isTransformArray(); updates Array handling to detect transform arrays, process each element, and flatten results into a single transform array.
Tests & Fixtures
packages/uniwind/tests/native/styles-parsing/transforms.test.tsx, packages/uniwind/tests/test.css
Adds @utility multiple-transform { transform: translateX(10px) translateY(10px); } and a test asserting a single token with multiple transforms yields the expected flattened transform array.
Tooling
package.json
Bumps devDependency turbo from 2.8.13 to 2.8.16.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through transforms, one, two, three,

Flattened the dance so the styles run free,
translateX then translateY in line,
One token, many moves — neat and fine,
A rabbit's cheer for tidy design.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing parsing of multiple transform tokens within a single CSS class, which aligns with the additions to transform array handling and test cases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/transform-parsing
📝 Coding Plan for PR comments
  • Generate coding plan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/uniwind/src/metro/processor/css.ts (1)

518-522: Consider adding a null check for defensive coding.

typeof null === 'object' in JavaScript, so if values ever contains a null element, the 'type' in value check would throw a TypeError. While unlikely with lightningcss output, a null guard would be more robust.

🛡️ Optional defensive fix
 private isTransformArray(values: Array<any>) {
     return values.every(
-        value => typeof value === 'object' && 'type' in value && CSS.TRANSFORM_TYPES.has(value.type),
+        value => typeof value === 'object' && value !== null && 'type' in value && CSS.TRANSFORM_TYPES.has(value.type),
     )
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/uniwind/src/metro/processor/css.ts` around lines 518 - 522, The
isTransformArray method can throw if an element is null because typeof null ===
'object'; update the predicate in isTransformArray to guard against
null/undefined (e.g., check value != null or value !== null) before checking
'type' and CSS.TRANSFORM_TYPES so values.every(...) only accesses properties on
non-null objects; keep the rest of the logic (using
CSS.TRANSFORM_TYPES.has(value.type)) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/uniwind/src/metro/processor/css.ts`:
- Around line 518-522: The isTransformArray method can throw if an element is
null because typeof null === 'object'; update the predicate in isTransformArray
to guard against null/undefined (e.g., check value != null or value !== null)
before checking 'type' and CSS.TRANSFORM_TYPES so values.every(...) only
accesses properties on non-null objects; keep the rest of the logic (using
CSS.TRANSFORM_TYPES.has(value.type)) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3049cdf0-a5a4-4f1c-a67a-a7e89a8daab6

📥 Commits

Reviewing files that changed from the base of the PR and between a828e68 and 10fe09f.

📒 Files selected for processing (3)
  • packages/uniwind/src/metro/processor/css.ts
  • packages/uniwind/tests/native/styles-parsing/transforms.test.tsx
  • packages/uniwind/tests/test.css

@Brentlok Brentlok merged commit 34693ea into main Mar 12, 2026
1 check passed
@Brentlok Brentlok deleted the fix/transform-parsing branch March 12, 2026 13:23
@github-actions
Copy link
Contributor

🚀 This pull request is included in v1.6.0. See Release v1.6.0 for release notes.

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