Skip to content

Conversation

kaathewisegit
Copy link

@kaathewisegit kaathewisegit commented Sep 5, 2025

Summary

Fixes #7407 by adding negative versions of placement utilities (e.g. -end) to the list of Tailwind utilities.

Changeset: Biome now recognizes negative placement utilities such as -inset-px or -end-full. This means that it'll no longer put them at the start of the class list.

Test Plan

?

Copy link

changeset-bot bot commented Sep 5, 2025

⚠️ No Changeset found

Latest commit: d90bfdd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Sep 5, 2025

Walkthrough

The pull request augments the Tailwind utilities whitelist used by the useSortedClasses rule by inserting nine negative placement variants: -inset-, -inset-x-, -inset-y-, -start-, -end-, -top-, -right-, -bottom-, -left-. These are added alongside their positive counterparts in crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs. Consequently, the UTILITIES_LAYER_CLASSES constant size increases from 578 to 587. No other logic or control flow changes are introduced.

Assessment against linked issues

Objective Addressed Explanation
Recognise and sort negative placement utilities in useSortedClasses (-left-, -right-, -top-, -bottom-, -inset-, -inset-x-, -inset-y-, -start-, -end-) [#7407]

Assessment against linked issues: Out-of-scope changes

None found.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Sep 5, 2025
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

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs (1)

21-38: Nice fix: negative placement utilities now recognised

Adding -inset-, -start-, -end-, -top-, -right-, -bottom-, -left- (and x/y variants) should stop them being misclassified and bubbled to the front. Please confirm the sort order matches expectations (e.g. should left-* come before or after -left-* when otherwise equal?) and add a test case for something like: class="container top-0 -left-2 left-1".

Would you like me to draft a couple of useSortedClasses tests covering negative placement (and a quick audit for other negative-able groups like transforms)?

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac9adb and d90bfdd.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (use just f/just format).

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
🧠 Learnings (1)
📚 Learning: 2025-09-05T09:13:58.901Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-09-05T09:13:58.901Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/**/*.rs : Place all new rules in the nursery group under biome_js_analyze/lib/src/lint/nursery

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs

const COMPONENTS_LAYER_CLASSES: [&str; 1] = ["container$"];

const UTILITIES_LAYER_CLASSES: [&str; 578] = [
const UTILITIES_LAYER_CLASSES: [&str; 587] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Edit the generator, not the generated file

This file is explicitly autogen. Please move the change into packages/@biomejs/tailwindcss-config-analyzer and re-run pnpm gen:tailwind-preset so the update is durable and won’t be clobbered on the next regen. Also run repo formatters before commit.


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE=crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs

# Sanity-check that all negative placement tokens are present
rg -n '"-inset-"|"-inset-x-"|"-inset-y-"|"-start-"|"-end-"|"-top-"|"-right-"|"-bottom-"|"-left-"' "$FILE"

# Regenerate from source and show any drift
pnpm -w gen:tailwind-preset
git --no-pager diff -- "$FILE" || true

# Optional: format
just f || just format || true

Length of output: 563


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Confirm file header to verify autogenerated notice
sed -n '1,20p' crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs

# Locate the generator package directory
fd -t d tailwindcss-config-analyzer

# Check for gen:tailwind-preset script in root package.json
rg -n 'gen:tailwind-preset' package.json || echo "No root gen:tailwind-preset script found"

# Check for gen:tailwind-preset script in generator's package.json
if [ -f packages/@biomejs/tailwindcss-config-analyzer/package.json ]; then
  rg -n 'gen:tailwind-preset' packages/@biomejs/tailwindcss-config-analyzer/package.json || echo "No gen:tailwind-preset script in generator"
fi

Length of output: 954


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify the generator package exists and list its scripts
if [ -f packages/tailwindcss-config-analyzer/package.json ]; then
  echo "Found generator package.json at packages/tailwindcss-config-analyzer/package.json"
  rg -n '"gen:tailwind-preset"' packages/tailwindcss-config-analyzer/package.json || echo "gen:tailwind-preset script missing"
else
  echo "Generator package.json not found"
fi

Length of output: 416


Add missing gen:tailwind-preset script and regenerate Tailwind preset

The file crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs is autogenerated—apply your change in packages/tailwindcss-config-analyzer, add a gen:tailwind-preset script to its package.json, run pnpm gen:tailwind-preset, commit the regenerated file, then run the repo’s formatters.

🤖 Prompt for AI Agents
In
crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs
around line 8, the autogenerated Tailwind preset file is out-of-date; you must
not edit this file directly. Instead, open packages/tailwindcss-config-analyzer,
add a "gen:tailwind-preset" script to its package.json that runs the generator
(e.g., node or pnpm command used by the package), run pnpm gen:tailwind-preset
to regenerate the preset, commit the updated tailwind_preset.rs into the crate,
and run the repository formatters (pnpm -w prettier/rustfmt or the repo-specific
format commands) before pushing.

@kaathewisegit
Copy link
Author

Neither pnpm nor I can find the gen:tailwind-preset command. I tried executing the build, but it fails because it can't find the tailwind submodule:

> pnpm run build
src/introspect.ts:4:27 - error TS2307: Cannot find module 'tailwindcss/resolveConfig.js' or its corresponding type declarations.

4 import resolveConfig from "tailwindcss/resolveConfig.js";
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in src/introspect.ts:4

And execution doesn't work either, fails with ERR_PACKAGE_PATH_NOT_EXPORTED.

@ematipico
Copy link
Member

Neither pnpm nor I can find the gen:tailwind-preset command. I tried executing the build, but it fails because it can't find the tailwind submodule:

> pnpm run build
src/introspect.ts:4:27 - error TS2307: Cannot find module 'tailwindcss/resolveConfig.js' or its corresponding type declarations.

4 import resolveConfig from "tailwindcss/resolveConfig.js";
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in src/introspect.ts:4

And execution doesn't work either, fails with ERR_PACKAGE_PATH_NOT_EXPORTED.

It's really an old command, initially built with bun too. It hasn't been run since it was created, so a long time. I'm not sure how it works either, so it's possible it's broken and it requires fixing.

@ematipico
Copy link
Member

Changeset: you must add it yourself, here's how: https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#create-a-changeset

Tests: you must add new tests here https://github.com/biomejs/biome/tree/main/crates/biome_js_analyze/tests/specs/nursery/useSortedClasses

Copy link

codspeed-hq bot commented Sep 7, 2025

CodSpeed Performance Report

Merging #7408 will not alter performance

Comparing kaathewisegit:sorted-classes (d90bfdd) with main (0ac9adb)

Summary

✅ 133 untouched benchmarks

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

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useSortedClasses doesn't recognize negative placement

2 participants