Skip to content

Comments

feat: add force left/right rules to RTL preset#1179

Merged
danielroe merged 2 commits intonpmx-dev:mainfrom
userquin:feat-add-force-rtl-rules
Feb 7, 2026
Merged

feat: add force left/right rules to RTL preset#1179
danielroe merged 2 commits intonpmx-dev:mainfrom
userquin:feat-add-force-rtl-rules

Conversation

@userquin
Copy link
Member

@userquin userquin commented Feb 7, 2026

No description provided.

@vercel
Copy link

vercel bot commented Feb 7, 2026

Deployment failed with the following error:

There is no GitHub account connected to this Vercel account.

@vercel
Copy link

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs.npmx.dev Error Error Feb 7, 2026 10:44pm
npmx.dev Ready Ready Preview, Comment Feb 7, 2026 10:44pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Feb 7, 2026 10:44pm

Request Review

@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danielroe danielroe enabled auto-merge February 7, 2026 22:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

The pull request introduces force-* direction utilities to the RTL preset that bypass RTL logic. It adds new test cases for force-* tokens and corresponding CSS utility definitions. The changes include new handler functions for forced padding, margin, positioning, text alignment, rounded corners and border widths. Updated warning messages guide users to either use suggested RTL alternatives or the force-* options to retain original physical directions. The CSS snapshots reflect the new default-layer block containing explicit force-* utility definitions.

Possibly Related PRs

Suggested Reviewers

  • danielroe
🚥 Pre-merge checks | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no author-provided description, making it impossible to assess whether it relates to the changeset. Add a pull request description explaining the purpose and scope of the force-* RTL rules being introduced, including why this feature is needed.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link
Contributor

@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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
uno-preset-rtl.ts (1)

22-28: ⚠️ Potential issue | 🟠 Major

Fix force- guidance for variant-prefixed utilities.*

force-${match} yields invalid ordering for variants (e.g., sm:pl-2force-sm:pl-2). The force prefix needs to be applied to the utility segment after the last variant prefix (e.g., sm:force-pl-2). This currently misleads users and will need snapshot updates once fixed.

💡 Suggested fix
 function reportWarning(match: string, suggestedClass: string, checker?: CollectorChecker) {
-  const message = `${checker ? 'a' : 'A'}void using '${match}', use '${suggestedClass}' instead, or 'force-${match}' to keep physical direction.`
+  const forceClass = match.replace(/([^:]+)$/, 'force-$1')
+  const message = `${checker ? 'a' : 'A'}void using '${match}', use '${suggestedClass}' instead, or '${forceClass}' to keep physical direction.`
   if (checker) {
     checker(message, match)
   } else {
     warnOnce(`[RTL] ${message}`, match)
   }
 }

Comment on lines +130 to +143
/^force-(?:position-|pos-)?(left|right)-(.+)$/,
([_, direction, size], context) => {
// Map 'left'/'right' to 'l'/'r' for directionMap lookup if needed,
// but directionMap has 'left'/'right' keys? No, it has 'l'/'r'.
// Wait, directionMap keys are 'l', 'r'.
// But inset usually uses 'left', 'right' properties directly.
// Let's use a custom handler for inset to be safe.
const v =
(context.theme as unknown as any).spacing?.[size || 'DEFAULT'] ??
h.bracket?.cssvar?.global?.auto?.fraction?.rem?.(size!)
if (v != null) {
return [[direction === 'left' ? 'left' : 'right', v]]
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove the any cast to keep this rule type-safe.

context.theme as unknown as any breaks strict type-safety. You can destructure theme using RuleContext<any> (like the helper does) and avoid the cast.

💡 Suggested fix
-      ([_, direction, size], context) => {
+      ([_, direction, size], { theme }: RuleContext<any>) => {
         // Map 'left'/'right' to 'l'/'r' for directionMap lookup if needed,
         // but directionMap has 'left'/'right' keys? No, it has 'l'/'r'.
         // Wait, directionMap keys are 'l', 'r'.
         // But inset usually uses 'left', 'right' properties directly.
         // Let's use a custom handler for inset to be safe.
         const v =
-          (context.theme as unknown as any).spacing?.[size || 'DEFAULT'] ??
+          theme.spacing?.[size || 'DEFAULT'] ??
           h.bracket?.cssvar?.global?.auto?.fraction?.rem?.(size!)
         if (v != null) {
           return [[direction === 'left' ? 'left' : 'right', v]]
         }
       },
As per coding guidelines, "Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index".
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/^force-(?:position-|pos-)?(left|right)-(.+)$/,
([_, direction, size], context) => {
// Map 'left'/'right' to 'l'/'r' for directionMap lookup if needed,
// but directionMap has 'left'/'right' keys? No, it has 'l'/'r'.
// Wait, directionMap keys are 'l', 'r'.
// But inset usually uses 'left', 'right' properties directly.
// Let's use a custom handler for inset to be safe.
const v =
(context.theme as unknown as any).spacing?.[size || 'DEFAULT'] ??
h.bracket?.cssvar?.global?.auto?.fraction?.rem?.(size!)
if (v != null) {
return [[direction === 'left' ? 'left' : 'right', v]]
}
},
/^force-(?:position-|pos-)?(left|right)-(.+)$/,
([_, direction, size], { theme }: RuleContext<any>) => {
// Map 'left'/'right' to 'l'/'r' for directionMap lookup if needed,
// but directionMap has 'left'/'right' keys? No, it has 'l'/'r'.
// Wait, directionMap keys are 'l', 'r'.
// But inset usually uses 'left', 'right' properties directly.
// Let's use a custom handler for inset to be safe.
const v =
theme.spacing?.[size || 'DEFAULT'] ??
h.bracket?.cssvar?.global?.auto?.fraction?.rem?.(size!)
if (v != null) {
return [[direction === 'left' ? 'left' : 'right', v]]
}
},

@danielroe danielroe added this pull request to the merge queue Feb 7, 2026
Merged via the queue into npmx-dev:main with commit 0105bef Feb 7, 2026
16 of 17 checks passed
@userquin userquin deleted the feat-add-force-rtl-rules branch February 7, 2026 22:49
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.

2 participants