-
-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(biome_css_analyze): add rule useSortedProperties
#4063
base: main
Are you sure you want to change the base?
Conversation
useSortedProperties
useSortedProperties
useSortedProperties
CodSpeed Performance ReportMerging #4063 will degrade performances by 19.89%Comparing Summary
Benchmarks breakdown
|
Thank you @simon-paris for the contribution. I will look into this rule this week. As a very early feedback, this rule should be made an assist (apologies for the lack of documentation, I will try to fix that ASAP). Here's an example of assist: https://github.com/biomejs/biome/blob/main/crates/biome_json_analyze/src/assists/source/use_sorted_keys.rs |
@@ -3436,6 +3436,10 @@ pub struct Nursery { | |||
#[serde(skip_serializing_if = "Option::is_none")] | |||
pub use_sorted_classes: | |||
Option<RuleFixConfiguration<biome_js_analyze::options::UseSortedClasses>>, | |||
#[doc = "Enforce ordering of CSS properties."] | |||
#[serde(skip_serializing_if = "Option::is_none")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know sorting alphabetically may have issues (example) but I'd really appreciate having an option for it. For me it's much more useful than the "recess-order" configuration. Would it be difficult to add support for it?
Summary
Related: #3 (comment), #3167
This implements CSS declaration and rule sorting from the
stylelint-order
plugin. It sorts properties (and nested rules) in a consistent order, e.g:The property order comes from the most popular preset config:
stylelint-config-recess-order
.This is the equivalent stylelint config:
The sort order is this: (ties stay in the same relative order)
a. Custom properties
b. The "composes" property
c. Properties
e. Nested rules and at-rules
f. Other
a. By the order defined in PROPERTY_ORDER
a. By the order defined in VENDOR_PREFIXES
b. Properties with no vendor prefix
Some possible issues:
LazyLock<HashMap>
to implement some lookup tables for this rule. Not sure if that's a good method, I'm new to rust.Test Plan
Unit tests are included.