fix(useSortedClasses): handle astro files#11088
Conversation
|
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
Merging this PR will not alter performance
Comparing Footnotes
|
a794091 to
e1c24f3
Compare
WalkthroughThe change moves sorted-class parsing, configuration, and ordering into shared Suggested labels: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/biome_analyze/src/shared/sorted_classes/mod.rs (1)
1-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the shared sorter’s public contract.
These new public submodules expose a cross-analyser API, but the module has no rustdoc explaining its parsing, ordering, or preset contract. Add concise
//!documentation at this boundary. As per coding guidelines, new Rust features should use rustdoc documentation.🤖 Prompt for 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. In `@crates/biome_analyze/src/shared/sorted_classes/mod.rs` around lines 1 - 6, Add concise module-level rustdoc (`//!`) to the shared sorted_classes module, documenting its public parsing, ordering, and preset contract for cross-analyser consumers. Place the documentation at the module boundary before the public submodule declarations, without changing the exposed API.Source: Coding guidelines
🤖 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 `@crates/biome_html_analyze/src/lint/nursery/use_sorted_classes.rs`:
- Around line 68-73: Extend use_sorted_classes.rs so HtmlAttribute analysis also
handles Astro expression-valued class attributes by extracting the interpolated
expression text and passing an appropriate replacement target through the
rule/action path, while preserving existing HtmlString handling. Add a
regression case to
crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.astro
covering an unsorted class expression and its expected diagnostic/fix.
---
Nitpick comments:
In `@crates/biome_analyze/src/shared/sorted_classes/mod.rs`:
- Around line 1-6: Add concise module-level rustdoc (`//!`) to the shared
sorted_classes module, documenting its public parsing, ordering, and preset
contract for cross-analyser consumers. Place the documentation at the module
boundary before the public submodule declarations, without changing the exposed
API.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 89a0cd36-7287-4df2-ab36-cae9a9348527
⛔ Files ignored due to path filters (7)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.html.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/valid.astro.snapis excluded by!**/*.snapand included by**crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/valid.html.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (18)
crates/biome_analyze/Cargo.tomlcrates/biome_analyze/src/shared/mod.rscrates/biome_analyze/src/shared/sorted_classes/class_info.rscrates/biome_analyze/src/shared/sorted_classes/class_lexer.rscrates/biome_analyze/src/shared/sorted_classes/mod.rscrates/biome_analyze/src/shared/sorted_classes/presets.rscrates/biome_analyze/src/shared/sorted_classes/sort.rscrates/biome_analyze/src/shared/sorted_classes/sort_config.rscrates/biome_analyze/src/shared/sorted_classes/tailwind_preset.rscrates/biome_html_analyze/src/lint/nursery/use_sorted_classes.rscrates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.astrocrates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.htmlcrates/biome_html_analyze/tests/specs/nursery/useSortedClasses/valid.astrocrates/biome_html_analyze/tests/specs/nursery/useSortedClasses/valid.htmlcrates/biome_js_analyze/benches/use_sorted_classes_parser.rscrates/biome_js_analyze/src/lint/nursery/use_sorted_classes.rscrates/biome_js_analyze/src/lint/nursery/use_sorted_classes/sort.rspackages/tailwindcss-config-analyzer/src/generate-tailwind-preset.ts
💤 Files with no reviewable changes (1)
- crates/biome_analyze/src/shared/sorted_classes/presets.rs
| let initializer = attribute.initializer()?; | ||
| let value = initializer.value().ok()?; | ||
| let html_string = value.as_html_string()?.clone(); | ||
| let value_token = html_string.value_token().ok()?; | ||
| let inner_text = inner_string_text(&value_token); | ||
| let value_str = inner_text.text(); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg 'use_sorted_classes|useSortedClasses|ast|html' | sed -n '1,200p'
echo "== rule outline =="
ast-grep outline crates/biome_html_analyze/src/lint/nursery/use_sorted_classes.rs --view expanded || true
echo "== rule relevant lines =="
cat -n crates/biome_html_analyze/src/lint/nursery/use_sorted_classes.rs | sed -n '1,180p'
echo "== tests =="
cat -n crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.astro | sed -n '1,200p'
fd -a 'useSortedClasses' crates/biome_html_analyze/tests/specs | sed -n '1,200p'Repository: biomejs/biome
Length of output: 21245
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Astro spec fixtures =="
find crates/biome_html_analyze/tests/specs/nursery/useSortedClasses -type f | sort | while read -r f; do
echo "--- $f"
sed -n '1,220p' "$f"
done
echo "== search for useSortedClasses/UseSortedClasses/usages =="
rg -n "useSortedClasses|UseSortedClasses|use_sorted_classes|sorted_classes" crates/biome_html_analyze crates/biome_html_formatter crates/ -g '*.rs' -g '*.astro' -g '*.html' | sed -n '1,240p'
echo "== html string initializer AST refs around HtmlAttribute initializer value_as_html_string =="
rg -n "HtmlAttribute|initializer\(|value\(|as_html_string|HtmlString" crates/biome_html_syntax crates/biome_html_factory -g '*.rs' | sed -n '1,260p'Repository: biomejs/biome
Length of output: 43386
Handle expression-valued Astro class attributes in both the rule and the fixture.
useSortedClasses currently only descends HtmlAttribute into HtmlString, so Astro interpolations like class={unsortedClasses} are skipped. Add a regression case in the Astro spec and extend the rule/action path to work from the interpolated expression text plus a replacement target rather than only from HtmlString.
📍 Affects 2 files
crates/biome_html_analyze/src/lint/nursery/use_sorted_classes.rs#L68-L73(this comment)crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.astro#L3-L5
🤖 Prompt for 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.
In `@crates/biome_html_analyze/src/lint/nursery/use_sorted_classes.rs` around
lines 68 - 73, Extend use_sorted_classes.rs so HtmlAttribute analysis also
handles Astro expression-valued class attributes by extracting the interpolated
expression text and passing an appropriate replacement target through the
rule/action path, while preserving existing HtmlString handling. Add a
regression case to
crates/biome_html_analyze/tests/specs/nursery/useSortedClasses/invalid.astro
covering an unsorted class expression and its expected diagnostic/fix.
Source: Coding guidelines
There was a problem hiding this comment.
Yes, that's out of scope for this PR currently
|
This isn't a fix though, we're adding an existing rule to another category of files. It's a new feature, so it's a |
The |
It's fine, you can still open it. Is there some specific code you need from |
There were some changes on |
Summary
Closes #9181
Most of this was written by AI with my guidance
Test Plan
I've added
crates\biome_html_analyze\tests\specs\nursery\useSortedClassesDocs
N/A