Skip to content

Conversation

@alexdln
Copy link
Contributor

@alexdln alexdln commented Feb 8, 2026

In a recent issue (#1116), we removed all hardcoded font-size classes, migrated them to our own inner classes, and agreed to use rem everywhere. We also added an rtl:check step, which checks whether classes comply with rtl patterns. Based on this, I'm adding a check for hardcoded font-size classes and slightly refining the solution to prevent this logic from degrading

I also set up lint-staged support (it passes all files as a list in the format node run-script path-a path-b path-c) and added a script to lint-staged. This should work quickly for most cases and will make debugging easier

I renamed the command to lint:css because it is more familiar to the average developer and formally that's what this script does

Closes #1201

@vercel
Copy link

vercel bot commented Feb 8, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 8, 2026 10:50am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 8, 2026 10:50am
npmx-lunaria Ignored Ignored Feb 8, 2026 10:50am

Request Review

@codecov
Copy link

codecov bot commented Feb 8, 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!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Replaces the RTL-only CSS linting with a unified UnoCSS check that includes both RTL and accessibility presets. Adds a new preset module (uno-preset-a11y.ts) that detects hardcoded font-size tokens (px and em), emits deduplicated warnings or routes them to a provided checker, and suggests existing text-size utilities. Introduces scripts/unocss-checker.ts to run checks per-file, updates package.json scripts and lint-staged, includes presetA11y in uno.config.ts (non‑CI), adds unit tests for the a11y preset, and makes a small class change in LicenseDisplay.vue.

Possibly related PRs

Suggested labels

a11y

Suggested reviewers

  • danielroe
  • userquin
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset, detailing the addition of a11y CSS checks, renaming rtl:check to lint:css, and implementing lint-staged support.
Linked Issues check ✅ Passed All coding objectives from #1201 are satisfied: hardcoded font-size class detection via presetA11y, RTL pattern validation integration, and lint-staged file-list support implemented.
Out of Scope Changes check ✅ Passed Changes in app/components/LicenseDisplay.vue updating text-[0.65em] to text-4xs align with the PR's font-size class refactoring objective and are within scope.

✏️ 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

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
test/unit/uno-preset-a11y.spec.ts (1)

5-93: Consider adding edge case tests for more comprehensive coverage.

The current tests cover the main paths well. For additional robustness, consider adding tests for:

  • Empty input (no matching classes)
  • Classes that should not trigger warnings (e.g., text-sm, text-base)
  • Verifying resetA11yWarnings() correctly clears the deduplication state

This would help ensure the preset handles edge cases gracefully and that the deduplication logic works as expected across multiple generator runs.


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: 2

🧹 Nitpick comments (2)
scripts/unocss-checker.ts (1)

38-48: Consider extracting the duplicated callback logic.

The A11y warning handler (lines 38-48) is nearly identical to the RTL handler (lines 27-37), differing only in the label [A11y] vs [RTL]. Extracting a helper function would reduce duplication.

♻️ Suggested refactor
+function createWarningHandler(
+  label: string,
+  warnings: Map<number, string[]>,
+  getContext: () => { idx: number; line: string; filename: string },
+): (warning: string, rule: string) => void {
+  return (warning, rule) => {
+    const { idx, line, filename } = getContext()
+    let entry = warnings.get(idx)
+    if (!entry) {
+      entry = []
+      warnings.set(idx, entry)
+    }
+    const ruleIdx = line.indexOf(rule)
+    entry.push(
+      `${COLORS.red} ❌ [${label}] ${filename}:${idx}${ruleIdx > -1 ? `:${ruleIdx + 1}` : ''} - ${warning}${COLORS.reset}`,
+    )
+  }
+}

Then use it:

const context = { idx: -1, line: '', filename }
const uno = await createGenerator({
  presets: [
    presetWind4(),
    presetRtl(createWarningHandler('RTL', warnings, () => context)),
    presetA11y(createWarningHandler('A11y', warnings, () => context)),
  ],
})
// Update context.idx and context.line in the loop
uno-preset-a11y.ts (1)

21-26: Consider documenting the mapping relationship with uno.config.ts.

The textPxToClass mapping corresponds to custom theme sizes in uno.config.ts (lines 46-49). A brief comment linking these would help maintainers keep them in sync.

📝 Suggested documentation
+// Maps pixel sizes to custom text classes defined in uno.config.ts theme.text
+// Keep in sync with theme configuration
 const textPxToClass: Record<number, string> = {
 }

@alexdln alexdln added front Frontend, Design a11y Related to accessibility and inclusion labels Feb 8, 2026
@danielroe danielroe added this pull request to the merge queue Feb 8, 2026
Merged via the queue into npmx-dev:main with commit eb19ccd Feb 8, 2026
18 checks passed
iiio2 pushed a commit to iiio2/npmx.dev that referenced this pull request Feb 8, 2026
@userquin
Copy link
Contributor

userquin commented Feb 9, 2026

Nice, I miss this one ❤️ (a11y statement page)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a11y Related to accessibility and inclusion front Frontend, Design

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add font-size check for classes

3 participants