Ensure --alpha(…) is seen as a color, and --spacing(…) is seen as a length#20260
Conversation
Confidence Score: 5/5The change is minimal and surgical — two small regex additions, each directly tested with snapshot assertions covering the previously-broken cases. Both No files require special attention. Reviews (2): Last reviewed commit: "update changelog" | Re-trigger Greptile |
WalkthroughTwo data-type recognizer functions are updated to correctly classify custom CSS function values. In 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/tailwindcss/src/utils/math-operators.ts`:
- Line 39: The issue is that in the addWhitespaceAroundMathOperators function,
the function-name scanner at lines 95-99 strips hyphens from function names,
causing --spacing( to be parsed as spacing instead of --spacing. When the code
checks MATH_FUNCTIONS.includes(fn) at line 107, it fails to match because it's
checking for spacing instead of --spacing. To fix this, modify the function-name
checking logic in addWhitespaceAroundMathOperators to also check for the
hyphenated version of custom properties (like --spacing) against MATH_FUNCTIONS,
either by preserving the original function name with hyphens before the check or
by adding both the stripped and hyphenated versions to the includes check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e9c54fb2-ff61-41ef-a75e-48dc69bbb662
📒 Files selected for processing (3)
packages/tailwindcss/src/utilities.test.tspackages/tailwindcss/src/utils/is-color.tspackages/tailwindcss/src/utils/math-operators.ts
Instead of hijacking the math operators
878deda to
bbd9e63
Compare
This PR fixes an issue where intellisense recommends this canonicalization:
Which is correct, but the issue is that the result is different due to ambiguity of the
text-*utilities.Notice that we're using
colorall of a sudden? This is because that's the default and we infer the data type based on the arbitrary value. Thecalc(…)infers that the type islength, but we don't know what the type of--spacing(…)is so we fallback to the default type which would becolor.This PR makes sure that built in functions like
--alpha(…)and--spacing(…)are resolved ascolorandlengthrespectively.With this fix in place, this is the result:
Fixes: #20256
Fixes: #20258
Test plan